Completed
Push — master ( 94097c...2ab4e5 )
by Yannick
55:33 queued 24:26
created
scripts/daemon-spotter.php 1 patch
Indentation   +1016 added lines, -1016 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,125 +190,125 @@  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('/\/api\/v1\/acars\/data$/i',$host)) {
208
-        	//$formats[$id] = 'phpvmacars';
209
-        	$globalSources[$id]['format'] = 'vaos';
210
-        	//$last_exec['phpvmacars'] = 0;
211
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
212
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
213
-        	//$formats[$id] = 'phpvmacars';
214
-        	$globalSources[$id]['format'] = 'vam';
215
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
216
-            } else if (preg_match('/whazzup/i',$host)) {
217
-        	//$formats[$id] = 'whazzup';
218
-        	$globalSources[$id]['format'] = 'whazzup';
219
-        	//$last_exec['whazzup'] = 0;
220
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
221
-            } else if (preg_match('/blitzortung/i',$host)) {
222
-        	$globalSources[$id]['format'] = 'blitzortung';
223
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
224
-            } else if (preg_match('/airwhere/i',$host)) {
225
-        	$globalSources[$id]['format'] = 'airwhere';
226
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
227
-            } else if (preg_match('/recentpireps/i',$host)) {
228
-        	//$formats[$id] = 'pirepsjson';
229
-        	$globalSources[$id]['format'] = 'pirepsjson';
230
-        	//$last_exec['pirepsjson'] = 0;
231
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
232
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
233
-        	//$formats[$id] = 'fr24json';
234
-        	$globalSources[$id]['format'] = 'fr24json';
235
-        	//$last_exec['fr24json'] = 0;
236
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
237
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
238
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
239
-        	    exit(0);
240
-        	}
241
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
242
-        	//$formats[$id] = 'fr24json';
243
-        	$globalSources[$id]['format'] = 'myshiptracking';
244
-        	//$last_exec['fr24json'] = 0;
245
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
246
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
247
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
248
-        	    exit(0);
249
-        	}
250
-            //} else if (preg_match('/10001/',$host)) {
251
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
252
-        	//$formats[$id] = 'tsv';
253
-        	$globalSources[$id]['format'] = 'tsv';
254
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
255
-            }
256
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
257
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
258
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
259
-    		    if ($idf !== false) {
260
-    			$httpfeeds[$id] = $idf;
261
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
262
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
263
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
264
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
265
-	    $hostport = explode(':',$host);
266
-	    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('/\/api\/v1\/acars\/data$/i',$host)) {
208
+			//$formats[$id] = 'phpvmacars';
209
+			$globalSources[$id]['format'] = 'vaos';
210
+			//$last_exec['phpvmacars'] = 0;
211
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
212
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
213
+			//$formats[$id] = 'phpvmacars';
214
+			$globalSources[$id]['format'] = 'vam';
215
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
216
+			} else if (preg_match('/whazzup/i',$host)) {
217
+			//$formats[$id] = 'whazzup';
218
+			$globalSources[$id]['format'] = 'whazzup';
219
+			//$last_exec['whazzup'] = 0;
220
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
221
+			} else if (preg_match('/blitzortung/i',$host)) {
222
+			$globalSources[$id]['format'] = 'blitzortung';
223
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
224
+			} else if (preg_match('/airwhere/i',$host)) {
225
+			$globalSources[$id]['format'] = 'airwhere';
226
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
227
+			} else if (preg_match('/recentpireps/i',$host)) {
228
+			//$formats[$id] = 'pirepsjson';
229
+			$globalSources[$id]['format'] = 'pirepsjson';
230
+			//$last_exec['pirepsjson'] = 0;
231
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
232
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
233
+			//$formats[$id] = 'fr24json';
234
+			$globalSources[$id]['format'] = 'fr24json';
235
+			//$last_exec['fr24json'] = 0;
236
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
237
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
238
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
239
+				exit(0);
240
+			}
241
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
242
+			//$formats[$id] = 'fr24json';
243
+			$globalSources[$id]['format'] = 'myshiptracking';
244
+			//$last_exec['fr24json'] = 0;
245
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
246
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
247
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
248
+				exit(0);
249
+			}
250
+			//} else if (preg_match('/10001/',$host)) {
251
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
252
+			//$formats[$id] = 'tsv';
253
+			$globalSources[$id]['format'] = 'tsv';
254
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
255
+			}
256
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
257
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
258
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
259
+				if ($idf !== false) {
260
+				$httpfeeds[$id] = $idf;
261
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
262
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
263
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
264
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
265
+		$hostport = explode(':',$host);
266
+		if (isset($hostport[1])) {
267 267
 		$port = $hostport[1];
268 268
 		$hostn = $hostport[0];
269
-	    } else {
269
+		} else {
270 270
 		$port = $globalSources[$id]['port'];
271 271
 		$hostn = $globalSources[$id]['host'];
272
-	    }
273
-	    $Common = new Common();
274
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
275
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
276
-    	    } else {
277
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
278
-	    }
279
-	    if ($s) {
280
-    	        $sockets[$id] = $s;
281
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
282
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
272
+		}
273
+		$Common = new Common();
274
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
275
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
276
+			} else {
277
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
278
+		}
279
+		if ($s) {
280
+				$sockets[$id] = $s;
281
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
282
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
283 283
 			//$formats[$id] = 'aprs';
284 284
 			$globalSources[$id]['format'] = 'aprs';
285 285
 			//$aprs_connect = 0;
286 286
 			//$use_aprs = true;
287
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
287
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
288 288
 			$globalSources[$id]['format'] = 'vrstcp';
289
-    		    } elseif ($port == '10001') {
290
-        		//$formats[$id] = 'tsv';
291
-        		$globalSources[$id]['format'] = 'tsv';
292
-		    } elseif ($port == '30002') {
293
-        		//$formats[$id] = 'raw';
294
-        		$globalSources[$id]['format'] = 'raw';
295
-		    } elseif ($port == '5001') {
296
-        		//$formats[$id] = 'raw';
297
-        		$globalSources[$id]['format'] = 'flightgearmp';
298
-		    } elseif ($port == '30005') {
289
+				} elseif ($port == '10001') {
290
+				//$formats[$id] = 'tsv';
291
+				$globalSources[$id]['format'] = 'tsv';
292
+			} elseif ($port == '30002') {
293
+				//$formats[$id] = 'raw';
294
+				$globalSources[$id]['format'] = 'raw';
295
+			} elseif ($port == '5001') {
296
+				//$formats[$id] = 'raw';
297
+				$globalSources[$id]['format'] = 'flightgearmp';
298
+			} elseif ($port == '30005') {
299 299
 			// Not yet supported
300
-        		//$formats[$id] = 'beast';
301
-        		$globalSources[$id]['format'] = 'beast';
302
-		    //} else $formats[$id] = 'sbs';
303
-		    } else $globalSources[$id]['format'] = 'sbs';
304
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
300
+				//$formats[$id] = 'beast';
301
+				$globalSources[$id]['format'] = 'beast';
302
+			//} else $formats[$id] = 'sbs';
303
+			} else $globalSources[$id]['format'] = 'sbs';
304
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
305 305
 		}
306 306
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
307
-            } else {
307
+			} else {
308 308
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
309
-    	    }
310
-        }
311
-    }
309
+			}
310
+		}
311
+	}
312 312
 }
313 313
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
314 314
 
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 //connect_all($globalSources);
332 332
 
333 333
 if (isset($globalProxy) && $globalProxy) {
334
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
334
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
335 335
 } else {
336
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
336
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
337 337
 }
338 338
 
339 339
 // APRS Configuration
@@ -342,21 +342,21 @@  discard block
 block discarded – undo
342 342
 	die;
343 343
 }
344 344
 foreach ($globalSources as $key => $source) {
345
-    if (!isset($source['format'])) {
346
-        $globalSources[$key]['format'] = 'auto';
347
-    }
348
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
349
-        unset($globalSources[$key]);
350
-    }
345
+	if (!isset($source['format'])) {
346
+		$globalSources[$key]['format'] = 'auto';
347
+	}
348
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
349
+		unset($globalSources[$key]);
350
+	}
351 351
 }
352 352
 connect_all($globalSources);
353 353
 foreach ($globalSources as $key => $source) {
354
-    if (isset($source['format']) && $source['format'] == 'aprs') {
354
+	if (isset($source['format']) && $source['format'] == 'aprs') {
355 355
 	$aprs_connect = 0;
356 356
 	$use_aprs = true;
357 357
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
358 358
 	break;
359
-    }
359
+	}
360 360
 }
361 361
 
362 362
 if ($use_aprs) {
@@ -397,129 +397,129 @@  discard block
 block discarded – undo
397 397
 
398 398
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
399 399
 while ($i > 0) {
400
-    if (!$globalDaemon) $i = $endtime-time();
401
-    // Delete old ATC
402
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
400
+	if (!$globalDaemon) $i = $endtime-time();
401
+	// Delete old ATC
402
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
403 403
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
404
-        $ATC->deleteOldATC();
405
-    }
404
+		$ATC->deleteOldATC();
405
+	}
406 406
     
407
-    if (count($last_exec) == count($globalSources)) {
407
+	if (count($last_exec) == count($globalSources)) {
408 408
 	$max = $globalMinFetch;
409 409
 	foreach ($last_exec as $last) {
410
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
410
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
411 411
 	}
412 412
 	if ($max != $globalMinFetch) {
413
-	    if ($globalDebug) echo 'Sleeping...'."\n";
414
-	    sleep($globalMinFetch-$max+2);
413
+		if ($globalDebug) echo 'Sleeping...'."\n";
414
+		sleep($globalMinFetch-$max+2);
415
+	}
415 416
 	}
416
-    }
417 417
 
418 418
     
