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