419
-    //foreach ($formats as $id => $value) {
420
-    foreach ($globalSources as $id => $value) {
419
+	//foreach ($formats as $id => $value) {
420
+	foreach ($globalSources as $id => $value) {
421 421
 	date_default_timezone_set('UTC');
422 422
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
423 423
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
424 424
 	if ($value['format'] == 'deltadbtxt' && 
425
-	    (
425
+		(
426 426
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
427 427
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
428
-	    )
428
+		)
429 429
 	) {
430
-	    //$buffer = $Common->getData($hosts[$id]);
431
-	    $buffer = $Common->getData($value['host']);
432
-	    if ($buffer != '') $reset = 0;
433
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434
-	    $buffer = explode('\n',$buffer);
435
-	    foreach ($buffer as $line) {
436
-    		if ($line != '' && count($line) > 7) {
437
-    		    $line = explode(',', $line);
438
-	            $data = array();
439
-	            $data['hex'] = $line[1]; // hex
440
-	            $data['ident'] = $line[2]; // ident
441
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
442
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
443
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
444
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
445
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
446
-	            $data['verticalrate'] = ''; // vertical rate
447
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
448
-	            $data['emergency'] = ''; // emergency
449
-		    $data['datetime'] = date('Y-m-d H:i:s');
450
-		    $data['format_source'] = 'deltadbtxt';
451
-    		    $data['id_source'] = $id_source;
452
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
453
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
454
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
455
-    		    $SI->add($data);
456
-		    unset($data);
457
-    		}
458
-    	    }
459
-    	    $last_exec[$id]['last'] = time();
430
+		//$buffer = $Common->getData($hosts[$id]);
431
+		$buffer = $Common->getData($value['host']);
432
+		if ($buffer != '') $reset = 0;
433
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434
+		$buffer = explode('\n',$buffer);
435
+		foreach ($buffer as $line) {
436
+			if ($line != '' && count($line) > 7) {
437
+				$line = explode(',', $line);
438
+				$data = array();
439
+				$data['hex'] = $line[1]; // hex
440
+				$data['ident'] = $line[2]; // ident
441
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
442
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
443
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
444
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
445
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
446
+				$data['verticalrate'] = ''; // vertical rate
447
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
448
+				$data['emergency'] = ''; // emergency
449
+			$data['datetime'] = date('Y-m-d H:i:s');
450
+			$data['format_source'] = 'deltadbtxt';
451
+				$data['id_source'] = $id_source;
452
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
453
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
454
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
455
+				$SI->add($data);
456
+			unset($data);
457
+			}
458
+			}
459
+			$last_exec[$id]['last'] = time();
460 460
 	} elseif ($value['format'] == 'aisnmeatxt' && 
461
-	    (
461
+		(
462 462
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
463 463
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
464
-	    )
464
+		)
465 465
 	) {
466
-	    date_default_timezone_set('CET');
467
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
468
-	    date_default_timezone_set('UTC');
469
-	    if ($buffer != '') $reset = 0;
470
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
471
-	    $buffer = explode('\n',$buffer);
472
-	    foreach ($buffer as $line) {
466
+		date_default_timezone_set('CET');
467
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
468
+		date_default_timezone_set('UTC');
469
+		if ($buffer != '') $reset = 0;
470
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
471
+		$buffer = explode('\n',$buffer);
472
+		foreach ($buffer as $line) {
473 473
 		if ($line != '') {
474
-		    //echo "'".$line."'\n";
475
-		    $add = false;
476
-		    $ais_data = $AIS->parse_line(trim($line));
477
-		    $data = array();
478
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
479
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
480
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
481
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
482
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
483
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
484
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
485
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
486
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
487
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
488
-		    if (isset($ais_data['timestamp'])) {
474
+			//echo "'".$line."'\n";
475
+			$add = false;
476
+			$ais_data = $AIS->parse_line(trim($line));
477
+			$data = array();
478
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
479
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
480
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
481
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
482
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
483
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
484
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
485
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
486
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
487
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
488
+			if (isset($ais_data['timestamp'])) {
489 489
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
490 490
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
491
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
492
-			    $add = true;
491
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
492
+				$add = true;
493 493
 			}
494
-		    } else {
494
+			} else {
495 495
 			$data['datetime'] = date('Y-m-d H:i:s');
496 496
 			$add = true;
497
-		    }
498
-		    $data['format_source'] = 'aisnmeatxt';
499
-    		    $data['id_source'] = $id_source;
500
-		    //print_r($data);
501
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
502
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
503
-		    unset($data);
497
+			}
498
+			$data['format_source'] = 'aisnmeatxt';
499
+				$data['id_source'] = $id_source;
500
+			//print_r($data);
501
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
502
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
503
+			unset($data);
504 504
 		}
505
-    	    }
506
-    	    $last_exec[$id]['last'] = time();
505
+			}
506
+			$last_exec[$id]['last'] = time();
507 507
 	} elseif ($value['format'] == 'aisnmeahttp') {
508
-	    $arr = $httpfeeds;
509
-	    $w = $e = null;
508
+		$arr = $httpfeeds;
509
+		$w = $e = null;
510 510
 	    
511
-	    if (isset($arr[$id])) {
511
+		if (isset($arr[$id])) {
512 512
 		$nn = stream_select($arr,$w,$e,$timeout);
513 513
 		if ($nn > 0) {
514
-		    foreach ($httpfeeds as $feed) {
514
+			foreach ($httpfeeds as $feed) {
515 515
 			$buffer = stream_get_line($feed,2000,"\n");
516 516
 			if ($buffer === FALSE) {
517
-			    connect_all($globalSources);
517
+				connect_all($globalSources);
518 518
 			}
519 519
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
520 520
 			$buffer = explode('\n',$buffer);
521 521
 			foreach ($buffer as $line) {
522
-			    if ($line != '') {
522
+				if ($line != '') {
523 523
 				$ais_data = $AIS->parse_line(trim($line));
524 524
 				$data = array();
525 525
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -537,115 +537,115 @@  discard block
 block discarded – undo
537 537
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
538 538
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
539 539
 				if (isset($ais_data['timestamp'])) {
540
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
540
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
541 541
 				} else {
542
-				    $data['datetime'] = date('Y-m-d H:i:s');
542
+					$data['datetime'] = date('Y-m-d H:i:s');
543 543
 				}
544 544
 				$data['format_source'] = 'aisnmeahttp';
545 545
 				$data['id_source'] = $id_source;
546 546
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
547 547
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
548 548
 				unset($data);
549
-			    }
549
+				}
550
+			}
550 551
 			}
551
-		    }
552 552
 		} else {
553
-		    $format = $value['format'];
554
-		    if (isset($tt[$format])) $tt[$format]++;
555
-		    else $tt[$format] = 0;
556
-		    if ($tt[$format] > 30) {
553
+			$format = $value['format'];
554
+			if (isset($tt[$format])) $tt[$format]++;
555
+			else $tt[$format] = 0;
556
+			if ($tt[$format] > 30) {
557 557
 			if ($globalDebug) echo 'Reconnect...'."\n";
558 558
 			sleep(2);
559 559
 			//$sourceeen[] = $value;
560 560
 			//connect_all($sourceeen);
561 561
 			//$sourceeen = array();
562 562
 			connect_all($globalSources);
563
-		    }
563
+			}
564
+		}
564 565
 		}
565
-	    }
566 566
 	} elseif ($value['format'] == 'myshiptracking' && 
567
-	    (
567
+		(
568 568
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
569 569
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
570
-	    )
570
+		)
571 571
 	) {
572
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
573
-	    if ($buffer != '') {
572
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
573
+		if ($buffer != '') {
574 574
 		//echo $buffer;
575 575
 		$all_data = json_decode($buffer,true);
576 576
 		//print_r($all_data);
577 577
 		if (isset($all_data[0]['DATA'])) {
578
-		    foreach ($all_data[0]['DATA'] as $line) {
578
+			foreach ($all_data[0]['DATA'] as $line) {
579 579
 			if ($line != '') {
580
-			    $data = array();
581
-			    $data['ident'] = $line['NAME'];
582
-			    $data['mmsi'] = $line['MMSI'];
583
-			    if (strlen($data['mmsi']) > 9) {
580
+				$data = array();
581
+				$data['ident'] = $line['NAME'];
582
+				$data['mmsi'] = $line['MMSI'];
583
+				if (strlen($data['mmsi']) > 9) {
584 584
 				$data['mmsi'] = substr($data['mmsi'],-9);
585
-			    }
586
-			    $data['speed'] = $line['SOG'];
587
-			    $data['heading'] = $line['COG'];
588
-			    $data['latitude'] = $line['LAT'];
589
-			    $data['longitude'] = $line['LNG'];
590
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
591
-			    $data['imo'] = $line['IMO'];
592
-			    //$data['arrival_code'] = $ais_data['destination'];
593
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
594
-			    $data['format_source'] = 'myshiptracking';
595
-			    $data['id_source'] = $id_source;
596
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
597
-			    $MI->add($data);
598
-			    unset($data);
585
+				}
586
+				$data['speed'] = $line['SOG'];
587
+				$data['heading'] = $line['COG'];
588
+				$data['latitude'] = $line['LAT'];
589
+				$data['longitude'] = $line['LNG'];
590
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
591
+				$data['imo'] = $line['IMO'];
592
+				//$data['arrival_code'] = $ais_data['destination'];
593
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
594
+				$data['format_source'] = 'myshiptracking';
595
+				$data['id_source'] = $id_source;
596
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
597
+				$MI->add($data);
598
+				unset($data);
599
+			}
599 600
 			}
600
-		    }
601 601
 		}
602
-	    }
603
-	    $last_exec[$id]['last'] = time();
602
+		}
603
+		$last_exec[$id]['last'] = time();
604 604
 	} elseif ($value['format'] == 'boatbeaconapp' && 
605
-	    (
605
+		(
606 606
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
607 607
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
608
-	    )
608
+		)
609 609
 	) {
610
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
611
-	    if ($buffer != '') {
610
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
611
+		if ($buffer != '') {
612 612
 		$all_data = json_decode($buffer,true);
613 613
 		if (isset($all_data[0]['mmsi'])) {
614
-		    foreach ($all_data as $line) {
614
+			foreach ($all_data as $line) {
615 615
 			if ($line != '') {
616
-			    $data = array();
617
-			    $data['ident'] = $line['shipname'];
618
-			    $data['callsign'] = $line['callsign'];
619
-			    $data['mmsi'] = $line['mmsi'];
620
-			    $data['speed'] = $line['sog'];
621
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
622
-			    $data['latitude'] = $line['latitude'];
623
-			    $data['longitude'] = $line['longitude'];
624
-			    $data['type_id'] = $line['shiptype'];
625
-			    $data['arrival_code'] = $line['destination'];
626
-			    $data['datetime'] = $line['time'];
627
-			    $data['format_source'] = 'boatbeaconapp';
628
-			    $data['id_source'] = $id_source;
629
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
630
-			    $MI->add($data);
631
-			    unset($data);
616
+				$data = array();
617
+				$data['ident'] = $line['shipname'];
618
+				$data['callsign'] = $line['callsign'];
619
+				$data['mmsi'] = $line['mmsi'];
620
+				$data['speed'] = $line['sog'];
621
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
622
+				$data['latitude'] = $line['latitude'];
623
+				$data['longitude'] = $line['longitude'];
624
+				$data['type_id'] = $line['shiptype'];
625
+				$data['arrival_code'] = $line['destination'];
626
+				$data['datetime'] = $line['time'];
627
+				$data['format_source'] = 'boatbeaconapp';
628
+				$data['id_source'] = $id_source;
629
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
630
+				$MI->add($data);
631
+				unset($data);
632
+			}
632 633
 			}
633
-		    }
634 634
 		}
635 635
 		
636
-	    }
637
-    	    $last_exec[$id]['last'] = time();
636
+		}
637
+			$last_exec[$id]['last'] = time();
638 638
 	} elseif ($value['format'] == 'boatnerd' && 
639
-	    (
639
+		(
640 640
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
641 641
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
642
-	    )
642
+		)
643 643
 	) {
644
-	    $buffer = $Common->getData($value['host']);
645
-	    if ($buffer != '') {
644
+		$buffer = $Common->getData($value['host']);
645
+		if ($buffer != '') {
646 646
 		$all_data = json_decode($buffer,true);
647 647
 		if (isset($all_data['features'][0]['id'])) {
648
-		    foreach ($all_data['features'] as $line) {
648
+			foreach ($all_data['features'] as $line) {
649 649
 			$data = array();
650 650
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
651 651
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -664,78 +664,78 @@  discard block
 block discarded – undo
664 664
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
665 665
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
666 666
 			unset($data);
667
-		    }
667
+			}
668 668
 		}
669 669
 		
670
-	    }
671
-    	    $last_exec[$id]['last'] = time();
670
+		}
671
+			$last_exec[$id]['last'] = time();
672 672
 	} elseif ($value['format'] == 'shipplotter' && 
673
-	    (
673
+		(
674 674
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
675 675
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
676
-	    )
676
+		)
677 677
 	) {
678
-	    echo 'download...';
679
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
680
-	    echo 'done !'."\n";
681
-	    if ($buffer != '') $reset = 0;
682
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
683
-	    $buffer = explode('\n',$buffer);
684
-	    foreach ($buffer as $line) {
678
+		echo 'download...';
679
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
680
+		echo 'done !'."\n";
681
+		if ($buffer != '') $reset = 0;
682
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
683
+		$buffer = explode('\n',$buffer);
684
+		foreach ($buffer as $line) {
685 685
 		if ($line != '') {
686
-		    $data = array();
687
-		    $data['mmsi'] = (int)substr($line,0,9);
688
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
689
-		    //$data['status'] = substr($line,21,2);
690
-		    //$data['type'] = substr($line,24,3);
691
-		    $data['latitude'] = substr($line,29,9);
692
-		    $data['longitude'] = substr($line,41,9);
693
-		    $data['speed'] = round(substr($line,51,5));
694
-		    //$data['course'] = substr($line,57,5);
695
-		    $data['heading'] = round(substr($line,63,3));
696
-		    //$data['draft'] = substr($line,67,4);
697
-		    //$data['length'] = substr($line,72,3);
698
-		    //$data['beam'] = substr($line,76,2);
699
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
700
-		    //$data['callsign'] = trim(substr($line,100,7);
701
-		    //$data['dest'] = substr($line,108,20);
702
-		    //$data['etaDate'] = substr($line,129,5);
703
-		    //$data['etaTime'] = substr($line,135,5);
704
-		    $data['format_source'] = 'shipplotter';
705
-    		    $data['id_source'] = $id_source;
706
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
707
-		    //print_r($data);
708
-		    echo 'Add...'."\n";
709
-		    $MI->add($data);
710
-		    unset($data);
686
+			$data = array();
687
+			$data['mmsi'] = (int)substr($line,0,9);
688
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
689
+			//$data['status'] = substr($line,21,2);
690
+			//$data['type'] = substr($line,24,3);
691
+			$data['latitude'] = substr($line,29,9);
692
+			$data['longitude'] = substr($line,41,9);
693
+			$data['speed'] = round(substr($line,51,5));
694
+			//$data['course'] = substr($line,57,5);
695
+			$data['heading'] = round(substr($line,63,3));
696
+			//$data['draft'] = substr($line,67,4);
697
+			//$data['length'] = substr($line,72,3);
698
+			//$data['beam'] = substr($line,76,2);
699
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
700
+			//$data['callsign'] = trim(substr($line,100,7);
701
+			//$data['dest'] = substr($line,108,20);
702
+			//$data['etaDate'] = substr($line,129,5);
703
+			//$data['etaTime'] = substr($line,135,5);
704
+			$data['format_source'] = 'shipplotter';
705
+				$data['id_source'] = $id_source;
706
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
707
+			//print_r($data);
708
+			echo 'Add...'."\n";
709
+			$MI->add($data);
710
+			unset($data);
711 711
 		}
712
-    	    }
713
-    	    $last_exec[$id]['last'] = time();
712
+			}
713
+			$last_exec[$id]['last'] = time();
714 714
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
715 715
 	} elseif (
716
-	    (
716
+		(
717 717
 		$value['format'] == 'whazzup' && 
718 718
 		(
719
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
720
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
719
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
720
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
721 721
 		)
722
-	    ) || (
722
+		) || (
723 723
 		$value['format'] == 'vatsimtxt' && 
724 724
 		(
725
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
726
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
725
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
726
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
727
+		)
727 728
 		)
728
-	    )
729 729
 	) {
730
-	    //$buffer = $Common->getData($hosts[$id]);
731
-	    $buffer = $Common->getData($value['host']);
732
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
733
-	    $buffer = explode('\n',$buffer);
734
-	    $reset = 0;
735
-	    foreach ($buffer as $line) {
736
-    		if ($line != '') {
737
-    		    $line = explode(':', $line);
738
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
730
+		//$buffer = $Common->getData($hosts[$id]);
731
+		$buffer = $Common->getData($value['host']);
732
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
733
+		$buffer = explode('\n',$buffer);
734
+		$reset = 0;
735
+		foreach ($buffer as $line) {
736
+			if ($line != '') {
737
+				$line = explode(':', $line);
738
+				if (count($line) > 30 && $line[0] != 'callsign') {
739 739
 			$data = array();
740 740
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
741 741
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -748,37 +748,37 @@  discard block
 block discarded – undo
748 748
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
749 749
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
750 750
 			$data['latitude'] = $line[5]; // lat
751
-	        	$data['longitude'] = $line[6]; // long
752
-	        	$data['verticalrate'] = ''; // vertical rate
753
-	        	$data['squawk'] = ''; // squawk
754
-	        	$data['emergency'] = ''; // emergency
755
-	        	$data['waypoints'] = $line[30];
751
+				$data['longitude'] = $line[6]; // long
752
+				$data['verticalrate'] = ''; // vertical rate
753
+				$data['squawk'] = ''; // squawk
754
+				$data['emergency'] = ''; // emergency
755
+				$data['waypoints'] = $line[30];
756 756
 			$data['datetime'] = date('Y-m-d H:i:s');
757 757
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
758 758
 			//if (isset($line[37])) $data['last_update'] = $line[37];
759
-		        $data['departure_airport_icao'] = $line[11];
760
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
761
-		        $data['arrival_airport_icao'] = $line[13];
759
+				$data['departure_airport_icao'] = $line[11];
760
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
761
+				$data['arrival_airport_icao'] = $line[13];
762 762
 			$data['frequency'] = $line[4];
763 763
 			$data['type'] = $line[18];
764 764
 			$data['range'] = $line[19];
765 765
 			if (isset($line[35])) $data['info'] = $line[35];
766
-    			$data['id_source'] = $id_source;
767
-	    		//$data['arrival_airport_time'] = ;
768
-	    		if ($line[9] != '') {
769
-	    		    $aircraft_data = explode('/',$line[9]);
770
-	    		    if (isset($aircraft_data[1])) {
771
-	    			$data['aircraft_icao'] = $aircraft_data[1];
772
-	    		    }
773
-        		}
774
-	    		/*
766
+				$data['id_source'] = $id_source;
767
+				//$data['arrival_airport_time'] = ;
768
+				if ($line[9] != '') {
769
+					$aircraft_data = explode('/',$line[9]);
770
+					if (isset($aircraft_data[1])) {
771
+					$data['aircraft_icao'] = $aircraft_data[1];
772
+					}
773
+				}
774
+				/*
775 775
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
776 776
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
777 777
 	    		*/
778
-	    		$data['format_source'] = $value['format'];
778
+				$data['format_source'] = $value['format'];
779 779
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
780 780
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
781
-    			if ($line[3] == 'PILOT') $SI->add($data);
781
+				if ($line[3] == 'PILOT') $SI->add($data);
782 782
 			elseif ($line[3] == 'ATC') {
783 783
 				//print_r($data);
784 784
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -799,21 +799,21 @@  discard block
 block discarded – undo
799 799
 					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']);
800 800
 				}
801 801
 			}
802
-    			unset($data);
803
-    		    }
804
-    		}
805
-    	    }
806
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
807
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
808
-    	    $last_exec[$id]['last'] = time();
809
-    	} elseif ($value['format'] == 'airwhere' && 
810
-    	    (
811
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
812
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
813
-    	    )
814
-    	) {
815
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
816
-	    if ($buffer != '') {
802
+				unset($data);
803
+				}
804
+			}
805
+			}
806
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
807
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
808
+			$last_exec[$id]['last'] = time();
809
+		} elseif ($value['format'] == 'airwhere' && 
810
+			(
811
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
812
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
813
+			)
814
+		) {
815
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
816
+		if ($buffer != '') {
817 817
 		$all_data = simplexml_load_string($buffer);
818 818
 		foreach($all_data->children() as $childdata) {
819 819
 			$data = array();
@@ -835,10 +835,10 @@  discard block
 block discarded – undo
835 835
 			$SI->add($data);
836 836
 			unset($data);
837 837
 		}
838
-	    }
839
-	    $Source->deleteOldLocationByType('gs');
840
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
841
-	    if ($buffer != '') {
838
+		}
839
+		$Source->deleteOldLocationByType('gs');
840
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
841
+		if ($buffer != '') {
842 842
 		$all_data = simplexml_load_string($buffer);
843 843
 		foreach($all_data->children() as $childdata) {
844 844
 			$data = array();
@@ -856,8 +856,8 @@  discard block
 block discarded – undo
856 856
 			}
857 857
 			unset($data);
858 858
 		}
859
-	    }
860
-	    $last_exec[$id]['last'] = time();
859
+		}
860
+		$last_exec[$id]['last'] = time();
861 861
 	/*
862 862
 	} if ($value['format'] == 'aircraftlistjson') {
863 863
 	    print_r($globalSources);
@@ -865,17 +865,17 @@  discard block
 block discarded – undo
865 865
 	    echo $globalMinFetch;
866 866
 	*/
867 867
 	} elseif ($value['format'] == 'aircraftlistjson' && 
868
-	    (
868
+		(
869 869
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
870 870
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
871
-	    )
871
+		)
872 872
 	) {
873
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
874
-	    if ($buffer != '') {
875
-	        $all_data = json_decode($buffer,true);
873
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
874
+		if ($buffer != '') {
875
+			$all_data = json_decode($buffer,true);
876 876
 		if (isset($all_data['acList'])) {
877
-		    $reset = 0;
878
-		    foreach ($all_data['acList'] as $line) {
877
+			$reset = 0;
878
+			foreach ($all_data['acList'] as $line) {
879 879
 			$data = array();
880 880
 			$data['hex'] = $line['Icao']; // hex
881 881
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -898,10 +898,10 @@  discard block
 block discarded – undo
898 898
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
899 899
 			if (isset($data['latitude'])) $SI->add($data);
900 900
 			unset($data);
901
-		    }
901
+			}
902 902
 		} elseif (is_array($all_data)) {
903
-		    $reset = 0;
904
-		    foreach ($all_data as $line) {
903
+			$reset = 0;
904
+			foreach ($all_data as $line) {
905 905
 			$data = array();
906 906
 			$data['hex'] = $line['hex']; // hex
907 907
 			$data['ident'] = $line['flight']; // ident
@@ -921,218 +921,218 @@  discard block
 block discarded – undo
921 921
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
922 922
 			$SI->add($data);
923 923
 			unset($data);
924
-		    }
924
+			}
925 925
 		}
926
-	    } elseif ($globalDebug) echo 'No data'."\n";
927
-    	    //$last_exec['aircraftlistjson'] = time();
928
-    	    $last_exec[$id]['last'] = time();
929
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
930
-    	} elseif ($value['format'] == 'planeupdatefaa' && 
931
-    	    (
932
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
933
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
934
-    	    )
935
-    	) {
936
-	    $buffer = $Common->getData($value['host']);
937
-	    $all_data = json_decode($buffer,true);
938
-	    if (isset($all_data['planes'])) {
926
+		} elseif ($globalDebug) echo 'No data'."\n";
927
+			//$last_exec['aircraftlistjson'] = time();
928
+			$last_exec[$id]['last'] = time();
929
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
930
+		} elseif ($value['format'] == 'planeupdatefaa' && 
931
+			(
932
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
933
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
934
+			)
935
+		) {
936
+		$buffer = $Common->getData($value['host']);
937
+		$all_data = json_decode($buffer,true);
938
+		if (isset($all_data['planes'])) {
939 939
 		$reset = 0;
940 940
 		foreach ($all_data['planes'] as $key => $line) {
941
-		    $data = array();
942
-		    $data['hex'] = $key; // hex
943
-		    $data['ident'] = $line[3]; // ident
944
-		    $data['altitude'] = $line[6]; // altitude
945
-		    $data['speed'] = $line[8]; // speed
946
-		    $data['heading'] = $line[7]; // heading
947
-		    $data['latitude'] = $line[4]; // lat
948
-		    $data['longitude'] = $line[5]; // long
949
-		    //$data['verticalrate'] = $line[]; // verticale rate
950
-		    $data['squawk'] = $line[10]; // squawk
951
-		    $data['emergency'] = ''; // emergency
952
-		    $data['registration'] = $line[2];
953
-		    $data['aircraft_icao'] = $line[0];
954
-		    $deparr = explode('-',$line[1]);
955
-		    if (count($deparr) == 2) {
941
+			$data = array();
942
+			$data['hex'] = $key; // hex
943
+			$data['ident'] = $line[3]; // ident
944
+			$data['altitude'] = $line[6]; // altitude
945
+			$data['speed'] = $line[8]; // speed
946
+			$data['heading'] = $line[7]; // heading
947
+			$data['latitude'] = $line[4]; // lat
948
+			$data['longitude'] = $line[5]; // long
949
+			//$data['verticalrate'] = $line[]; // verticale rate
950
+			$data['squawk'] = $line[10]; // squawk
951
+			$data['emergency'] = ''; // emergency
952
+			$data['registration'] = $line[2];
953
+			$data['aircraft_icao'] = $line[0];
954
+			$deparr = explode('-',$line[1]);
955
+			if (count($deparr) == 2) {
956 956
 			$data['departure_airport_icao'] = $deparr[0];
957 957
 			$data['arrival_airport_icao'] = $deparr[1];
958
-		    }
959
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
960
-	    	    $data['format_source'] = 'planeupdatefaa';
961
-    		    $data['id_source'] = $id_source;
962
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
963
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
964
-		    $SI->add($data);
965
-		    unset($data);
958
+			}
959
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
960
+				$data['format_source'] = 'planeupdatefaa';
961
+				$data['id_source'] = $id_source;
962
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
963
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
964
+			$SI->add($data);
965
+			unset($data);
966
+		}
966 967
 		}
967
-	    }
968
-	    //$last_exec['planeupdatefaa'] = time();
969
-	    $last_exec[$id]['last'] = time();
968
+		//$last_exec['planeupdatefaa'] = time();
969
+		$last_exec[$id]['last'] = time();
970 970
 	} elseif ($value['format'] == 'opensky' && 
971
-	    (
971
+		(
972 972
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
973 973
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
974
-	    )
974
+		)
975 975
 	) {
976
-	    $buffer = $Common->getData($value['host']);
977
-	    $all_data = json_decode($buffer,true);
978
-	    if (isset($all_data['states'])) {
976
+		$buffer = $Common->getData($value['host']);
977
+		$all_data = json_decode($buffer,true);
978
+		if (isset($all_data['states'])) {
979 979
 		$reset = 0;
980 980
 		foreach ($all_data['states'] as $key => $line) {
981
-		    $data = array();
982
-		    $data['hex'] = $line[0]; // hex
983
-		    $data['ident'] = trim($line[1]); // ident
984
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
985
-		    $data['speed'] = round($line[9]*1.94384); // speed
986
-		    $data['heading'] = round($line[10]); // heading
987
-		    $data['latitude'] = $line[6]; // lat
988
-		    $data['longitude'] = $line[5]; // long
989
-		    $data['verticalrate'] = $line[11]; // verticale rate
990
-		    //$data['squawk'] = $line[10]; // squawk
991
-		    //$data['emergency'] = ''; // emergency
992
-		    //$data['registration'] = $line[2];
993
-		    //$data['aircraft_icao'] = $line[0];
994
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
995
-		    $data['format_source'] = 'opensky';
996
-		    $data['id_source'] = $id_source;
997
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
998
-		    $SI->add($data);
999
-		    unset($data);
981
+			$data = array();
982
+			$data['hex'] = $line[0]; // hex
983
+			$data['ident'] = trim($line[1]); // ident
984
+			$data['altitude'] = round($line[7]*3.28084); // altitude
985
+			$data['speed'] = round($line[9]*1.94384); // speed
986
+			$data['heading'] = round($line[10]); // heading
987
+			$data['latitude'] = $line[6]; // lat
988
+			$data['longitude'] = $line[5]; // long
989
+			$data['verticalrate'] = $line[11]; // verticale rate
990
+			//$data['squawk'] = $line[10]; // squawk
991
+			//$data['emergency'] = ''; // emergency
992
+			//$data['registration'] = $line[2];
993
+			//$data['aircraft_icao'] = $line[0];
994
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
995
+			$data['format_source'] = 'opensky';
996
+			$data['id_source'] = $id_source;
997
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
998
+			$SI->add($data);
999
+			unset($data);
1000
+		}
1000 1001
 		}
1001
-	    }
1002
-	    //$last_exec['planeupdatefaa'] = time();
1003
-	    $last_exec[$id]['last'] = time();
1002
+		//$last_exec['planeupdatefaa'] = time();
1003
+		$last_exec[$id]['last'] = time();
1004 1004
 	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1005 1005
 	} elseif ($value['format'] == 'fr24json' && 
1006
-	    (
1006
+		(
1007 1007
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1008 1008
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1009
-	    )
1009
+		)
1010 1010
 	) {
1011
-	    //$buffer = $Common->getData($hosts[$id]);
1012
-	    $buffer = $Common->getData($value['host']);
1013
-	    $all_data = json_decode($buffer,true);
1014
-	    if (!empty($all_data)) $reset = 0;
1015
-	    foreach ($all_data as $key => $line) {
1011
+		//$buffer = $Common->getData($hosts[$id]);
1012
+		$buffer = $Common->getData($value['host']);
1013
+		$all_data = json_decode($buffer,true);
1014
+		if (!empty($all_data)) $reset = 0;
1015
+		foreach ($all_data as $key => $line) {
1016 1016
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1017
-		    $data = array();
1018
-		    $data['hex'] = $line[0];
1019
-		    $data['ident'] = $line[16]; //$line[13]
1020
-	    	    $data['altitude'] = $line[4]; // altitude
1021
-	    	    $data['speed'] = $line[5]; // speed
1022
-	    	    $data['heading'] = $line[3]; // heading
1023
-	    	    $data['latitude'] = $line[1]; // lat
1024
-	    	    $data['longitude'] = $line[2]; // long
1025
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1026
-	    	    $data['squawk'] = $line[6]; // squawk
1027
-	    	    $data['aircraft_icao'] = $line[8];
1028
-	    	    $data['registration'] = $line[9];
1029
-		    $data['departure_airport_iata'] = $line[11];
1030
-		    $data['arrival_airport_iata'] = $line[12];
1031
-	    	    $data['emergency'] = ''; // emergency
1032
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1033
-	    	    $data['format_source'] = 'fr24json';
1034
-    		    $data['id_source'] = $id_source;
1035
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1036
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1037
-		    $SI->add($data);
1038
-		    unset($data);
1017
+			$data = array();
1018
+			$data['hex'] = $line[0];
1019
+			$data['ident'] = $line[16]; //$line[13]
1020
+				$data['altitude'] = $line[4]; // altitude
1021
+				$data['speed'] = $line[5]; // speed
1022
+				$data['heading'] = $line[3]; // heading
1023
+				$data['latitude'] = $line[1]; // lat
1024
+				$data['longitude'] = $line[2]; // long
1025
+				$data['verticalrate'] = $line[15]; // verticale rate
1026
+				$data['squawk'] = $line[6]; // squawk
1027
+				$data['aircraft_icao'] = $line[8];
1028
+				$data['registration'] = $line[9];
1029
+			$data['departure_airport_iata'] = $line[11];
1030
+			$data['arrival_airport_iata'] = $line[12];
1031
+				$data['emergency'] = ''; // emergency
1032
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1033
+				$data['format_source'] = 'fr24json';
1034
+				$data['id_source'] = $id_source;
1035
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1036
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1037
+			$SI->add($data);
1038
+			unset($data);
1039 1039
 		}
1040
-	    }
1041
-	    //$last_exec['fr24json'] = time();
1042
-	    $last_exec[$id]['last'] = time();
1040
+		}
1041
+		//$last_exec['fr24json'] = time();
1042
+		$last_exec[$id]['last'] = time();
1043 1043
 	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1044 1044
 	} elseif ($value['format'] == 'radarvirtueljson' && 
1045
-	    (
1045
+		(
1046 1046
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1047 1047
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1048
-	    )
1048
+		)
1049 1049
 	) {
1050
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1051
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1052
-	    //echo $buffer;
1053
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1054
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1055
-	    $all_data = json_decode($buffer,true);
1056
-	    if (json_last_error() != JSON_ERROR_NONE) {
1050
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1051
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1052
+		//echo $buffer;
1053
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1054
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1055
+		$all_data = json_decode($buffer,true);
1056
+		if (json_last_error() != JSON_ERROR_NONE) {
1057 1057
 		die(json_last_error_msg());
1058
-	    }
1059
-	    if (isset($all_data['mrkrs'])) {
1058
+		}
1059
+		if (isset($all_data['mrkrs'])) {
1060 1060
 		$reset = 0;
1061 1061
 		foreach ($all_data['mrkrs'] as $key => $line) {
1062
-		    if (isset($line['inf'])) {
1062
+			if (isset($line['inf'])) {
1063 1063
 			$data = array();
1064 1064
 			$data['hex'] = $line['inf']['ia'];
1065 1065
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1066
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1067
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1068
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1069
-	    		$data['latitude'] = $line['pt'][0]; // lat
1070
-	    		$data['longitude'] = $line['pt'][1]; // long
1071
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1072
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1073
-	    		//$data['aircraft_icao'] = $line[8];
1074
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1066
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1067
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1068
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1069
+				$data['latitude'] = $line['pt'][0]; // lat
1070
+				$data['longitude'] = $line['pt'][1]; // long
1071
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1072
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1073
+				//$data['aircraft_icao'] = $line[8];
1074
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1075 1075
 			//$data['departure_airport_iata'] = $line[11];
1076 1076
 			//$data['arrival_airport_iata'] = $line[12];
1077
-	    		//$data['emergency'] = ''; // emergency
1077
+				//$data['emergency'] = ''; // emergency
1078 1078
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1079
-	    		$data['format_source'] = 'radarvirtueljson';
1080
-    			$data['id_source'] = $id_source;
1079
+				$data['format_source'] = 'radarvirtueljson';
1080
+				$data['id_source'] = $id_source;
1081 1081
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1082 1082
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1083 1083
 			$SI->add($data);
1084 1084
 			unset($data);
1085
-		    }
1085
+			}
1086 1086
 		}
1087
-	    }
1088
-	    //$last_exec['radarvirtueljson'] = time();
1089
-	    $last_exec[$id]['last'] = time();
1087
+		}
1088
+		//$last_exec['radarvirtueljson'] = time();
1089
+		$last_exec[$id]['last'] = time();
1090 1090
 	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1091 1091
 	} elseif ($value['format'] == 'pirepsjson' && 
1092
-	    (
1092
+		(
1093 1093
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1094 1094
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1095
-	    )
1095
+		)
1096 1096
 	) {
1097
-	    //$buffer = $Common->getData($hosts[$id]);
1098
-	    $buffer = $Common->getData($value['host'].'?'.time());
1099
-	    $all_data = json_decode(utf8_encode($buffer),true);
1097
+		//$buffer = $Common->getData($hosts[$id]);
1098
+		$buffer = $Common->getData($value['host'].'?'.time());
1099
+		$all_data = json_decode(utf8_encode($buffer),true);
1100 1100
 	    
1101
-	    if (isset($all_data['pireps'])) {
1101
+		if (isset($all_data['pireps'])) {
1102 1102
 		$reset = 0;
1103
-	        foreach ($all_data['pireps'] as $line) {
1104
-		    $data = array();
1105
-		    $data['id'] = $line['id'];
1106
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1107
-		    $data['ident'] = $line['callsign']; // ident
1108
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1109
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1110
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1111
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1112
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1113
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1114
-		    $data['latitude'] = $line['lat']; // lat
1115
-		    $data['longitude'] = $line['lon']; // long
1116
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1117
-		    //$data['squawk'] = $line['squawk']; // squawk
1118
-		    //$data['emergency'] = ''; // emergency
1119
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1120
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1121
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1122
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1123
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1124
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1125
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1126
-		    else $data['info'] = '';
1127
-		    $data['format_source'] = 'pireps';
1128
-    		    $data['id_source'] = $id_source;
1129
-		    $data['datetime'] = date('Y-m-d H:i:s');
1130
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1131
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1132
-		    if ($line['icon'] == 'plane') {
1103
+			foreach ($all_data['pireps'] as $line) {
1104
+			$data = array();
1105
+			$data['id'] = $line['id'];
1106
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1107
+			$data['ident'] = $line['callsign']; // ident
1108
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1109
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1110
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1111
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1112
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1113
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1114
+			$data['latitude'] = $line['lat']; // lat
1115
+			$data['longitude'] = $line['lon']; // long
1116
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1117
+			//$data['squawk'] = $line['squawk']; // squawk
1118
+			//$data['emergency'] = ''; // emergency
1119
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1120
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1121
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1122
+			//$data['arrival_airport_time'] = $line['arrtime'];
1123
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1124
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1125
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1126
+			else $data['info'] = '';
1127
+			$data['format_source'] = 'pireps';
1128
+				$data['id_source'] = $id_source;
1129
+			$data['datetime'] = date('Y-m-d H:i:s');
1130
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1131
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1132
+			if ($line['icon'] == 'plane') {
1133 1133
 			$SI->add($data);
1134
-		    //    print_r($data);
1135
-    		    } elseif ($line['icon'] == 'ct') {
1134
+			//    print_r($data);
1135
+				} elseif ($line['icon'] == 'ct') {
1136 1136
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1137 1137
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1138 1138
 			$typec = substr($data['ident'],-3);
@@ -1147,209 +1147,209 @@  discard block
 block discarded – undo
1147 1147
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1148 1148
 			else $data['type'] = 'Observer';
1149 1149
 			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']);
1150
-		    }
1151
-		    unset($data);
1150
+			}
1151
+			unset($data);
1152
+		}
1152 1153
 		}
1153
-	    }
1154
-	    //$last_exec['pirepsjson'] = time();
1155
-	    $last_exec[$id]['last'] = time();
1154
+		//$last_exec['pirepsjson'] = time();
1155
+		$last_exec[$id]['last'] = time();
1156 1156
 	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1157 1157
 	} elseif ($value['format'] == 'phpvmacars' && 
1158
-	    (
1158
+		(
1159 1159
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1160 1160
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1161
-	    )
1161
+		)
1162 1162
 	) {
1163
-	    //$buffer = $Common->getData($hosts[$id]);
1164
-	    if ($globalDebug) echo 'Get Data...'."\n";
1165
-	    $buffer = $Common->getData($value['host']);
1166
-	    $all_data = json_decode($buffer,true);
1167
-	    if ($buffer != '' && is_array($all_data)) {
1163
+		//$buffer = $Common->getData($hosts[$id]);
1164
+		if ($globalDebug) echo 'Get Data...'."\n";
1165
+		$buffer = $Common->getData($value['host']);
1166
+		$all_data = json_decode($buffer,true);
1167
+		if ($buffer != '' && is_array($all_data)) {
1168 1168
 		$reset = 0;
1169 1169
 		foreach ($all_data as $line) {
1170
-	    	    $data = array();
1171
-	    	    //$data['id'] = $line['id']; // id not usable
1172
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1173
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1174
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1175
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1176
-	    	    $data['ident'] = $line['flightnum']; // ident
1177
-	    	    $data['altitude'] = $line['alt']; // altitude
1178
-	    	    $data['speed'] = $line['gs']; // speed
1179
-	    	    $data['heading'] = $line['heading']; // heading
1180
-	    	    $data['latitude'] = $line['lat']; // lat
1181
-	    	    $data['longitude'] = $line['lng']; // long
1182
-	    	    $data['verticalrate'] = ''; // verticale rate
1183
-	    	    $data['squawk'] = ''; // squawk
1184
-	    	    $data['emergency'] = ''; // emergency
1185
-	    	    //$data['datetime'] = $line['lastupdate'];
1186
-	    	    //$data['last_update'] = $line['lastupdate'];
1187
-	    	    if (isset($value['timezone'])) {
1188
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1189
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1190
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1191
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1192
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1193
-	    	    $data['departure_airport_time'] = $line['deptime'];
1194
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1195
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1196
-    		    if (isset($line['registration'])) {
1197
-    			$data['registration'] = $line['registration'];
1198
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1199
-    		    } else $data['registration'] = $line['aircraft'];
1200
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1201
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1202
-		    if (isset($line['aircraftname'])) {
1170
+				$data = array();
1171
+				//$data['id'] = $line['id']; // id not usable
1172
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1173
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1174
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1175
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1176
+				$data['ident'] = $line['flightnum']; // ident
1177
+				$data['altitude'] = $line['alt']; // altitude
1178
+				$data['speed'] = $line['gs']; // speed
1179
+				$data['heading'] = $line['heading']; // heading
1180
+				$data['latitude'] = $line['lat']; // lat
1181
+				$data['longitude'] = $line['lng']; // long
1182
+				$data['verticalrate'] = ''; // verticale rate
1183
+				$data['squawk'] = ''; // squawk
1184
+				$data['emergency'] = ''; // emergency
1185
+				//$data['datetime'] = $line['lastupdate'];
1186
+				//$data['last_update'] = $line['lastupdate'];
1187
+				if (isset($value['timezone'])) {
1188
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1189
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1190
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1191
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1192
+				$data['departure_airport_icao'] = $line['depicao'];
1193
+				$data['departure_airport_time'] = $line['deptime'];
1194
+				$data['arrival_airport_icao'] = $line['arricao'];
1195
+				$data['arrival_airport_time'] = $line['arrtime'];
1196
+				if (isset($line['registration'])) {
1197
+				$data['registration'] = $line['registration'];
1198
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1199
+				} else $data['registration'] = $line['aircraft'];
1200
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1201
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1202
+			if (isset($line['aircraftname'])) {
1203 1203
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1204 1204
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1205
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1206
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1207
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1208
-	    		else {
1209
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1210
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1211
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1212
-	    		}
1213
-	    	    }
1214
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1215
-    		    $data['id_source'] = $id_source;
1216
-	    	    $data['format_source'] = 'phpvmacars';
1217
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1218
-		    $SI->add($data);
1219
-		    unset($data);
1205
+				$aircraft_data = explode('-',$line['aircraftname']);
1206
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1207
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1208
+				else {
1209
+					$aircraft_data = explode(' ',$line['aircraftname']);
1210
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1211
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1212
+				}
1213
+				}
1214
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1215
+				$data['id_source'] = $id_source;
1216
+				$data['format_source'] = 'phpvmacars';
1217
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1218
+			$SI->add($data);
1219
+			unset($data);
1220 1220
 		}
1221 1221
 		if ($globalDebug) echo 'No more data...'."\n";
1222 1222
 		unset($buffer);
1223 1223
 		unset($all_data);
1224
-	    }
1225
-	    //$last_exec['phpvmacars'] = time();
1226
-	    $last_exec[$id]['last'] = time();
1224
+		}
1225
+		//$last_exec['phpvmacars'] = time();
1226
+		$last_exec[$id]['last'] = time();
1227 1227
 	} elseif ($value['format'] == 'vaos' && 
1228
-	    (
1228
+		(
1229 1229
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1230 1230
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1231
-	    )
1231
+		)
1232 1232
 	) {
1233
-	    //$buffer = $Common->getData($hosts[$id]);
1234
-	    if ($globalDebug) echo 'Get Data...'."\n";
1235
-	    $buffer = $Common->getData($value['host']);
1236
-	    $all_data = json_decode($buffer,true);
1237
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1233
+		//$buffer = $Common->getData($hosts[$id]);
1234
+		if ($globalDebug) echo 'Get Data...'."\n";
1235
+		$buffer = $Common->getData($value['host']);
1236
+		$all_data = json_decode($buffer,true);
1237
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1238 1238
 		$reset = 0;
1239 1239
 		foreach ($all_data['ACARSData'] as $line) {
1240
-		    //print_r($line);
1241
-	    	    $data = array();
1242
-	    	    //$data['id'] = $line['id']; // id not usable
1243
-	    	    $data['id'] = $line['id'];
1244
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1245
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1246
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1247
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1248
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1249
-	    	    $data['altitude'] = $line['altitude']; // altitude
1250
-	    	    $data['speed'] = $line['groundspeed']; // speed
1251
-	    	    $data['heading'] = $line['heading']; // heading
1252
-	    	    $data['latitude'] = $line['lat']; // lat
1253
-	    	    $data['longitude'] = $line['lon']; // long
1254
-	    	    //$data['verticalrate'] = ''; // verticale rate
1255
-	    	    //$data['squawk'] = ''; // squawk
1256
-	    	    //$data['emergency'] = ''; // emergency
1257
-	    	    if (isset($value['timezone'])) {
1258
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1259
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1260
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1261
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1240
+			//print_r($line);
1241
+				$data = array();
1242
+				//$data['id'] = $line['id']; // id not usable
1243
+				$data['id'] = $line['id'];
1244
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1245
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1246
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1247
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1248
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1249
+				$data['altitude'] = $line['altitude']; // altitude
1250
+				$data['speed'] = $line['groundspeed']; // speed
1251
+				$data['heading'] = $line['heading']; // heading
1252
+				$data['latitude'] = $line['lat']; // lat
1253
+				$data['longitude'] = $line['lon']; // long
1254
+				//$data['verticalrate'] = ''; // verticale rate
1255
+				//$data['squawk'] = ''; // squawk
1256
+				//$data['emergency'] = ''; // emergency
1257
+				if (isset($value['timezone'])) {
1258
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1259
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1260
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1261
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1262 1262
 	    	    
1263
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1264
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1265
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1266
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1267
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1263
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1264
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1265
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1266
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1267
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1268 1268
 
1269
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1270
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1271
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1269
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1270
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1271
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1272 1272
 
1273
-    		    $data['id_source'] = $id_source;
1274
-	    	    $data['format_source'] = 'vaos';
1275
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1276
-		    $SI->add($data);
1277
-		    unset($data);
1273
+				$data['id_source'] = $id_source;
1274
+				$data['format_source'] = 'vaos';
1275
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1276
+			$SI->add($data);
1277
+			unset($data);
1278 1278
 		}
1279 1279
 		if ($globalDebug) echo 'No more data...'."\n";
1280 1280
 		unset($buffer);
1281 1281
 		unset($all_data);
1282
-	    }
1283
-	    //$last_exec['phpvmacars'] = time();
1284
-	    $last_exec[$id]['last'] = time();
1282
+		}
1283
+		//$last_exec['phpvmacars'] = time();
1284
+		$last_exec[$id]['last'] = time();
1285 1285
 	} elseif ($value['format'] == 'vam' && 
1286
-	    (
1286
+		(
1287 1287
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1288 1288
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1289
-	    )
1289
+		)
1290 1290
 	) {
1291
-	    //$buffer = $Common->getData($hosts[$id]);
1292
-	    if ($globalDebug) echo 'Get Data...'."\n";
1293
-	    $buffer = $Common->getData($value['host']);
1294
-	    $all_data = json_decode($buffer,true);
1295
-	    if ($buffer != '' && is_array($all_data)) {
1291
+		//$buffer = $Common->getData($hosts[$id]);
1292
+		if ($globalDebug) echo 'Get Data...'."\n";
1293
+		$buffer = $Common->getData($value['host']);
1294
+		$all_data = json_decode($buffer,true);
1295
+		if ($buffer != '' && is_array($all_data)) {
1296 1296
 		$reset = 0;
1297 1297
 		foreach ($all_data as $line) {
1298
-	    	    $data = array();
1299
-	    	    //$data['id'] = $line['id']; // id not usable
1300
-	    	    $data['id'] = trim($line['flight_id']);
1301
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1302
-	    	    $data['pilot_name'] = $line['pilot_name'];
1303
-	    	    $data['pilot_id'] = $line['pilot_id'];
1304
-	    	    $data['ident'] = trim($line['callsign']); // ident
1305
-	    	    $data['altitude'] = $line['altitude']; // altitude
1306
-	    	    $data['speed'] = $line['gs']; // speed
1307
-	    	    $data['heading'] = $line['heading']; // heading
1308
-	    	    $data['latitude'] = $line['latitude']; // lat
1309
-	    	    $data['longitude'] = $line['longitude']; // long
1310
-	    	    $data['verticalrate'] = ''; // verticale rate
1311
-	    	    $data['squawk'] = ''; // squawk
1312
-	    	    $data['emergency'] = ''; // emergency
1313
-	    	    //$data['datetime'] = $line['lastupdate'];
1314
-	    	    $data['last_update'] = $line['last_update'];
1315
-		    $data['datetime'] = date('Y-m-d H:i:s');
1316
-	    	    $data['departure_airport_icao'] = $line['departure'];
1317
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1318
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1319
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1320
-    		    //$data['registration'] = $line['aircraft'];
1321
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1322
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1323
-    		    $data['id_source'] = $id_source;
1324
-	    	    $data['format_source'] = 'vam';
1325
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1326
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1327
-		    $SI->add($data);
1328
-		    unset($data);
1298
+				$data = array();
1299
+				//$data['id'] = $line['id']; // id not usable
1300
+				$data['id'] = trim($line['flight_id']);
1301
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1302
+				$data['pilot_name'] = $line['pilot_name'];
1303
+				$data['pilot_id'] = $line['pilot_id'];
1304
+				$data['ident'] = trim($line['callsign']); // ident
1305
+				$data['altitude'] = $line['altitude']; // altitude
1306
+				$data['speed'] = $line['gs']; // speed
1307
+				$data['heading'] = $line['heading']; // heading
1308
+				$data['latitude'] = $line['latitude']; // lat
1309
+				$data['longitude'] = $line['longitude']; // long
1310
+				$data['verticalrate'] = ''; // verticale rate
1311
+				$data['squawk'] = ''; // squawk
1312
+				$data['emergency'] = ''; // emergency
1313
+				//$data['datetime'] = $line['lastupdate'];
1314
+				$data['last_update'] = $line['last_update'];
1315
+			$data['datetime'] = date('Y-m-d H:i:s');
1316
+				$data['departure_airport_icao'] = $line['departure'];
1317
+				//$data['departure_airport_time'] = $line['departure_time'];
1318
+				$data['arrival_airport_icao'] = $line['arrival'];
1319
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1320
+				//$data['registration'] = $line['aircraft'];
1321
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1322
+				$data['aircraft_icao'] = $line['plane_type'];
1323
+				$data['id_source'] = $id_source;
1324
+				$data['format_source'] = 'vam';
1325
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1326
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1327
+			$SI->add($data);
1328
+			unset($data);
1329 1329
 		}
1330 1330
 		if ($globalDebug) echo 'No more data...'."\n";
1331 1331
 		unset($buffer);
1332 1332
 		unset($all_data);
1333
-	    }
1334
-	    //$last_exec['phpvmacars'] = time();
1335
-	    $last_exec[$id]['last'] = time();
1333
+		}
1334
+		//$last_exec['phpvmacars'] = time();
1335
+		$last_exec[$id]['last'] = time();
1336 1336
 	} elseif ($value['format'] == 'blitzortung' && 
1337
-	    (
1337
+		(
1338 1338
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1339 1339
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1340
-	    )
1340
+		)
1341 1341
 	) {
1342
-	    //$buffer = $Common->getData($hosts[$id]);
1343
-	    if ($globalDebug) echo 'Get Data...'."\n";
1344
-	    $buffer = $Common->getData($value['host']);
1345
-	    $all_data = json_decode($buffer,true);
1346
-	    if ($buffer != '') {
1342
+		//$buffer = $Common->getData($hosts[$id]);
1343
+		if ($globalDebug) echo 'Get Data...'."\n";
1344
+		$buffer = $Common->getData($value['host']);
1345
+		$all_data = json_decode($buffer,true);
1346
+		if ($buffer != '') {
1347 1347
 		$Source->deleteLocationBySource('blitzortung');
1348 1348
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1349 1349
 		$buffer = explode('\n',$buffer);
1350 1350
 		foreach ($buffer as $buffer_line) {
1351
-		    $line = json_decode($buffer_line,true);
1352
-		    if (isset($line['time'])) {
1351
+			$line = json_decode($buffer_line,true);
1352
+			if (isset($line['time'])) {
1353 1353
 			$data = array();
1354 1354
 			$data['altitude'] = $line['alt']; // altitude
1355 1355
 			$data['latitude'] = $line['lat']; // lat
@@ -1361,96 +1361,96 @@  discard block
 block discarded – undo
1361 1361
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1362 1362
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1363 1363
 			unset($data);
1364
-		    }
1364
+			}
1365 1365
 		}
1366 1366
 		if ($globalDebug) echo 'No more data...'."\n";
1367 1367
 		unset($buffer);
1368
-	    }
1369
-	    $last_exec[$id]['last'] = time();
1368
+		}
1369
+		$last_exec[$id]['last'] = time();
1370 1370
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1371 1371
 	} 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') {
1372
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1373
-    	    //$last_exec[$id]['last'] = time();
1372
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1373
+			//$last_exec[$id]['last'] = time();
1374 1374
 
1375
-	    //$read = array( $sockets[$id] );
1376
-	    $read = $sockets;
1377
-	    $write = NULL;
1378
-	    $e = NULL;
1379
-	    $n = socket_select($read, $write, $e, $timeout);
1380
-	    if ($e != NULL) var_dump($e);
1381
-	    if ($n > 0) {
1375
+		//$read = array( $sockets[$id] );
1376
+		$read = $sockets;
1377
+		$write = NULL;
1378
+		$e = NULL;
1379
+		$n = socket_select($read, $write, $e, $timeout);
1380
+		if ($e != NULL) var_dump($e);
1381
+		if ($n > 0) {
1382 1382
 		$reset = 0;
1383 1383
 		foreach ($read as $nb => $r) {
1384
-		    //$value = $formats[$nb];
1385
-		    $format = $globalSources[$nb]['format'];
1386
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1384
+			//$value = $formats[$nb];
1385
+			$format = $globalSources[$nb]['format'];
1386
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1387 1387
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1388
-		    } elseif ($format == 'vrstcp') {
1388
+			} elseif ($format == 'vrstcp') {
1389 1389
 			$buffer = @socket_read($r, 6000);
1390
-		    } else {
1390
+			} else {
1391 1391
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1392
-		    }
1393
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1394
-		    //echo $buffer."\n";
1395
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1396
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1397
-		    $error = false;
1398
-		    //$SI::del();
1399
-		    if ($buffer !== FALSE) {
1392
+			}
1393
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1394
+			//echo $buffer."\n";
1395
+			// lets play nice and handle signals such as ctrl-c/kill properly
1396
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1397
+			$error = false;
1398
+			//$SI::del();
1399
+			if ($buffer !== FALSE) {
1400 1400
 			if ($format == 'vrstcp') {
1401
-			    $buffer = explode('},{',$buffer);
1401
+				$buffer = explode('},{',$buffer);
1402 1402
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1403
-		    }
1404
-		    // SBS format is CSV format
1405
-		    if ($buffer !== FALSE && $buffer !== '') {
1403
+			}
1404
+			// SBS format is CSV format
1405
+			if ($buffer !== FALSE && $buffer !== '') {
1406 1406
 			$tt[$format] = 0;
1407 1407
 			if ($format == 'acarssbs3') {
1408
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1409
-			    $ACARS->add(trim($buffer));
1410
-			    $ACARS->deleteLiveAcarsData();
1408
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1409
+				$ACARS->add(trim($buffer));
1410
+				$ACARS->deleteLiveAcarsData();
1411 1411
 			} elseif ($format == 'raw') {
1412
-			    // AVR format
1413
-			    $data = $SBS->parse($buffer);
1414
-			    if (is_array($data)) {
1412
+				// AVR format
1413
+				$data = $SBS->parse($buffer);
1414
+				if (is_array($data)) {
1415 1415
 				$data['datetime'] = date('Y-m-d H:i:s');
1416 1416
 				$data['format_source'] = 'raw';
1417 1417
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1418 1418
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1419 1419
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1420 1420
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1421
-			    }
1421
+				}
1422 1422
 			} elseif ($format == 'ais') {
1423
-			    $ais_data = $AIS->parse_line(trim($buffer));
1424
-			    $data = array();
1425
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1426
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1427
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1428
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1429
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1430
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1431
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1432
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1433
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1434
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1435
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1436
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1437
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1438
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1439
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1440
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1423
+				$ais_data = $AIS->parse_line(trim($buffer));
1424
+				$data = array();
1425
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1426
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1427
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1428
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1429
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1430
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1431
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1432
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1433
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1434
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1435
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1436
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1437
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1438
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1439
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1440
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1441 1441
 
1442
-			    if (isset($ais_data['timestamp'])) {
1442
+				if (isset($ais_data['timestamp'])) {
1443 1443
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1444
-			    } else {
1444
+				} else {
1445 1445
 				$data['datetime'] = date('Y-m-d H:i:s');
1446
-			    }
1447
-			    $data['format_source'] = 'aisnmea';
1448
-    			    $data['id_source'] = $id_source;
1449
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1450
-			    unset($data);
1451
-                        } elseif ($format == 'flightgearsp') {
1452
-                    	    //echo $buffer."\n";
1453
-                    	    if (strlen($buffer) > 5) {
1446
+				}
1447
+				$data['format_source'] = 'aisnmea';
1448
+					$data['id_source'] = $id_source;
1449
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1450
+				unset($data);
1451
+						} elseif ($format == 'flightgearsp') {
1452
+							//echo $buffer."\n";
1453
+							if (strlen($buffer) > 5) {
1454 1454
 				$line = explode(',',$buffer);
1455 1455
 				$data = array();
1456 1456
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1467,38 +1467,38 @@  discard block
 block discarded – undo
1467 1467
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1468 1468
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1469 1469
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1470
-			    }
1471
-                        } elseif ($format == 'acars') {
1472
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1473
-			    $ACARS->add(trim($buffer));
1474
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1475
-			    $ACARS->deleteLiveAcarsData();
1470
+				}
1471
+						} elseif ($format == 'acars') {
1472
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1473
+				$ACARS->add(trim($buffer));
1474
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1475
+				$ACARS->deleteLiveAcarsData();
1476 1476
 			} elseif ($format == 'flightgearmp') {
1477
-			    if (substr($buffer,0,1) != '#') {
1477
+				if (substr($buffer,0,1) != '#') {
1478 1478
 				$data = array();
1479 1479
 				//echo $buffer."\n";
1480 1480
 				$line = explode(' ',$buffer);
1481 1481
 				if (count($line) == 11) {
1482
-				    $userserver = explode('@',$line[0]);
1483
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1484
-				    $data['ident'] = $userserver[0];
1485
-				    $data['registration'] = $userserver[0];
1486
-				    $data['latitude'] = $line[4];
1487
-				    $data['longitude'] = $line[5];
1488
-				    $data['altitude'] = $line[6];
1489
-				    $data['datetime'] = date('Y-m-d H:i:s');
1490
-				    $aircraft_type = $line[10];
1491
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1492
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1493
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1494
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1482
+					$userserver = explode('@',$line[0]);
1483
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1484
+					$data['ident'] = $userserver[0];
1485
+					$data['registration'] = $userserver[0];
1486
+					$data['latitude'] = $line[4];
1487
+					$data['longitude'] = $line[5];
1488
+					$data['altitude'] = $line[6];
1489
+					$data['datetime'] = date('Y-m-d H:i:s');
1490
+					$aircraft_type = $line[10];
1491
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1492
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1493
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1494
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1495
+				}
1495 1496
 				}
1496
-			    }
1497 1497
 			} elseif ($format == 'beast') {
1498
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1499
-			    die;
1498
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1499
+				die;
1500 1500
 			} elseif ($format == 'vrstcp') {
1501
-			    foreach($buffer as $all_data) {
1501
+				foreach($buffer as $all_data) {
1502 1502
 				$line = json_decode('{'.$all_data.'}',true);
1503 1503
 				$data = array();
1504 1504
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1518,153 +1518,153 @@  discard block
 block discarded – undo
1518 1518
 				*/
1519 1519
 				$data['datetime'] = date('Y-m-d H:i:s');
1520 1520
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1521
-		    		$data['format_source'] = 'vrstcp';
1521
+					$data['format_source'] = 'vrstcp';
1522 1522
 				$data['id_source'] = $id_source;
1523 1523
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1524 1524
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1525 1525
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1526 1526
 				unset($data);
1527
-			    }
1527
+				}
1528 1528
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1529
-			    $line = explode("\t", $buffer);
1530
-			    for($k = 0; $k < count($line); $k=$k+2) {
1529
+				$line = explode("\t", $buffer);
1530
+				for($k = 0; $k < count($line); $k=$k+2) {
1531 1531
 				$key = $line[$k];
1532
-			        $lined[$key] = $line[$k+1];
1533
-			    }
1534
-    			    if (count($lined) > 3) {
1535
-    				$data['hex'] = $lined['hexid'];
1536
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1537
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1538
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1539
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1540
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1541
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1542
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1543
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1544
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1545
-    				$data['id_source'] = $id_source;
1546
-    				$data['format_source'] = 'tsv';
1547
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1548
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1532
+					$lined[$key] = $line[$k+1];
1533
+				}
1534
+					if (count($lined) > 3) {
1535
+					$data['hex'] = $lined['hexid'];
1536
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1537
+					$data['datetime'] = date('Y-m-d H:i:s');;
1538
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1539
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1540
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1541
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1542
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1543
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1544
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1545
+					$data['id_source'] = $id_source;
1546
+					$data['format_source'] = 'tsv';
1547
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1548
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1549 1549
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1550
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1551
-    				unset($lined);
1552
-    				unset($data);
1553
-    			    } else $error = true;
1550
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1551
+					unset($lined);
1552
+					unset($data);
1553
+					} else $error = true;
1554 1554
 			} elseif ($format == 'aprs' && $use_aprs) {
1555
-			    if ($aprs_connect == 0) {
1555
+				if ($aprs_connect == 0) {
1556 1556
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1557 1557
 				$aprs_connect = 1;
1558
-			    }
1558
+				}
1559 1559
 			    
1560
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1560
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1561 1561
 				$aprs_last_tx = time();
1562 1562
 				$data_aprs = "# Keep alive";
1563 1563
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1564
-			    }
1564
+				}
1565 1565
 			    
1566
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1567
-			    //echo 'APRS data : '.$buffer."\n";
1568
-			    $buffer = str_replace('APRS <- ','',$buffer);
1569
-			    $buffer = str_replace('APRS -> ','',$buffer);
1570
-			    //echo $buffer."\n";
1571
-			    date_default_timezone_set('UTC');
1572
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1566
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1567
+				//echo 'APRS data : '.$buffer."\n";
1568
+				$buffer = str_replace('APRS <- ','',$buffer);
1569
+				$buffer = str_replace('APRS -> ','',$buffer);
1570
+				//echo $buffer."\n";
1571
+				date_default_timezone_set('UTC');
1572
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1573 1573
 				$line = $APRS->parse($buffer);
1574 1574
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1575 1575
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1576
-				    $aprs_last_tx = time();
1577
-				    $data = array();
1578
-				    //print_r($line);
1579
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1580
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1581
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1582
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1583
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1584
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1585
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1586
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1587
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1588
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1589
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1590
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1591
-				    $data['latitude'] = $line['latitude'];
1592
-				    $data['longitude'] = $line['longitude'];
1593
-				    //$data['verticalrate'] = $line[16];
1594
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1595
-				    //else $data['speed'] = 0;
1596
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1597
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1598
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1599
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1576
+					$aprs_last_tx = time();
1577
+					$data = array();
1578
+					//print_r($line);
1579
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1580
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1581
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1582
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1583
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1584
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1585
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1586
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1587
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1588
+					else $data['datetime'] = date('Y-m-d H:i:s');
1589
+					//$data['datetime'] = date('Y-m-d H:i:s');
1590
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1591
+					$data['latitude'] = $line['latitude'];
1592
+					$data['longitude'] = $line['longitude'];
1593
+					//$data['verticalrate'] = $line[16];
1594
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1595
+					//else $data['speed'] = 0;
1596
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1597
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1598
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1599
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1600 1600
 				    
1601
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1602
-				    //else echo 'No heading...'."\n";
1603
-				    //else $data['heading'] = 0;
1604
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1605
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1606
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1607
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1608
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1609
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1610
-    				    $data['id_source'] = $id_source;
1611
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1612
-				    else $data['format_source'] = 'aprs';
1613
-				    $data['source_name'] = $line['source'];
1614
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1615
-				    else $data['source_type'] = 'flarm';
1616
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1617
-				    $currentdate = date('Y-m-d H:i:s');
1618
-				    $aprsdate = strtotime($data['datetime']);
1619
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1620
-				    // Accept data if time <= system time + 20s
1621
-				    //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'])))) {
1622
-				    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'])))) {
1601
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1602
+					//else echo 'No heading...'."\n";
1603
+					//else $data['heading'] = 0;
1604
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1605
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1606
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1607
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1608
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1609
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1610
+						$data['id_source'] = $id_source;
1611
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1612
+					else $data['format_source'] = 'aprs';
1613
+					$data['source_name'] = $line['source'];
1614
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1615
+					else $data['source_type'] = 'flarm';
1616
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1617
+					$currentdate = date('Y-m-d H:i:s');
1618
+					$aprsdate = strtotime($data['datetime']);
1619
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1620
+					// Accept data if time <= system time + 20s
1621
+					//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'])))) {
1622
+					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'])))) {
1623 1623
 					$send = $SI->add($data);
1624
-				    } elseif ($data['source_type'] == 'ais') {
1624
+					} elseif ($data['source_type'] == 'ais') {
1625 1625
 					$data['type'] = '';
1626 1626
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1627
-				    } elseif (isset($line['stealth'])) {
1627
+					} elseif (isset($line['stealth'])) {
1628 1628
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1629 1629
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1630
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1631
-					    //$line['symbol'] == 'Balloon' ||
1632
-					    $line['symbol'] == 'Glider' || 
1633
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1634
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1635
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1636
-					    $send = $SI->add($data);
1637
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1638
-					    $line['symbol'] == 'Yacht (Sail)' || 
1639
-					    $line['symbol'] == 'Ship (Power Boat)')) {
1640
-					    $send = $MI->add($data);
1641
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1642
-					    $line['symbol'] == 'Car' || 
1643
-					    $line['symbol'] == 'Ambulance' || 
1644
-					    $line['symbol'] == 'Van' || 
1645
-					    $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1646
-					    $line['symbol'] == 'Motorcycle' || 
1647
-					    $line['symbol'] == 'Tractor' || 
1648
-					    $line['symbol'] == 'Police' || 
1649
-					    $line['symbol'] == 'Bike' || 
1650
-					    $line['symbol'] == 'Jogger' || 
1651
-					    $line['symbol'] == 'Horse' || 
1652
-					    $line['symbol'] == 'Bus' || 
1653
-					    $line['symbol'] == 'Jeep' || 
1654
-					    $line['symbol'] == 'Recreational Vehicle' || 
1655
-					    $line['symbol'] == 'Yacht (Sail)' || 
1656
-					    $line['symbol'] == 'Ship (Power Boat)' || 
1657
-					    $line['symbol'] == 'Firetruck' || 
1658
-					    $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1659
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1660
-					    $line['symbol'] == 'SUV' ||
1661
-					    $line['symbol'] == 'Snowmobile' ||
1662
-					    $line['symbol'] == 'Mobile Satellite Station')) {
1663
-				    //} 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') {
1630
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1631
+						//$line['symbol'] == 'Balloon' ||
1632
+						$line['symbol'] == 'Glider' || 
1633
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1634
+						if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1635
+						if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1636
+						$send = $SI->add($data);
1637
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1638
+						$line['symbol'] == 'Yacht (Sail)' || 
1639
+						$line['symbol'] == 'Ship (Power Boat)')) {
1640
+						$send = $MI->add($data);
1641
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1642
+						$line['symbol'] == 'Car' || 
1643
+						$line['symbol'] == 'Ambulance' || 
1644
+						$line['symbol'] == 'Van' || 
1645
+						$line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1646
+						$line['symbol'] == 'Motorcycle' || 
1647
+						$line['symbol'] == 'Tractor' || 
1648
+						$line['symbol'] == 'Police' || 
1649
+						$line['symbol'] == 'Bike' || 
1650
+						$line['symbol'] == 'Jogger' || 
1651
+						$line['symbol'] == 'Horse' || 
1652
+						$line['symbol'] == 'Bus' || 
1653
+						$line['symbol'] == 'Jeep' || 
1654
+						$line['symbol'] == 'Recreational Vehicle' || 
1655
+						$line['symbol'] == 'Yacht (Sail)' || 
1656
+						$line['symbol'] == 'Ship (Power Boat)' || 
1657
+						$line['symbol'] == 'Firetruck' || 
1658
+						$line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1659
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1660
+						$line['symbol'] == 'SUV' ||
1661
+						$line['symbol'] == 'Snowmobile' ||
1662
+						$line['symbol'] == 'Mobile Satellite Station')) {
1663
+					//} 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') {
1664 1664
 				//    } 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') {
1665 1665
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1666 1666
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1667
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1667
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1668 1668
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1669 1669
 					$Source->deleteOldLocationByType('gs');
1670 1670
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1672,7 +1672,7 @@  discard block
 block discarded – undo
1672 1672
 					} else {
1673 1673
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1674 1674
 					}
1675
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1675
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1676 1676
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1677 1677
 					if ($globalDebug) echo '# Weather Station added'."\n";
1678 1678
 					$Source->deleteOldLocationByType('wx');
@@ -1682,7 +1682,7 @@  discard block
 block discarded – undo
1682 1682
 					} else {
1683 1683
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1684 1684
 					}
1685
-				    } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1685
+					} elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1686 1686
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1687 1687
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1688 1688
 					$Source->deleteOldLocationByType('lightning');
@@ -1691,11 +1691,11 @@  discard block
 block discarded – undo
1691 1691
 					} else {
1692 1692
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1693 1693
 					}
1694
-				    } elseif ($globalDebug) {
1695
-				    	echo '/!\ Not added: '.$buffer."\n";
1696
-				    	print_r($line);
1697
-				    }
1698
-				    unset($data);
1694
+					} elseif ($globalDebug) {
1695
+						echo '/!\ Not added: '.$buffer."\n";
1696
+						print_r($line);
1697
+					}
1698
+					unset($data);
1699 1699
 				}
1700 1700
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1701 1701
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1714,12 +1714,12 @@  discard block
 block discarded – undo
1714 1714
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1715 1715
 					$globalSources[$nb]['last_weather_clean'] = time();
1716 1716
 				}
1717
-			    }
1717
+				}
1718 1718
 			} else {
1719
-			    $line = explode(',', $buffer);
1720
-    			    if (count($line) > 20) {
1721
-    			    	$data['hex'] = $line[4];
1722
-    				/*
1719
+				$line = explode(',', $buffer);
1720
+					if (count($line) > 20) {
1721
+						$data['hex'] = $line[4];
1722
+					/*
1723 1723
     				$data['datetime'] = $line[6].' '.$line[7];
1724 1724
     					date_default_timezone_set($globalTimezone);
1725 1725
     					$datetime = new DateTime($data['datetime']);
@@ -1727,30 +1727,30 @@  discard block
 block discarded – undo
1727 1727
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1728 1728
     					date_default_timezone_set('UTC');
1729 1729
     				*/
1730
-    				// Force datetime to current UTC datetime
1731
-    				date_default_timezone_set('UTC');
1732
-    				$data['datetime'] = date('Y-m-d H:i:s');
1733
-    				$data['ident'] = trim($line[10]);
1734
-    				$data['latitude'] = $line[14];
1735
-    				$data['longitude'] = $line[15];
1736
-    				$data['verticalrate'] = $line[16];
1737
-    				$data['emergency'] = $line[20];
1738
-    				$data['speed'] = $line[12];
1739
-    				$data['squawk'] = $line[17];
1740
-    				$data['altitude'] = $line[11];
1741
-    				$data['heading'] = $line[13];
1742
-    				$data['ground'] = $line[21];
1743
-    				$data['emergency'] = $line[19];
1744
-    				$data['format_source'] = 'sbs';
1730
+					// Force datetime to current UTC datetime
1731
+					date_default_timezone_set('UTC');
1732
+					$data['datetime'] = date('Y-m-d H:i:s');
1733
+					$data['ident'] = trim($line[10]);
1734
+					$data['latitude'] = $line[14];
1735
+					$data['longitude'] = $line[15];
1736
+					$data['verticalrate'] = $line[16];
1737
+					$data['emergency'] = $line[20];
1738
+					$data['speed'] = $line[12];
1739
+					$data['squawk'] = $line[17];
1740
+					$data['altitude'] = $line[11];
1741
+					$data['heading'] = $line[13];
1742
+					$data['ground'] = $line[21];
1743
+					$data['emergency'] = $line[19];
1744
+					$data['format_source'] = 'sbs';
1745 1745
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1746
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1746
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1747 1747
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1748
-    				$data['id_source'] = $id_source;
1749
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1750
-    				else $error = true;
1751
-    				unset($data);
1752
-    			    } else $error = true;
1753
-			    if ($error) {
1748
+					$data['id_source'] = $id_source;
1749
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1750
+					else $error = true;
1751
+					unset($data);
1752
+					} else $error = true;
1753
+				if ($error) {
1754 1754
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1755 1755
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1756 1756
 				} else {
@@ -1766,13 +1766,13 @@  discard block
 block discarded – undo
1766 1766
 					connect_all($sourceer);
1767 1767
 					$sourceer = array();
1768 1768
 				}
1769
-			    }
1769
+				}
1770 1770
 			}
1771 1771
 			// Sleep for xxx microseconds
1772 1772
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1773
-		    } else {
1773
+			} else {
1774 1774
 			if ($format == 'flightgearmp') {
1775
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1775
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1776 1776
 				//@socket_close($r);
1777 1777
 				sleep($globalMinFetch);
1778 1778
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1781,9 +1781,9 @@  discard block
 block discarded – undo
1781 1781
 				break;
1782 1782
 				
1783 1783
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1784
-			    if (isset($tt[$format])) $tt[$format]++;
1785
-			    else $tt[$format] = 0;
1786
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
1784
+				if (isset($tt[$format])) $tt[$format]++;
1785
+				else $tt[$format] = 0;
1786
+				if ($tt[$format] > 30 || $buffer === FALSE) {
1787 1787
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1788 1788
 				//@socket_close($r);
1789 1789
 				sleep(2);
@@ -1794,24 +1794,24 @@  discard block
 block discarded – undo
1794 1794
 				//connect_all($globalSources);
1795 1795
 				$tt[$format]=0;
1796 1796
 				break;
1797
-			    } 
1798
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1797
+				} 
1798
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1799
+			}
1799 1800
 			}
1800
-		    }
1801 1801
 		}
1802
-	    } else {
1802
+		} else {
1803 1803
 		$error = socket_strerror(socket_last_error());
1804 1804
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1805 1805
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1806 1806
 			if (isset($globalDebug)) echo "Restarting...\n";
1807 1807
 			// Restart the script if possible
1808 1808
 			if (is_array($sockets)) {
1809
-			    if ($globalDebug) echo "Shutdown all sockets...";
1809
+				if ($globalDebug) echo "Shutdown all sockets...";
1810 1810
 			    
1811
-			    foreach ($sockets as $sock) {
1811
+				foreach ($sockets as $sock) {
1812 1812
 				@socket_shutdown($sock,2);
1813 1813
 				@socket_close($sock);
1814
-			    }
1814
+				}
1815 1815
 			    
1816 1816
 			}
1817 1817
 			if ($globalDebug) echo "Waiting...";
@@ -1826,15 +1826,15 @@  discard block
 block discarded – undo
1826 1826
 			if ($globalDebug) echo "Restart all connections...";
1827 1827
 			connect_all($globalSources);
1828 1828
 		}
1829
-	    }
1829
+		}
1830 1830
 	}
1831 1831
 	if ($globalDaemon === false) {
1832
-	    if ($globalDebug) echo 'Check all...'."\n";
1833
-	    if (isset($SI)) $SI->checkAll();
1834
-	    if (isset($TI)) $TI->checkAll();
1835
-	    if (isset($MI)) $MI->checkAll();
1832
+		if ($globalDebug) echo 'Check all...'."\n";
1833
+		if (isset($SI)) $SI->checkAll();
1834
+		if (isset($TI)) $TI->checkAll();
1835
+		if (isset($MI)) $MI->checkAll();
1836
+	}
1836 1837
 	}
1837
-    }
1838 1838
 }
1839 1839
 
1840 1840
 ?>
Please login to merge, or discard this patch.