Completed
Push — master ( 06f826...32823f )
by Yannick
68:39 queued 38:54
created
scripts/daemon-spotter.php 1 patch
Indentation   +1117 added lines, -1117 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 57
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 if (isset($options['idsource'])) $id_source = $options['idsource'];
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
106
+	if ($globalDebug) echo "Using Server Mode\n";
107
+	$SI=new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
117
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
117
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 119
 }
120 120
 
121 121
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
122 122
 if (isset($globalMarine) && $globalMarine) {
123
-    $AIS = new AIS();
124
-    $MI = new MarineImport($Connection->db);
123
+	$AIS = new AIS();
124
+	$MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127 127
 $SBS=new SBS();
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
138
-        global $sockets;
139
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
-        die("Bye!\n");
141
-    });
142
-    pcntl_signal_dispatch();
137
+	pcntl_signal(SIGINT,  function() {
138
+		global $sockets;
139
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
+		die("Bye!\n");
141
+	});
142
+	pcntl_signal_dispatch();
143 143
 }
144 144
 
145 145
 // let's try and connect
@@ -149,46 +149,46 @@  discard block
 block discarded – undo
149 149
 $reset = 0;
150 150
 
151 151
 function connect_all($hosts) {
152
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
-    $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
156
-    foreach ($hosts as $id => $value) {
152
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
+	$reset++;
155
+	if ($globalDebug) echo 'Connect to all...'."\n";
156
+	foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160 160
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
162
-        	//$formats[$id] = 'deltadbtxt';
163
-        	$globalSources[$id]['format'] = 'deltadbtxt';
164
-        	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
-        	//$formats[$id] = 'vatsimtxt';
168
-        	$globalSources[$id]['format'] = 'vatsimtxt';
169
-        	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172
-        	//$formats[$id] = 'aircraftlistjson';
173
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
174
-        	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
177
-        	//$formats[$id] = 'aircraftjson';
178
-        	$globalSources[$id]['format'] = 'aircraftjson';
179
-        	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraft$/i',$host)) {
182
-        	//$formats[$id] = 'planefinderclient';
183
-        	$globalSources[$id]['format'] = 'planefinderclient';
184
-        	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
-    	    } else if (preg_match('/opensky/i',$host)) {
187
-        	//$formats[$id] = 'aircraftlistjson';
188
-        	$globalSources[$id]['format'] = 'opensky';
189
-        	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
191
-    	    /*
161
+			if (preg_match('/deltadb.txt$/i',$host)) {
162
+			//$formats[$id] = 'deltadbtxt';
163
+			$globalSources[$id]['format'] = 'deltadbtxt';
164
+			//$last_exec['deltadbtxt'] = 0;
165
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
+			//$formats[$id] = 'vatsimtxt';
168
+			$globalSources[$id]['format'] = 'vatsimtxt';
169
+			//$last_exec['vatsimtxt'] = 0;
170
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
172
+			//$formats[$id] = 'aircraftlistjson';
173
+			$globalSources[$id]['format'] = 'aircraftlistjson';
174
+			//$last_exec['aircraftlistjson'] = 0;
175
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
+			} else if (preg_match('/aircraft.json$/i',$host)) {
177
+			//$formats[$id] = 'aircraftjson';
178
+			$globalSources[$id]['format'] = 'aircraftjson';
179
+			//$last_exec['aircraftlistjson'] = 0;
180
+			if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
+			} else if (preg_match('/aircraft$/i',$host)) {
182
+			//$formats[$id] = 'planefinderclient';
183
+			$globalSources[$id]['format'] = 'planefinderclient';
184
+			//$last_exec['aircraftlistjson'] = 0;
185
+			if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
+			} else if (preg_match('/opensky/i',$host)) {
187
+			//$formats[$id] = 'aircraftlistjson';
188
+			$globalSources[$id]['format'] = 'opensky';
189
+			//$last_exec['aircraftlistjson'] = 0;
190
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
191
+			/*
192 192
     	    // Disabled for now, site change source format
193 193
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
194 194
         	//$formats[$id] = 'radarvirtueljson';
@@ -200,128 +200,128 @@  discard block
 block discarded – undo
200 200
         	    exit(0);
201 201
         	}
202 202
     	    */
203
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
204
-        	//$formats[$id] = 'planeupdatefaa';
205
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
206
-        	//$last_exec['planeupdatefaa'] = 0;
207
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
208
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
-        	    exit(0);
211
-        	}
212
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
213
-        	//$formats[$id] = 'phpvmacars';
214
-        	$globalSources[$id]['format'] = 'phpvmacars';
215
-        	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218
-        	//$formats[$id] = 'phpvmacars';
219
-        	$globalSources[$id]['format'] = 'vaos';
220
-        	//$last_exec['phpvmacars'] = 0;
221
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
223
-        	//$formats[$id] = 'phpvmacars';
224
-        	$globalSources[$id]['format'] = 'vam';
225
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
-            } else if (preg_match('/whazzup/i',$host)) {
227
-        	//$formats[$id] = 'whazzup';
228
-        	$globalSources[$id]['format'] = 'whazzup';
229
-        	//$last_exec['whazzup'] = 0;
230
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
-            } else if (preg_match('/blitzortung/i',$host)) {
232
-        	$globalSources[$id]['format'] = 'blitzortung';
233
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
-            } else if (preg_match('/airwhere/i',$host)) {
235
-        	$globalSources[$id]['format'] = 'airwhere';
236
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
-            } else if (preg_match('/recentpireps/i',$host)) {
238
-        	//$formats[$id] = 'pirepsjson';
239
-        	$globalSources[$id]['format'] = 'pirepsjson';
240
-        	//$last_exec['pirepsjson'] = 0;
241
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243
-        	//$formats[$id] = 'fr24json';
244
-        	$globalSources[$id]['format'] = 'fr24json';
245
-        	//$last_exec['fr24json'] = 0;
246
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
247
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249
-        	    exit(0);
250
-        	}
251
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
252
-        	//$formats[$id] = 'fr24json';
253
-        	$globalSources[$id]['format'] = 'myshiptracking';
254
-        	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
256
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
-        	    exit(0);
259
-        	}
260
-            //} else if (preg_match('/10001/',$host)) {
261
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262
-        	//$formats[$id] = 'tsv';
263
-        	$globalSources[$id]['format'] = 'tsv';
264
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265
-            }
266
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
267
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
269
-    		    if ($idf !== false) {
270
-    			$httpfeeds[$id] = $idf;
271
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
274
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
275
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
276
-	    $hostport = explode(':',$host);
277
-	    if (isset($hostport[1])) {
203
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
204
+			//$formats[$id] = 'planeupdatefaa';
205
+			$globalSources[$id]['format'] = 'planeupdatefaa';
206
+			//$last_exec['planeupdatefaa'] = 0;
207
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
208
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
+				exit(0);
211
+			}
212
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
213
+			//$formats[$id] = 'phpvmacars';
214
+			$globalSources[$id]['format'] = 'phpvmacars';
215
+			//$last_exec['phpvmacars'] = 0;
216
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218
+			//$formats[$id] = 'phpvmacars';
219
+			$globalSources[$id]['format'] = 'vaos';
220
+			//$last_exec['phpvmacars'] = 0;
221
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
223
+			//$formats[$id] = 'phpvmacars';
224
+			$globalSources[$id]['format'] = 'vam';
225
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
+			} else if (preg_match('/whazzup/i',$host)) {
227
+			//$formats[$id] = 'whazzup';
228
+			$globalSources[$id]['format'] = 'whazzup';
229
+			//$last_exec['whazzup'] = 0;
230
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
+			} else if (preg_match('/blitzortung/i',$host)) {
232
+			$globalSources[$id]['format'] = 'blitzortung';
233
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
+			} else if (preg_match('/airwhere/i',$host)) {
235
+			$globalSources[$id]['format'] = 'airwhere';
236
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
+			} else if (preg_match('/recentpireps/i',$host)) {
238
+			//$formats[$id] = 'pirepsjson';
239
+			$globalSources[$id]['format'] = 'pirepsjson';
240
+			//$last_exec['pirepsjson'] = 0;
241
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243
+			//$formats[$id] = 'fr24json';
244
+			$globalSources[$id]['format'] = 'fr24json';
245
+			//$last_exec['fr24json'] = 0;
246
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
247
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249
+				exit(0);
250
+			}
251
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
252
+			//$formats[$id] = 'fr24json';
253
+			$globalSources[$id]['format'] = 'myshiptracking';
254
+			//$last_exec['fr24json'] = 0;
255
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
256
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
+				exit(0);
259
+			}
260
+			//} else if (preg_match('/10001/',$host)) {
261
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262
+			//$formats[$id] = 'tsv';
263
+			$globalSources[$id]['format'] = 'tsv';
264
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265
+			}
266
+		} elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
267
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
269
+				if ($idf !== false) {
270
+				$httpfeeds[$id] = $idf;
271
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
+			} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
274
+			elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
275
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
276
+		$hostport = explode(':',$host);
277
+		if (isset($hostport[1])) {
278 278
 		$port = $hostport[1];
279 279
 		$hostn = $hostport[0];
280
-	    } else {
280
+		} else {
281 281
 		$port = $globalSources[$id]['port'];
282 282
 		$hostn = $globalSources[$id]['host'];
283
-	    }
284
-	    $Common = new Common();
285
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
286
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
287
-    	    } else {
288
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
289
-	    }
290
-	    if ($s) {
291
-    	        $sockets[$id] = $s;
292
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
293
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
283
+		}
284
+		$Common = new Common();
285
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
286
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
287
+			} else {
288
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
289
+		}
290
+		if ($s) {
291
+				$sockets[$id] = $s;
292
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
293
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
294 294
 			//$formats[$id] = 'aprs';
295 295
 			$globalSources[$id]['format'] = 'aprs';
296 296
 			//$aprs_connect = 0;
297 297
 			//$use_aprs = true;
298
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
298
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
299 299
 			$globalSources[$id]['format'] = 'vrstcp';
300
-    		    } elseif ($port == '10001') {
301
-        		//$formats[$id] = 'tsv';
302
-        		$globalSources[$id]['format'] = 'tsv';
303
-		    } elseif ($port == '30002') {
304
-        		//$formats[$id] = 'raw';
305
-        		$globalSources[$id]['format'] = 'raw';
306
-		    } elseif ($port == '5001') {
307
-        		//$formats[$id] = 'raw';
308
-        		$globalSources[$id]['format'] = 'flightgearmp';
309
-		    } elseif ($port == '30005') {
300
+				} elseif ($port == '10001') {
301
+				//$formats[$id] = 'tsv';
302
+				$globalSources[$id]['format'] = 'tsv';
303
+			} elseif ($port == '30002') {
304
+				//$formats[$id] = 'raw';
305
+				$globalSources[$id]['format'] = 'raw';
306
+			} elseif ($port == '5001') {
307
+				//$formats[$id] = 'raw';
308
+				$globalSources[$id]['format'] = 'flightgearmp';
309
+			} elseif ($port == '30005') {
310 310
 			// Not yet supported
311
-        		//$formats[$id] = 'beast';
312
-        		$globalSources[$id]['format'] = 'beast';
313
-		    //} else $formats[$id] = 'sbs';
314
-		    } else $globalSources[$id]['format'] = 'sbs';
315
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
311
+				//$formats[$id] = 'beast';
312
+				$globalSources[$id]['format'] = 'beast';
313
+			//} else $formats[$id] = 'sbs';
314
+			} else $globalSources[$id]['format'] = 'sbs';
315
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
316 316
 		}
317 317
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
318
-            } else {
318
+			} else {
319 319
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
320 320
 		sleep(10);
321 321
 		connect_all($hosts);
322
-    	    }
323
-        }
324
-    }
322
+			}
323
+		}
324
+	}
325 325
 }
326 326
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
327 327
 
@@ -344,9 +344,9 @@  discard block
 block discarded – undo
344 344
 //connect_all($globalSources);
345 345
 
346 346
 if (isset($globalProxy) && $globalProxy) {
347
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
347
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
348 348
 } else {
349
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
349
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
350 350
 }
351 351
 
352 352
 // APRS Configuration
@@ -355,21 +355,21 @@  discard block
 block discarded – undo
355 355
 	die;
356 356
 }
357 357
 foreach ($globalSources as $key => $source) {
358
-    if (!isset($source['format'])) {
359
-        $globalSources[$key]['format'] = 'auto';
360
-    }
361
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
362
-        unset($globalSources[$key]);
363
-    }
358
+	if (!isset($source['format'])) {
359
+		$globalSources[$key]['format'] = 'auto';
360
+	}
361
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
362
+		unset($globalSources[$key]);
363
+	}
364 364
 }
365 365
 connect_all($globalSources);
366 366
 foreach ($globalSources as $key => $source) {
367
-    if (isset($source['format']) && $source['format'] == 'aprs') {
367
+	if (isset($source['format']) && $source['format'] == 'aprs') {
368 368
 	$aprs_connect = 0;
369 369
 	$use_aprs = true;
370 370
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
371 371
 	break;
372
-    }
372
+	}
373 373
 }
374 374
 
375 375
 if ($use_aprs) {
@@ -410,133 +410,133 @@  discard block
 block discarded – undo
410 410
 
411 411
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
412 412
 while ($i > 0) {
413
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
413
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
414 414
 
415
-    if (!$globalDaemon) $i = $endtime-time();
416
-    // Delete old ATC
417
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
415
+	if (!$globalDaemon) $i = $endtime-time();
416
+	// Delete old ATC
417
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
418 418
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
419
-        $ATC->deleteOldATC();
420
-    }
419
+		$ATC->deleteOldATC();
420
+	}
421 421
     
422
-    if (count($last_exec) == count($globalSources)) {
422
+	if (count($last_exec) == count($globalSources)) {
423 423
 	$max = $globalMinFetch;
424 424
 	foreach ($last_exec as $last) {
425
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
425
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
426 426
 	}
427 427
 	if ($max < $globalMinFetch) {
428
-	    if ($globalDebug) echo 'Sleeping...'."\n";
429
-	    sleep($globalMinFetch-$max+2);
428
+		if ($globalDebug) echo 'Sleeping...'."\n";
429
+		sleep($globalMinFetch-$max+2);
430
+	}
430 431
 	}
431
-    }
432 432
 
433 433
     
434
-    //foreach ($formats as $id => $value) {
435
-    foreach ($globalSources as $id => $value) {
434
+	//foreach ($formats as $id => $value) {
435
+	foreach ($globalSources as $id => $value) {
436 436
 	date_default_timezone_set('UTC');
437 437
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
438 438
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
439 439
 	if ($value['format'] === 'deltadbtxt' && 
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))
443
-	    )
443
+		)
444 444
 	) {
445
-	    //$buffer = $Common->getData($hosts[$id]);
446
-	    $buffer = $Common->getData($value['host']);
447
-	    if ($buffer != '') $reset = 0;
448
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449
-	    $buffer = explode('\n',$buffer);
450
-	    foreach ($buffer as $line) {
451
-    		if ($line != '' && count($line) > 7) {
452
-    		    $line = explode(',', $line);
453
-	            $data = array();
454
-	            $data['hex'] = $line[1]; // hex
455
-	            $data['ident'] = $line[2]; // ident
456
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
457
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
458
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
459
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
460
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
461
-	            $data['verticalrate'] = ''; // vertical rate
462
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
463
-	            $data['emergency'] = ''; // emergency
464
-		    $data['datetime'] = date('Y-m-d H:i:s');
465
-		    $data['format_source'] = 'deltadbtxt';
466
-    		    $data['id_source'] = $id_source;
467
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
468
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
469
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
470
-    		    $SI->add($data);
471
-		    unset($data);
472
-    		}
473
-    	    }
474
-    	    $last_exec[$id]['last'] = time();
445
+		//$buffer = $Common->getData($hosts[$id]);
446
+		$buffer = $Common->getData($value['host']);
447
+		if ($buffer != '') $reset = 0;
448
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449
+		$buffer = explode('\n',$buffer);
450
+		foreach ($buffer as $line) {
451
+			if ($line != '' && count($line) > 7) {
452
+				$line = explode(',', $line);
453
+				$data = array();
454
+				$data['hex'] = $line[1]; // hex
455
+				$data['ident'] = $line[2]; // ident
456
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
457
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
458
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
459
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
460
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
461
+				$data['verticalrate'] = ''; // vertical rate
462
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
463
+				$data['emergency'] = ''; // emergency
464
+			$data['datetime'] = date('Y-m-d H:i:s');
465
+			$data['format_source'] = 'deltadbtxt';
466
+				$data['id_source'] = $id_source;
467
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
468
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
469
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
470
+				$SI->add($data);
471
+			unset($data);
472
+			}
473
+			}
474
+			$last_exec[$id]['last'] = time();
475 475
 	} elseif ($value['format'] === 'aisnmeatxt' && 
476
-	    (
476
+		(
477 477
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
478 478
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
479
-	    )
479
+		)
480 480
 	) {
481
-	    date_default_timezone_set('CET');
482
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
483
-	    date_default_timezone_set('UTC');
484
-	    if ($buffer != '') $reset = 0;
485
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486
-	    $buffer = explode('\n',$buffer);
487
-	    foreach ($buffer as $line) {
481
+		date_default_timezone_set('CET');
482
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
483
+		date_default_timezone_set('UTC');
484
+		if ($buffer != '') $reset = 0;
485
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486
+		$buffer = explode('\n',$buffer);
487
+		foreach ($buffer as $line) {
488 488
 		if ($line != '') {
489
-		    //echo "'".$line."'\n";
490
-		    $add = false;
491
-		    $ais_data = $AIS->parse_line(trim($line));
492
-		    $data = array();
493
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
494
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
495
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
496
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
497
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
498
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
499
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
500
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
501
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
502
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
503
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
504
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
505
-		    if (isset($ais_data['timestamp'])) {
489
+			//echo "'".$line."'\n";
490
+			$add = false;
491
+			$ais_data = $AIS->parse_line(trim($line));
492
+			$data = array();
493
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
494
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
495
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
496
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
497
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
498
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
499
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
500
+			if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
501
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
502
+			if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
503
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
504
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
505
+			if (isset($ais_data['timestamp'])) {
506 506
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
507 507
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
508
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
509
-			    $add = true;
508
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
509
+				$add = true;
510 510
 			}
511
-		    } else {
511
+			} else {
512 512
 			$data['datetime'] = date('Y-m-d H:i:s');
513 513
 			$add = true;
514
-		    }
515
-		    $data['format_source'] = 'aisnmeatxt';
516
-    		    $data['id_source'] = $id_source;
517
-		    //print_r($data);
518
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
519
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
520
-		    unset($data);
514
+			}
515
+			$data['format_source'] = 'aisnmeatxt';
516
+				$data['id_source'] = $id_source;
517
+			//print_r($data);
518
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
519
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
520
+			unset($data);
521 521
 		}
522
-    	    }
523
-    	    $last_exec[$id]['last'] = time();
522
+			}
523
+			$last_exec[$id]['last'] = time();
524 524
 	} elseif ($value['format'] === 'aisnmeahttp') {
525
-	    $arr = $httpfeeds;
526
-	    $w = $e = null;
525
+		$arr = $httpfeeds;
526
+		$w = $e = null;
527 527
 	    
528
-	    if (isset($arr[$id])) {
528
+		if (isset($arr[$id])) {
529 529
 		$nn = stream_select($arr,$w,$e,$timeout);
530 530
 		if ($nn > 0) {
531
-		    foreach ($httpfeeds as $feed) {
531
+			foreach ($httpfeeds as $feed) {
532 532
 			$buffer = stream_get_line($feed,2000,"\n");
533 533
 			if ($buffer === FALSE) {
534
-			    connect_all($globalSources);
534
+				connect_all($globalSources);
535 535
 			}
536 536
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
537 537
 			$buffer = explode('\n',$buffer);
538 538
 			foreach ($buffer as $line) {
539
-			    if ($line != '') {
539
+				if ($line != '') {
540 540
 				$ais_data = $AIS->parse_line(trim($line));
541 541
 				$data = array();
542 542
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -554,117 +554,117 @@  discard block
 block discarded – undo
554 554
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
555 555
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
556 556
 				if (isset($ais_data['timestamp'])) {
557
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
557
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
558 558
 				} else {
559
-				    $data['datetime'] = date('Y-m-d H:i:s');
559
+					$data['datetime'] = date('Y-m-d H:i:s');
560 560
 				}
561 561
 				$data['format_source'] = 'aisnmeahttp';
562 562
 				$data['id_source'] = $id_source;
563 563
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
564 564
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
565 565
 				unset($data);
566
-			    }
566
+				}
567
+			}
567 568
 			}
568
-		    }
569 569
 		} else {
570
-		    $format = $value['format'];
571
-		    if (isset($tt[$format])) $tt[$format]++;
572
-		    else $tt[$format] = 0;
573
-		    if ($tt[$format] > 30) {
570
+			$format = $value['format'];
571
+			if (isset($tt[$format])) $tt[$format]++;
572
+			else $tt[$format] = 0;
573
+			if ($tt[$format] > 30) {
574 574
 			if ($globalDebug) echo 'Reconnect...'."\n";
575 575
 			sleep(2);
576 576
 			//$sourceeen[] = $value;
577 577
 			//connect_all($sourceeen);
578 578
 			//$sourceeen = array();
579 579
 			connect_all($globalSources);
580
-		    }
580
+			}
581
+		}
581 582
 		}
582
-	    }
583 583
 	} elseif ($value['format'] === 'myshiptracking' && 
584
-	    (
584
+		(
585 585
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
586 586
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
587
-	    )
587
+		)
588 588
 	) {
589
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
590
-	    if ($buffer != '') {
589
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
590
+		if ($buffer != '') {
591 591
 		//echo $buffer;
592 592
 		$all_data = json_decode($buffer,true);
593 593
 		//print_r($all_data);
594 594
 		if (isset($all_data[0]['DATA'])) {
595
-		    foreach ($all_data[0]['DATA'] as $line) {
595
+			foreach ($all_data[0]['DATA'] as $line) {
596 596
 			if ($line != '') {
597
-			    $data = array();
598
-			    $data['ident'] = $line['NAME'];
599
-			    $data['mmsi'] = $line['MMSI'];
600
-			    if (strlen($data['mmsi']) > 9) {
597
+				$data = array();
598
+				$data['ident'] = $line['NAME'];
599
+				$data['mmsi'] = $line['MMSI'];
600
+				if (strlen($data['mmsi']) > 9) {
601 601
 				$data['mmsi'] = substr($data['mmsi'],-9);
602
-			    }
603
-			    $data['speed'] = $line['SOG'];
604
-			    $data['heading'] = $line['COG'];
605
-			    $data['latitude'] = $line['LAT'];
606
-			    $data['longitude'] = $line['LNG'];
607
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
608
-			    //$data['type_id'] = $line['TYPE'];
609
-			    $data['imo'] = $line['IMO'];
610
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
611
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
612
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
613
-			    $data['format_source'] = 'myshiptracking';
614
-			    $data['id_source'] = $id_source;
615
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
616
-			    $MI->add($data);
617
-			    unset($data);
602
+				}
603
+				$data['speed'] = $line['SOG'];
604
+				$data['heading'] = $line['COG'];
605
+				$data['latitude'] = $line['LAT'];
606
+				$data['longitude'] = $line['LNG'];
607
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
608
+				//$data['type_id'] = $line['TYPE'];
609
+				$data['imo'] = $line['IMO'];
610
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
611
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
612
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
613
+				$data['format_source'] = 'myshiptracking';
614
+				$data['id_source'] = $id_source;
615
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
616
+				$MI->add($data);
617
+				unset($data);
618 618
 			}
619
-		    }
619
+			}
620
+		}
620 621
 		}
621
-	    }
622
-	    $last_exec[$id]['last'] = time();
622
+		$last_exec[$id]['last'] = time();
623 623
 	} elseif ($value['format'] === 'boatbeaconapp' && 
624
-	    (
624
+		(
625 625
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
626 626
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
627
-	    )
627
+		)
628 628
 	) {
629
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
630
-	    if ($buffer != '') {
629
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
630
+		if ($buffer != '') {
631 631
 		$all_data = json_decode($buffer,true);
632 632
 		if (isset($all_data[0]['mmsi'])) {
633
-		    foreach ($all_data as $line) {
633
+			foreach ($all_data as $line) {
634 634
 			if ($line != '') {
635
-			    $data = array();
636
-			    $data['ident'] = $line['shipname'];
637
-			    $data['callsign'] = $line['callsign'];
638
-			    $data['mmsi'] = substr($line['mmsi'],-9);
639
-			    $data['speed'] = $line['sog'];
640
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
641
-			    $data['latitude'] = $line['latitude'];
642
-			    $data['longitude'] = $line['longitude'];
643
-			    $data['type_id'] = $line['shiptype'];
644
-			    $data['arrival_code'] = $line['destination'];
645
-			    $data['datetime'] = $line['time'];
646
-			    $data['format_source'] = 'boatbeaconapp';
647
-			    $data['id_source'] = $id_source;
648
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
649
-			    $MI->add($data);
650
-			    unset($data);
635
+				$data = array();
636
+				$data['ident'] = $line['shipname'];
637
+				$data['callsign'] = $line['callsign'];
638
+				$data['mmsi'] = substr($line['mmsi'],-9);
639
+				$data['speed'] = $line['sog'];
640
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
641
+				$data['latitude'] = $line['latitude'];
642
+				$data['longitude'] = $line['longitude'];
643
+				$data['type_id'] = $line['shiptype'];
644
+				$data['arrival_code'] = $line['destination'];
645
+				$data['datetime'] = $line['time'];
646
+				$data['format_source'] = 'boatbeaconapp';
647
+				$data['id_source'] = $id_source;
648
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
649
+				$MI->add($data);
650
+				unset($data);
651
+			}
651 652
 			}
652
-		    }
653 653
 		}
654 654
 		
655
-	    }
656
-    	    $last_exec[$id]['last'] = time();
655
+		}
656
+			$last_exec[$id]['last'] = time();
657 657
 	} elseif ($value['format'] === 'boatnerd' && 
658
-	    (
658
+		(
659 659
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
660 660
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
661
-	    )
661
+		)
662 662
 	) {
663
-	    $buffer = $Common->getData($value['host']);
664
-	    if ($buffer != '') {
663
+		$buffer = $Common->getData($value['host']);
664
+		if ($buffer != '') {
665 665
 		$all_data = json_decode($buffer,true);
666 666
 		if (isset($all_data['features'][0]['id'])) {
667
-		    foreach ($all_data['features'] as $line) {
667
+			foreach ($all_data['features'] as $line) {
668 668
 			print_r($line);
669 669
 			$data = array();
670 670
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -684,76 +684,76 @@  discard block
 block discarded – undo
684 684
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
685 685
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
686 686
 			unset($data);
687
-		    }
687
+			}
688 688
 		}
689 689
 		
690
-	    }
691
-    	    $last_exec[$id]['last'] = time();
690
+		}
691
+			$last_exec[$id]['last'] = time();
692 692
 	} elseif ($value['format'] === 'shipplotter' && 
693
-	    (
693
+		(
694 694
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
695 695
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
696
-	    )
696
+		)
697 697
 	) {
698
-	    if ($globalDebug) echo 'download...';
699
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
700
-	    if ($globalDebug) echo 'done !'."\n";
701
-	    // FIXME: Need more work
702
-	    if ($buffer != '') $reset = 0;
703
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
704
-	    $buffer = explode('\n',$buffer);
705
-	    foreach ($buffer as $line) {
698
+		if ($globalDebug) echo 'download...';
699
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
700
+		if ($globalDebug) echo 'done !'."\n";
701
+		// FIXME: Need more work
702
+		if ($buffer != '') $reset = 0;
703
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
704
+		$buffer = explode('\n',$buffer);
705
+		foreach ($buffer as $line) {
706 706
 		if ($line != '') {
707
-		    $data = array();
708
-		    //echo $line."\n";
709
-		    $data['mmsi'] = (int)substr($line,0,9);
710
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
711
-		    $data['status_id'] = substr($line,21,2);
712
-		    $data['type_id'] = substr($line,24,3);
713
-		    $data['latitude'] = substr($line,29,9);
714
-		    $data['longitude'] = substr($line,41,9);
715
-		    $data['speed'] = round(substr($line,51,5));
716
-		    //$data['course'] = substr($line,57,5);
717
-		    $data['heading'] = round(substr($line,63,3));
718
-		    //$data['draft'] = substr($line,67,4);
719
-		    //$data['length'] = substr($line,72,3);
720
-		    //$data['beam'] = substr($line,76,2);
721
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
722
-		    //$data['callsign'] = trim(substr($line,100,7);
723
-		    $data['arrival_code'] = substr($line,108,20);
724
-		    //$data['etaDate'] = substr($line,129,5);
725
-		    //$data['etaTime'] = substr($line,135,5);
726
-		    $data['format_source'] = 'shipplotter';
727
-    		    $data['id_source'] = $id_source;
728
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
729
-		    //print_r($data);
730
-		    //echo 'Add...'."\n";
731
-		    $MI->add($data);
732
-		    unset($data);
707
+			$data = array();
708
+			//echo $line."\n";
709
+			$data['mmsi'] = (int)substr($line,0,9);
710
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
711
+			$data['status_id'] = substr($line,21,2);
712
+			$data['type_id'] = substr($line,24,3);
713
+			$data['latitude'] = substr($line,29,9);
714
+			$data['longitude'] = substr($line,41,9);
715
+			$data['speed'] = round(substr($line,51,5));
716
+			//$data['course'] = substr($line,57,5);
717
+			$data['heading'] = round(substr($line,63,3));
718
+			//$data['draft'] = substr($line,67,4);
719
+			//$data['length'] = substr($line,72,3);
720
+			//$data['beam'] = substr($line,76,2);
721
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
722
+			//$data['callsign'] = trim(substr($line,100,7);
723
+			$data['arrival_code'] = substr($line,108,20);
724
+			//$data['etaDate'] = substr($line,129,5);
725
+			//$data['etaTime'] = substr($line,135,5);
726
+			$data['format_source'] = 'shipplotter';
727
+				$data['id_source'] = $id_source;
728
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
729
+			//print_r($data);
730
+			//echo 'Add...'."\n";
731
+			$MI->add($data);
732
+			unset($data);
733 733
 		}
734
-    	    }
735
-    	    $last_exec[$id]['last'] = time();
734
+			}
735
+			$last_exec[$id]['last'] = time();
736 736
 	} elseif ($value['format'] === 'sailaway' && 
737
-	    (
737
+		(
738 738
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
739 739
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
740
-	    )
740
+		)
741 741
 	) {
742
-	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
742
+		if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
743 743
 		$authsailaway = $Common->getData('https://sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
744 744
 		//echo $authsailaway;
745 745
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
746 746
 		if (isset($setcookie[1][0])) {
747
-		    $sailaway_authcookie = $setcookie[1][0];
747
+			$sailaway_authcookie = $setcookie[1][0];
748
+		}
748 749
 		}
749
-	    }
750 750
 
751
-	    if ($globalDebug) echo '! Download... ';
752
-	    for ($i =0; $i <= 1; $i++) {
751
+		if ($globalDebug) echo '! Download... ';
752
+		for ($i =0; $i <= 1; $i++) {
753 753
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
754 754
 		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
755
-	    if ($globalDebug) echo 'done'."\n";
756
-	    if ($buffer != '') {
755
+		if ($globalDebug) echo 'done'."\n";
756
+		if ($buffer != '') {
757 757
 		$all_data = json_decode($buffer,true);
758 758
 		if (isset($all_data['missions'])) {
759 759
 			foreach ($all_data['missions'] as $mission) {
@@ -772,19 +772,19 @@  discard block
 block discarded – undo
772 772
 					//print_r($race_data);
773 773
 					unset($racebuffer);
774 774
 					if (isset($race_data['mission'])) {
775
-					    $datar = array();
776
-					    $datar['id'] = $mission['misnr'];
777
-					    $datar['desc'] = $race_data['mission']['misdescr'];
778
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
779
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
780
-					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
781
-					    $markers = array();
782
-					    foreach ($race_data['mission']['course'] as $course) {
775
+						$datar = array();
776
+						$datar['id'] = $mission['misnr'];
777
+						$datar['desc'] = $race_data['mission']['misdescr'];
778
+						$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
779
+						$datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
780
+						$datar['startdate'] = $race_data['mission']['misstartdatetime'];
781
+						$markers = array();
782
+						foreach ($race_data['mission']['course'] as $course) {
783 783
 						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
784
-					    }
785
-					    $datar['markers'] = json_encode($markers);
786
-					    //print_r($datar);
787
-					    $MI->race_add($datar);
784
+						}
785
+						$datar['markers'] = json_encode($markers);
786
+						//print_r($datar);
787
+						$MI->race_add($datar);
788 788
 					}
789 789
 				}
790 790
 				if ($bufferm != '') {
@@ -847,34 +847,34 @@  discard block
 block discarded – undo
847 847
 				}
848 848
 			}
849 849
 		}
850
-	    }
851
-	    }
852
-    	    $last_exec[$id]['last'] = time();
850
+		}
851
+		}
852
+			$last_exec[$id]['last'] = time();
853 853
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
854 854
 	} elseif (
855
-	    (
855
+		(
856 856
 		$value['format'] === 'whazzup' && 
857 857
 		(
858
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
859
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
858
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
859
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
860 860
 		)
861
-	    ) || (
861
+		) || (
862 862
 		$value['format'] === 'vatsimtxt' && 
863 863
 		(
864
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
865
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
864
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
865
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
866
+		)
866 867
 		)
867
-	    )
868 868
 	) {
869
-	    //$buffer = $Common->getData($hosts[$id]);
870
-	    $buffer = $Common->getData($value['host']);
871
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
872
-	    $buffer = explode('\n',$buffer);
873
-	    $reset = 0;
874
-	    foreach ($buffer as $line) {
875
-    		if ($line != '') {
876
-    		    $line = explode(':', $line);
877
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
869
+		//$buffer = $Common->getData($hosts[$id]);
870
+		$buffer = $Common->getData($value['host']);
871
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
872
+		$buffer = explode('\n',$buffer);
873
+		$reset = 0;
874
+		foreach ($buffer as $line) {
875
+			if ($line != '') {
876
+				$line = explode(':', $line);
877
+				if (count($line) > 30 && $line[0] != 'callsign') {
878 878
 			$data = array();
879 879
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
880 880
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -887,37 +887,37 @@  discard block
 block discarded – undo
887 887
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
888 888
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
889 889
 			$data['latitude'] = $line[5]; // lat
890
-	        	$data['longitude'] = $line[6]; // long
891
-	        	$data['verticalrate'] = ''; // vertical rate
892
-	        	$data['squawk'] = ''; // squawk
893
-	        	$data['emergency'] = ''; // emergency
894
-	        	$data['waypoints'] = $line[30];
890
+				$data['longitude'] = $line[6]; // long
891
+				$data['verticalrate'] = ''; // vertical rate
892
+				$data['squawk'] = ''; // squawk
893
+				$data['emergency'] = ''; // emergency
894
+				$data['waypoints'] = $line[30];
895 895
 			$data['datetime'] = date('Y-m-d H:i:s');
896 896
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
897 897
 			//if (isset($line[37])) $data['last_update'] = $line[37];
898
-		        $data['departure_airport_icao'] = $line[11];
899
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
900
-		        $data['arrival_airport_icao'] = $line[13];
898
+				$data['departure_airport_icao'] = $line[11];
899
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
900
+				$data['arrival_airport_icao'] = $line[13];
901 901
 			$data['frequency'] = $line[4];
902 902
 			$data['type'] = $line[18];
903 903
 			$data['range'] = $line[19];
904 904
 			if (isset($line[35])) $data['info'] = $line[35];
905
-    			$data['id_source'] = $id_source;
906
-	    		//$data['arrival_airport_time'] = ;
907
-	    		if ($line[9] != '') {
908
-	    		    $aircraft_data = explode('/',$line[9]);
909
-	    		    if (isset($aircraft_data[1])) {
910
-	    			$data['aircraft_icao'] = $aircraft_data[1];
911
-	    		    }
912
-        		}
913
-	    		/*
905
+				$data['id_source'] = $id_source;
906
+				//$data['arrival_airport_time'] = ;
907
+				if ($line[9] != '') {
908
+					$aircraft_data = explode('/',$line[9]);
909
+					if (isset($aircraft_data[1])) {
910
+					$data['aircraft_icao'] = $aircraft_data[1];
911
+					}
912
+				}
913
+				/*
914 914
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
915 915
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
916 916
 	    		*/
917
-	    		$data['format_source'] = $value['format'];
917
+				$data['format_source'] = $value['format'];
918 918
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
919 919
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
920
-    			if ($line[3] === 'PILOT') $SI->add($data);
920
+				if ($line[3] === 'PILOT') $SI->add($data);
921 921
 			elseif ($line[3] === 'ATC') {
922 922
 				//print_r($data);
923 923
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -938,21 +938,21 @@  discard block
 block discarded – undo
938 938
 					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']);
939 939
 				}
940 940
 			}
941
-    			unset($data);
942
-    		    }
943
-    		}
944
-    	    }
945
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
946
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
947
-    	    $last_exec[$id]['last'] = time();
948
-    	} elseif ($value['format'] === 'airwhere' && 
949
-    	    (
950
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
951
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
952
-    	    )
953
-    	) {
954
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
955
-	    if ($buffer != '') {
941
+				unset($data);
942
+				}
943
+			}
944
+			}
945
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
946
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
947
+			$last_exec[$id]['last'] = time();
948
+		} elseif ($value['format'] === 'airwhere' && 
949
+			(
950
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
951
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
952
+			)
953
+		) {
954
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
955
+		if ($buffer != '') {
956 956
 		$all_data = simplexml_load_string($buffer);
957 957
 		foreach($all_data->children() as $childdata) {
958 958
 			$data = array();
@@ -974,10 +974,10 @@  discard block
 block discarded – undo
974 974
 			$SI->add($data);
975 975
 			unset($data);
976 976
 		}
977
-	    }
978
-	    $Source->deleteOldLocationByType('gs');
979
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
980
-	    if ($buffer != '') {
977
+		}
978
+		$Source->deleteOldLocationByType('gs');
979
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
980
+		if ($buffer != '') {
981 981
 		$all_data = simplexml_load_string($buffer);
982 982
 		foreach($all_data->children() as $childdata) {
983 983
 			$data = array();
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
 			}
996 996
 			unset($data);
997 997
 		}
998
-	    }
999
-	    $last_exec[$id]['last'] = time();
998
+		}
999
+		$last_exec[$id]['last'] = time();
1000 1000
 	/*
1001 1001
 	} if ($value['format'] === 'aircraftlistjson') {
1002 1002
 	    print_r($globalSources);
@@ -1004,17 +1004,17 @@  discard block
 block discarded – undo
1004 1004
 	    echo $globalMinFetch;
1005 1005
 	*/
1006 1006
 	} elseif ($value['format'] === 'aircraftlistjson' && 
1007
-	    (
1007
+		(
1008 1008
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1009 1009
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1010
-	    )
1010
+		)
1011 1011
 	) {
1012
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1013
-	    if ($buffer != '') {
1014
-	        $all_data = json_decode($buffer,true);
1012
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
1013
+		if ($buffer != '') {
1014
+			$all_data = json_decode($buffer,true);
1015 1015
 		if (isset($all_data['acList'])) {
1016
-		    $reset = 0;
1017
-		    foreach ($all_data['acList'] as $line) {
1016
+			$reset = 0;
1017
+			foreach ($all_data['acList'] as $line) {
1018 1018
 			$data = array();
1019 1019
 			$data['hex'] = $line['Icao']; // hex
1020 1020
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1037,10 +1037,10 @@  discard block
 block discarded – undo
1037 1037
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1038 1038
 			if (isset($data['latitude'])) $SI->add($data);
1039 1039
 			unset($data);
1040
-		    }
1040
+			}
1041 1041
 		} elseif (is_array($all_data)) {
1042
-		    $reset = 0;
1043
-		    foreach ($all_data as $line) {
1042
+			$reset = 0;
1043
+			foreach ($all_data as $line) {
1044 1044
 			$data = array();
1045 1045
 			$data['hex'] = $line['hex']; // hex
1046 1046
 			$data['ident'] = $line['flight']; // ident
@@ -1060,291 +1060,291 @@  discard block
 block discarded – undo
1060 1060
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1061 1061
 			$SI->add($data);
1062 1062
 			unset($data);
1063
-		    }
1063
+			}
1064 1064
 		}
1065
-	    } elseif ($globalDebug) echo 'No data'."\n";
1066
-    	    //$last_exec['aircraftlistjson'] = time();
1067
-    	    $last_exec[$id]['last'] = time();
1068
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1069
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
1070
-    	    (
1071
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1072
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1073
-    	    )
1074
-    	) {
1075
-	    $buffer = $Common->getData($value['host']);
1076
-	    $all_data = json_decode($buffer,true);
1077
-	    if (isset($all_data['planes'])) {
1065
+		} elseif ($globalDebug) echo 'No data'."\n";
1066
+			//$last_exec['aircraftlistjson'] = time();
1067
+			$last_exec[$id]['last'] = time();
1068
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1069
+		} elseif ($value['format'] === 'planeupdatefaa' && 
1070
+			(
1071
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1072
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1073
+			)
1074
+		) {
1075
+		$buffer = $Common->getData($value['host']);
1076
+		$all_data = json_decode($buffer,true);
1077
+		if (isset($all_data['planes'])) {
1078 1078
 		$reset = 0;
1079 1079
 		foreach ($all_data['planes'] as $key => $line) {
1080
-		    $data = array();
1081
-		    $data['hex'] = $key; // hex
1082
-		    $data['ident'] = $line[3]; // ident
1083
-		    $data['altitude'] = $line[6]; // altitude
1084
-		    $data['speed'] = $line[8]; // speed
1085
-		    $data['heading'] = $line[7]; // heading
1086
-		    $data['latitude'] = $line[4]; // lat
1087
-		    $data['longitude'] = $line[5]; // long
1088
-		    //$data['verticalrate'] = $line[]; // verticale rate
1089
-		    $data['squawk'] = $line[10]; // squawk
1090
-		    $data['emergency'] = ''; // emergency
1091
-		    $data['registration'] = $line[2];
1092
-		    $data['aircraft_icao'] = $line[0];
1093
-		    $deparr = explode('-',$line[1]);
1094
-		    if (count($deparr) === 2) {
1080
+			$data = array();
1081
+			$data['hex'] = $key; // hex
1082
+			$data['ident'] = $line[3]; // ident
1083
+			$data['altitude'] = $line[6]; // altitude
1084
+			$data['speed'] = $line[8]; // speed
1085
+			$data['heading'] = $line[7]; // heading
1086
+			$data['latitude'] = $line[4]; // lat
1087
+			$data['longitude'] = $line[5]; // long
1088
+			//$data['verticalrate'] = $line[]; // verticale rate
1089
+			$data['squawk'] = $line[10]; // squawk
1090
+			$data['emergency'] = ''; // emergency
1091
+			$data['registration'] = $line[2];
1092
+			$data['aircraft_icao'] = $line[0];
1093
+			$deparr = explode('-',$line[1]);
1094
+			if (count($deparr) === 2) {
1095 1095
 			$data['departure_airport_icao'] = $deparr[0];
1096 1096
 			$data['arrival_airport_icao'] = $deparr[1];
1097
-		    }
1098
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1099
-	    	    $data['format_source'] = 'planeupdatefaa';
1100
-    		    $data['id_source'] = $id_source;
1101
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1102
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1103
-		    $SI->add($data);
1104
-		    unset($data);
1097
+			}
1098
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1099
+				$data['format_source'] = 'planeupdatefaa';
1100
+				$data['id_source'] = $id_source;
1101
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1102
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1103
+			$SI->add($data);
1104
+			unset($data);
1105
+		}
1105 1106
 		}
1106
-	    }
1107
-	    //$last_exec['planeupdatefaa'] = time();
1108
-	    $last_exec[$id]['last'] = time();
1107
+		//$last_exec['planeupdatefaa'] = time();
1108
+		$last_exec[$id]['last'] = time();
1109 1109
 	} elseif ($value['format'] === 'opensky' && 
1110
-	    (
1110
+		(
1111 1111
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1112 1112
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1113
-	    )
1113
+		)
1114 1114
 	) {
1115
-	    $buffer = $Common->getData($value['host']);
1116
-	    $all_data = json_decode($buffer,true);
1117
-	    if (isset($all_data['states'])) {
1115
+		$buffer = $Common->getData($value['host']);
1116
+		$all_data = json_decode($buffer,true);
1117
+		if (isset($all_data['states'])) {
1118 1118
 		$reset = 0;
1119 1119
 		foreach ($all_data['states'] as $key => $line) {
1120
-		    $data = array();
1121
-		    $data['hex'] = $line[0]; // hex
1122
-		    $data['ident'] = trim($line[1]); // ident
1123
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1124
-		    $data['speed'] = round($line[9]*1.94384); // speed
1125
-		    $data['heading'] = round($line[10]); // heading
1126
-		    $data['latitude'] = $line[6]; // lat
1127
-		    $data['longitude'] = $line[5]; // long
1128
-		    $data['verticalrate'] = $line[11]; // verticale rate
1129
-		    //$data['squawk'] = $line[10]; // squawk
1130
-		    //$data['emergency'] = ''; // emergency
1131
-		    //$data['registration'] = $line[2];
1132
-		    //$data['aircraft_icao'] = $line[0];
1133
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1134
-		    $data['format_source'] = 'opensky';
1135
-		    $data['id_source'] = $id_source;
1136
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1137
-		    $SI->add($data);
1138
-		    unset($data);
1120
+			$data = array();
1121
+			$data['hex'] = $line[0]; // hex
1122
+			$data['ident'] = trim($line[1]); // ident
1123
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1124
+			$data['speed'] = round($line[9]*1.94384); // speed
1125
+			$data['heading'] = round($line[10]); // heading
1126
+			$data['latitude'] = $line[6]; // lat
1127
+			$data['longitude'] = $line[5]; // long
1128
+			$data['verticalrate'] = $line[11]; // verticale rate
1129
+			//$data['squawk'] = $line[10]; // squawk
1130
+			//$data['emergency'] = ''; // emergency
1131
+			//$data['registration'] = $line[2];
1132
+			//$data['aircraft_icao'] = $line[0];
1133
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1134
+			$data['format_source'] = 'opensky';
1135
+			$data['id_source'] = $id_source;
1136
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1137
+			$SI->add($data);
1138
+			unset($data);
1139 1139
 		}
1140
-	    }
1141
-	    //$last_exec['planeupdatefaa'] = time();
1142
-	    $last_exec[$id]['last'] = time();
1140
+		}
1141
+		//$last_exec['planeupdatefaa'] = time();
1142
+		$last_exec[$id]['last'] = time();
1143 1143
 	} elseif ($value['format'] === 'aircraftjson' && 
1144
-	    (
1144
+		(
1145 1145
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1146 1146
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1147
-	    )
1147
+		)
1148 1148
 	) {
1149
-	    $buffer = $Common->getData($value['host']);
1150
-	    $all_data = json_decode($buffer,true);
1151
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1149
+		$buffer = $Common->getData($value['host']);
1150
+		$all_data = json_decode($buffer,true);
1151
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1152 1152
 		$reset = 0;
1153 1153
 		foreach ($all_data['aircraft'] as $key => $line) {
1154
-		    $data = array();
1155
-		    // add support for ground vehicule with ~ in front of hex
1156
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1157
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1158
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1159
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1160
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1161
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1162
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1163
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1164
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1165
-		    //$data['emergency'] = ''; // emergency
1166
-		    //$data['registration'] = $line[2];
1167
-		    //$data['aircraft_icao'] = $line[0];
1168
-		    $data['datetime'] = date('Y-m-d H:i:s');
1169
-		    $data['format_source'] = 'aircraftjson';
1170
-		    $data['id_source'] = $id_source;
1171
-		    if (isset($value['name']) && $value['name'] != '') {
1172
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1173
-			    else $data['source_name'] = $value['name'];
1174
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1175
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1176
-		    $SI->add($data);
1177
-		    unset($data);
1154
+			$data = array();
1155
+			// add support for ground vehicule with ~ in front of hex
1156
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1157
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1158
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1159
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1160
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1161
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1162
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1163
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1164
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1165
+			//$data['emergency'] = ''; // emergency
1166
+			//$data['registration'] = $line[2];
1167
+			//$data['aircraft_icao'] = $line[0];
1168
+			$data['datetime'] = date('Y-m-d H:i:s');
1169
+			$data['format_source'] = 'aircraftjson';
1170
+			$data['id_source'] = $id_source;
1171
+			if (isset($value['name']) && $value['name'] != '') {
1172
+				if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1173
+				else $data['source_name'] = $value['name'];
1174
+			} elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1175
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1176
+			$SI->add($data);
1177
+			unset($data);
1178
+		}
1178 1179
 		}
1179
-	    }
1180
-	    //$last_exec['planeupdatefaa'] = time();
1181
-	    $last_exec[$id]['last'] = time();
1180
+		//$last_exec['planeupdatefaa'] = time();
1181
+		$last_exec[$id]['last'] = time();
1182 1182
 	} elseif ($value['format'] === 'planefinderclient' && 
1183
-	    (
1183
+		(
1184 1184
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1185 1185
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1186
-	    )
1186
+		)
1187 1187
 	) {
1188
-	    $buffer = $Common->getData($value['host']);
1189
-	    $all_data = json_decode($buffer,true);
1190
-	    if (isset($all_data['aircraft'])) {
1188
+		$buffer = $Common->getData($value['host']);
1189
+		$all_data = json_decode($buffer,true);
1190
+		if (isset($all_data['aircraft'])) {
1191 1191
 		$reset = 0;
1192 1192
 		foreach ($all_data['aircraft'] as $key => $line) {
1193
-		    $data = array();
1194
-		    $data['hex'] = $key; // hex
1195
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1196
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1197
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1198
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1199
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1200
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1201
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1202
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1203
-		    //$data['emergency'] = ''; // emergency
1204
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1205
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1206
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1207
-		    $data['format_source'] = 'planefinderclient';
1208
-		    $data['id_source'] = $id_source;
1209
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1210
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1211
-		    $SI->add($data);
1212
-		    unset($data);
1193
+			$data = array();
1194
+			$data['hex'] = $key; // hex
1195
+			if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1196
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1197
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1198
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1199
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1200
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1201
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1202
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1203
+			//$data['emergency'] = ''; // emergency
1204
+			if (isset($line['reg'])) $data['registration'] = $line['reg'];
1205
+			if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1206
+			$data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1207
+			$data['format_source'] = 'planefinderclient';
1208
+			$data['id_source'] = $id_source;
1209
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1210
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1211
+			$SI->add($data);
1212
+			unset($data);
1213 1213
 		}
1214
-	    }
1215
-	    $last_exec[$id]['last'] = time();
1214
+		}
1215
+		$last_exec[$id]['last'] = time();
1216 1216
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1217 1217
 	} elseif ($value['format'] === 'fr24json' && 
1218
-	    (
1218
+		(
1219 1219
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1220 1220
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1221
-	    )
1221
+		)
1222 1222
 	) {
1223
-	    //$buffer = $Common->getData($hosts[$id]);
1224
-	    $buffer = $Common->getData($value['host']);
1225
-	    $all_data = json_decode($buffer,true);
1226
-	    if (!empty($all_data)) $reset = 0;
1227
-	    foreach ($all_data as $key => $line) {
1223
+		//$buffer = $Common->getData($hosts[$id]);
1224
+		$buffer = $Common->getData($value['host']);
1225
+		$all_data = json_decode($buffer,true);
1226
+		if (!empty($all_data)) $reset = 0;
1227
+		foreach ($all_data as $key => $line) {
1228 1228
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1229
-		    $data = array();
1230
-		    $data['hex'] = $line[0];
1231
-		    $data['ident'] = $line[16]; //$line[13]
1232
-	    	    $data['altitude'] = $line[4]; // altitude
1233
-	    	    $data['speed'] = $line[5]; // speed
1234
-	    	    $data['heading'] = $line[3]; // heading
1235
-	    	    $data['latitude'] = $line[1]; // lat
1236
-	    	    $data['longitude'] = $line[2]; // long
1237
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1238
-	    	    $data['squawk'] = $line[6]; // squawk
1239
-	    	    $data['aircraft_icao'] = $line[8];
1240
-	    	    $data['registration'] = $line[9];
1241
-		    $data['departure_airport_iata'] = $line[11];
1242
-		    $data['arrival_airport_iata'] = $line[12];
1243
-	    	    $data['emergency'] = ''; // emergency
1244
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1245
-	    	    $data['format_source'] = 'fr24json';
1246
-    		    $data['id_source'] = $id_source;
1247
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1248
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1249
-		    $SI->add($data);
1250
-		    unset($data);
1229
+			$data = array();
1230
+			$data['hex'] = $line[0];
1231
+			$data['ident'] = $line[16]; //$line[13]
1232
+				$data['altitude'] = $line[4]; // altitude
1233
+				$data['speed'] = $line[5]; // speed
1234
+				$data['heading'] = $line[3]; // heading
1235
+				$data['latitude'] = $line[1]; // lat
1236
+				$data['longitude'] = $line[2]; // long
1237
+				$data['verticalrate'] = $line[15]; // verticale rate
1238
+				$data['squawk'] = $line[6]; // squawk
1239
+				$data['aircraft_icao'] = $line[8];
1240
+				$data['registration'] = $line[9];
1241
+			$data['departure_airport_iata'] = $line[11];
1242
+			$data['arrival_airport_iata'] = $line[12];
1243
+				$data['emergency'] = ''; // emergency
1244
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1245
+				$data['format_source'] = 'fr24json';
1246
+				$data['id_source'] = $id_source;
1247
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1248
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1249
+			$SI->add($data);
1250
+			unset($data);
1251
+		}
1251 1252
 		}
1252
-	    }
1253
-	    //$last_exec['fr24json'] = time();
1254
-	    $last_exec[$id]['last'] = time();
1253
+		//$last_exec['fr24json'] = time();
1254
+		$last_exec[$id]['last'] = time();
1255 1255
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1256 1256
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1257
-	    (
1257
+		(
1258 1258
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1259 1259
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1260
-	    )
1260
+		)
1261 1261
 	) {
1262
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1263
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1264
-	    //echo $buffer;
1265
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1266
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1267
-	    $all_data = json_decode($buffer,true);
1268
-	    if (json_last_error() != JSON_ERROR_NONE) {
1262
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1263
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1264
+		//echo $buffer;
1265
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1266
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1267
+		$all_data = json_decode($buffer,true);
1268
+		if (json_last_error() != JSON_ERROR_NONE) {
1269 1269
 		die(json_last_error_msg());
1270
-	    }
1271
-	    if (isset($all_data['mrkrs'])) {
1270
+		}
1271
+		if (isset($all_data['mrkrs'])) {
1272 1272
 		$reset = 0;
1273 1273
 		foreach ($all_data['mrkrs'] as $key => $line) {
1274
-		    if (isset($line['inf'])) {
1274
+			if (isset($line['inf'])) {
1275 1275
 			$data = array();
1276 1276
 			$data['hex'] = $line['inf']['ia'];
1277 1277
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1278
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1279
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1280
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1281
-	    		$data['latitude'] = $line['pt'][0]; // lat
1282
-	    		$data['longitude'] = $line['pt'][1]; // long
1283
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1284
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1285
-	    		//$data['aircraft_icao'] = $line[8];
1286
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1278
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1279
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1280
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1281
+				$data['latitude'] = $line['pt'][0]; // lat
1282
+				$data['longitude'] = $line['pt'][1]; // long
1283
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1284
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1285
+				//$data['aircraft_icao'] = $line[8];
1286
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1287 1287
 			//$data['departure_airport_iata'] = $line[11];
1288 1288
 			//$data['arrival_airport_iata'] = $line[12];
1289
-	    		//$data['emergency'] = ''; // emergency
1289
+				//$data['emergency'] = ''; // emergency
1290 1290
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1291
-	    		$data['format_source'] = 'radarvirtueljson';
1292
-    			$data['id_source'] = $id_source;
1291
+				$data['format_source'] = 'radarvirtueljson';
1292
+				$data['id_source'] = $id_source;
1293 1293
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1294 1294
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1295 1295
 			$SI->add($data);
1296 1296
 			unset($data);
1297
-		    }
1297
+			}
1298 1298
 		}
1299
-	    }
1300
-	    //$last_exec['radarvirtueljson'] = time();
1301
-	    $last_exec[$id]['last'] = time();
1299
+		}
1300
+		//$last_exec['radarvirtueljson'] = time();
1301
+		$last_exec[$id]['last'] = time();
1302 1302
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1303 1303
 	} elseif ($value['format'] === 'pirepsjson' && 
1304
-	    (
1304
+		(
1305 1305
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1306 1306
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1307
-	    )
1307
+		)
1308 1308
 	) {
1309
-	    //$buffer = $Common->getData($hosts[$id]);
1310
-	    $buffer = $Common->getData($value['host'].'?'.time());
1311
-	    $all_data = json_decode(utf8_encode($buffer),true);
1309
+		//$buffer = $Common->getData($hosts[$id]);
1310
+		$buffer = $Common->getData($value['host'].'?'.time());
1311
+		$all_data = json_decode(utf8_encode($buffer),true);
1312 1312
 	    
1313
-	    if (isset($all_data['pireps'])) {
1313
+		if (isset($all_data['pireps'])) {
1314 1314
 		$reset = 0;
1315
-	        foreach ($all_data['pireps'] as $line) {
1316
-		    $data = array();
1317
-		    $data['id'] = $line['id'];
1318
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1319
-		    $data['ident'] = $line['callsign']; // ident
1320
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1321
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1322
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1323
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1324
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1325
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1326
-		    $data['latitude'] = $line['lat']; // lat
1327
-		    $data['longitude'] = $line['lon']; // long
1328
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1329
-		    //$data['squawk'] = $line['squawk']; // squawk
1330
-		    //$data['emergency'] = ''; // emergency
1331
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1332
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1333
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1334
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1335
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1336
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1337
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1338
-		    else $data['info'] = '';
1339
-		    $data['format_source'] = 'pireps';
1340
-    		    $data['id_source'] = $id_source;
1341
-		    $data['datetime'] = date('Y-m-d H:i:s');
1342
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1343
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1344
-		    if ($line['icon'] === 'plane') {
1315
+			foreach ($all_data['pireps'] as $line) {
1316
+			$data = array();
1317
+			$data['id'] = $line['id'];
1318
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1319
+			$data['ident'] = $line['callsign']; // ident
1320
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1321
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1322
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1323
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1324
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1325
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1326
+			$data['latitude'] = $line['lat']; // lat
1327
+			$data['longitude'] = $line['lon']; // long
1328
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1329
+			//$data['squawk'] = $line['squawk']; // squawk
1330
+			//$data['emergency'] = ''; // emergency
1331
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1332
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1333
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1334
+			//$data['arrival_airport_time'] = $line['arrtime'];
1335
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1336
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1337
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1338
+			else $data['info'] = '';
1339
+			$data['format_source'] = 'pireps';
1340
+				$data['id_source'] = $id_source;
1341
+			$data['datetime'] = date('Y-m-d H:i:s');
1342
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1343
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1344
+			if ($line['icon'] === 'plane') {
1345 1345
 			$SI->add($data);
1346
-		    //    print_r($data);
1347
-    		    } elseif ($line['icon'] === 'ct') {
1346
+			//    print_r($data);
1347
+				} elseif ($line['icon'] === 'ct') {
1348 1348
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1349 1349
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1350 1350
 			$typec = substr($data['ident'],-3);
@@ -1359,209 +1359,209 @@  discard block
 block discarded – undo
1359 1359
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1360 1360
 			else $data['type'] = 'Observer';
1361 1361
 			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']);
1362
-		    }
1363
-		    unset($data);
1362
+			}
1363
+			unset($data);
1364 1364
 		}
1365
-	    }
1366
-	    //$last_exec['pirepsjson'] = time();
1367
-	    $last_exec[$id]['last'] = time();
1365
+		}
1366
+		//$last_exec['pirepsjson'] = time();
1367
+		$last_exec[$id]['last'] = time();
1368 1368
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1369 1369
 	} elseif ($value['format'] === 'phpvmacars' && 
1370
-	    (
1370
+		(
1371 1371
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1372 1372
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1373
-	    )
1373
+		)
1374 1374
 	) {
1375
-	    //$buffer = $Common->getData($hosts[$id]);
1376
-	    if ($globalDebug) echo 'Get Data...'."\n";
1377
-	    $buffer = $Common->getData($value['host']);
1378
-	    $all_data = json_decode($buffer,true);
1379
-	    if ($buffer != '' && is_array($all_data)) {
1375
+		//$buffer = $Common->getData($hosts[$id]);
1376
+		if ($globalDebug) echo 'Get Data...'."\n";
1377
+		$buffer = $Common->getData($value['host']);
1378
+		$all_data = json_decode($buffer,true);
1379
+		if ($buffer != '' && is_array($all_data)) {
1380 1380
 		$reset = 0;
1381 1381
 		foreach ($all_data as $line) {
1382
-	    	    $data = array();
1383
-	    	    //$data['id'] = $line['id']; // id not usable
1384
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1385
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1386
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1387
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1388
-	    	    $data['ident'] = $line['flightnum']; // ident
1389
-	    	    $data['altitude'] = $line['alt']; // altitude
1390
-	    	    $data['speed'] = $line['gs']; // speed
1391
-	    	    $data['heading'] = $line['heading']; // heading
1392
-	    	    $data['latitude'] = $line['lat']; // lat
1393
-	    	    $data['longitude'] = $line['lng']; // long
1394
-	    	    $data['verticalrate'] = ''; // verticale rate
1395
-	    	    $data['squawk'] = ''; // squawk
1396
-	    	    $data['emergency'] = ''; // emergency
1397
-	    	    //$data['datetime'] = $line['lastupdate'];
1398
-	    	    //$data['last_update'] = $line['lastupdate'];
1399
-	    	    if (isset($value['timezone'])) {
1400
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1401
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1402
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1403
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1404
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1405
-	    	    $data['departure_airport_time'] = $line['deptime'];
1406
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1407
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1408
-    		    if (isset($line['registration'])) {
1409
-    			$data['registration'] = $line['registration'];
1410
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1411
-    		    } else $data['registration'] = $line['aircraft'];
1412
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1413
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1414
-		    if (isset($line['aircraftname'])) {
1382
+				$data = array();
1383
+				//$data['id'] = $line['id']; // id not usable
1384
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1385
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1386
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1387
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1388
+				$data['ident'] = $line['flightnum']; // ident
1389
+				$data['altitude'] = $line['alt']; // altitude
1390
+				$data['speed'] = $line['gs']; // speed
1391
+				$data['heading'] = $line['heading']; // heading
1392
+				$data['latitude'] = $line['lat']; // lat
1393
+				$data['longitude'] = $line['lng']; // long
1394
+				$data['verticalrate'] = ''; // verticale rate
1395
+				$data['squawk'] = ''; // squawk
1396
+				$data['emergency'] = ''; // emergency
1397
+				//$data['datetime'] = $line['lastupdate'];
1398
+				//$data['last_update'] = $line['lastupdate'];
1399
+				if (isset($value['timezone'])) {
1400
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1401
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1402
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1403
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1404
+				$data['departure_airport_icao'] = $line['depicao'];
1405
+				$data['departure_airport_time'] = $line['deptime'];
1406
+				$data['arrival_airport_icao'] = $line['arricao'];
1407
+				$data['arrival_airport_time'] = $line['arrtime'];
1408
+				if (isset($line['registration'])) {
1409
+				$data['registration'] = $line['registration'];
1410
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1411
+				} else $data['registration'] = $line['aircraft'];
1412
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1413
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1414
+			if (isset($line['aircraftname'])) {
1415 1415
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1416 1416
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1417
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1418
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1419
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1420
-	    		else {
1421
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1422
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1423
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1424
-	    		}
1425
-	    	    }
1426
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1427
-    		    $data['id_source'] = $id_source;
1428
-	    	    $data['format_source'] = 'phpvmacars';
1429
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1430
-		    $SI->add($data);
1431
-		    unset($data);
1417
+				$aircraft_data = explode('-',$line['aircraftname']);
1418
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1419
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1420
+				else {
1421
+					$aircraft_data = explode(' ',$line['aircraftname']);
1422
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1423
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1424
+				}
1425
+				}
1426
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1427
+				$data['id_source'] = $id_source;
1428
+				$data['format_source'] = 'phpvmacars';
1429
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1430
+			$SI->add($data);
1431
+			unset($data);
1432 1432
 		}
1433 1433
 		if ($globalDebug) echo 'No more data...'."\n";
1434 1434
 		unset($buffer);
1435 1435
 		unset($all_data);
1436
-	    }
1437
-	    //$last_exec['phpvmacars'] = time();
1438
-	    $last_exec[$id]['last'] = time();
1436
+		}
1437
+		//$last_exec['phpvmacars'] = time();
1438
+		$last_exec[$id]['last'] = time();
1439 1439
 	} elseif ($value['format'] === 'vaos' && 
1440
-	    (
1440
+		(
1441 1441
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1442 1442
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1443
-	    )
1443
+		)
1444 1444
 	) {
1445
-	    //$buffer = $Common->getData($hosts[$id]);
1446
-	    if ($globalDebug) echo 'Get Data...'."\n";
1447
-	    $buffer = $Common->getData($value['host']);
1448
-	    $all_data = json_decode($buffer,true);
1449
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1445
+		//$buffer = $Common->getData($hosts[$id]);
1446
+		if ($globalDebug) echo 'Get Data...'."\n";
1447
+		$buffer = $Common->getData($value['host']);
1448
+		$all_data = json_decode($buffer,true);
1449
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1450 1450
 		$reset = 0;
1451 1451
 		foreach ($all_data['ACARSData'] as $line) {
1452
-		    //print_r($line);
1453
-	    	    $data = array();
1454
-	    	    //$data['id'] = $line['id']; // id not usable
1455
-	    	    $data['id'] = $line['id'];
1456
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1457
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1458
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1459
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1460
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1461
-	    	    $data['altitude'] = $line['altitude']; // altitude
1462
-	    	    $data['speed'] = $line['groundspeed']; // speed
1463
-	    	    $data['heading'] = $line['heading']; // heading
1464
-	    	    $data['latitude'] = $line['lat']; // lat
1465
-	    	    $data['longitude'] = $line['lon']; // long
1466
-	    	    //$data['verticalrate'] = ''; // verticale rate
1467
-	    	    //$data['squawk'] = ''; // squawk
1468
-	    	    //$data['emergency'] = ''; // emergency
1469
-	    	    if (isset($value['timezone'])) {
1470
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1471
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1472
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1473
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1452
+			//print_r($line);
1453
+				$data = array();
1454
+				//$data['id'] = $line['id']; // id not usable
1455
+				$data['id'] = $line['id'];
1456
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1457
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1458
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1459
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1460
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1461
+				$data['altitude'] = $line['altitude']; // altitude
1462
+				$data['speed'] = $line['groundspeed']; // speed
1463
+				$data['heading'] = $line['heading']; // heading
1464
+				$data['latitude'] = $line['lat']; // lat
1465
+				$data['longitude'] = $line['lon']; // long
1466
+				//$data['verticalrate'] = ''; // verticale rate
1467
+				//$data['squawk'] = ''; // squawk
1468
+				//$data['emergency'] = ''; // emergency
1469
+				if (isset($value['timezone'])) {
1470
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1471
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1472
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1473
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1474 1474
 	    	    
1475
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1476
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1477
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1478
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1479
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1475
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1476
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1477
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1478
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1479
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1480 1480
 
1481
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1482
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1483
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1481
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1482
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1483
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1484 1484
 
1485
-    		    $data['id_source'] = $id_source;
1486
-	    	    $data['format_source'] = 'vaos';
1487
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1488
-		    $SI->add($data);
1489
-		    unset($data);
1485
+				$data['id_source'] = $id_source;
1486
+				$data['format_source'] = 'vaos';
1487
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1488
+			$SI->add($data);
1489
+			unset($data);
1490 1490
 		}
1491 1491
 		if ($globalDebug) echo 'No more data...'."\n";
1492 1492
 		unset($buffer);
1493 1493
 		unset($all_data);
1494
-	    }
1495
-	    //$last_exec['phpvmacars'] = time();
1496
-	    $last_exec[$id]['last'] = time();
1494
+		}
1495
+		//$last_exec['phpvmacars'] = time();
1496
+		$last_exec[$id]['last'] = time();
1497 1497
 	} elseif ($value['format'] === 'vam' && 
1498
-	    (
1498
+		(
1499 1499
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1500 1500
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1501
-	    )
1501
+		)
1502 1502
 	) {
1503
-	    //$buffer = $Common->getData($hosts[$id]);
1504
-	    if ($globalDebug) echo 'Get Data...'."\n";
1505
-	    $buffer = $Common->getData($value['host']);
1506
-	    $all_data = json_decode($buffer,true);
1507
-	    if ($buffer != '' && is_array($all_data)) {
1503
+		//$buffer = $Common->getData($hosts[$id]);
1504
+		if ($globalDebug) echo 'Get Data...'."\n";
1505
+		$buffer = $Common->getData($value['host']);
1506
+		$all_data = json_decode($buffer,true);
1507
+		if ($buffer != '' && is_array($all_data)) {
1508 1508
 		$reset = 0;
1509 1509
 		foreach ($all_data as $line) {
1510
-	    	    $data = array();
1511
-	    	    //$data['id'] = $line['id']; // id not usable
1512
-	    	    $data['id'] = trim($line['flight_id']);
1513
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1514
-	    	    $data['pilot_name'] = $line['pilot_name'];
1515
-	    	    $data['pilot_id'] = $line['pilot_id'];
1516
-	    	    $data['ident'] = trim($line['callsign']); // ident
1517
-	    	    $data['altitude'] = $line['altitude']; // altitude
1518
-	    	    $data['speed'] = $line['gs']; // speed
1519
-	    	    $data['heading'] = $line['heading']; // heading
1520
-	    	    $data['latitude'] = $line['latitude']; // lat
1521
-	    	    $data['longitude'] = $line['longitude']; // long
1522
-	    	    $data['verticalrate'] = ''; // verticale rate
1523
-	    	    $data['squawk'] = ''; // squawk
1524
-	    	    $data['emergency'] = ''; // emergency
1525
-	    	    //$data['datetime'] = $line['lastupdate'];
1526
-	    	    $data['last_update'] = $line['last_update'];
1527
-		    $data['datetime'] = date('Y-m-d H:i:s');
1528
-	    	    $data['departure_airport_icao'] = $line['departure'];
1529
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1530
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1531
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1532
-    		    //$data['registration'] = $line['aircraft'];
1533
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1534
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1535
-    		    $data['id_source'] = $id_source;
1536
-	    	    $data['format_source'] = 'vam';
1537
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1538
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1539
-		    $SI->add($data);
1540
-		    unset($data);
1510
+				$data = array();
1511
+				//$data['id'] = $line['id']; // id not usable
1512
+				$data['id'] = trim($line['flight_id']);
1513
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1514
+				$data['pilot_name'] = $line['pilot_name'];
1515
+				$data['pilot_id'] = $line['pilot_id'];
1516
+				$data['ident'] = trim($line['callsign']); // ident
1517
+				$data['altitude'] = $line['altitude']; // altitude
1518
+				$data['speed'] = $line['gs']; // speed
1519
+				$data['heading'] = $line['heading']; // heading
1520
+				$data['latitude'] = $line['latitude']; // lat
1521
+				$data['longitude'] = $line['longitude']; // long
1522
+				$data['verticalrate'] = ''; // verticale rate
1523
+				$data['squawk'] = ''; // squawk
1524
+				$data['emergency'] = ''; // emergency
1525
+				//$data['datetime'] = $line['lastupdate'];
1526
+				$data['last_update'] = $line['last_update'];
1527
+			$data['datetime'] = date('Y-m-d H:i:s');
1528
+				$data['departure_airport_icao'] = $line['departure'];
1529
+				//$data['departure_airport_time'] = $line['departure_time'];
1530
+				$data['arrival_airport_icao'] = $line['arrival'];
1531
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1532
+				//$data['registration'] = $line['aircraft'];
1533
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1534
+				$data['aircraft_icao'] = $line['plane_type'];
1535
+				$data['id_source'] = $id_source;
1536
+				$data['format_source'] = 'vam';
1537
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1538
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1539
+			$SI->add($data);
1540
+			unset($data);
1541 1541
 		}
1542 1542
 		if ($globalDebug) echo 'No more data...'."\n";
1543 1543
 		unset($buffer);
1544 1544
 		unset($all_data);
1545
-	    }
1546
-	    //$last_exec['phpvmacars'] = time();
1547
-	    $last_exec[$id]['last'] = time();
1545
+		}
1546
+		//$last_exec['phpvmacars'] = time();
1547
+		$last_exec[$id]['last'] = time();
1548 1548
 	} elseif ($value['format'] === 'blitzortung' && 
1549
-	    (
1549
+		(
1550 1550
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1551 1551
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1552
-	    )
1552
+		)
1553 1553
 	) {
1554
-	    //$buffer = $Common->getData($hosts[$id]);
1555
-	    if ($globalDebug) echo 'Get Data...'."\n";
1556
-	    $buffer = $Common->getData($value['host']);
1557
-	    $all_data = json_decode($buffer,true);
1558
-	    if ($buffer != '') {
1554
+		//$buffer = $Common->getData($hosts[$id]);
1555
+		if ($globalDebug) echo 'Get Data...'."\n";
1556
+		$buffer = $Common->getData($value['host']);
1557
+		$all_data = json_decode($buffer,true);
1558
+		if ($buffer != '') {
1559 1559
 		$Source->deleteLocationBySource('blitzortung');
1560 1560
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1561 1561
 		$buffer = explode('\n',$buffer);
1562 1562
 		foreach ($buffer as $buffer_line) {
1563
-		    $line = json_decode($buffer_line,true);
1564
-		    if (isset($line['time'])) {
1563
+			$line = json_decode($buffer_line,true);
1564
+			if (isset($line['time'])) {
1565 1565
 			$data = array();
1566 1566
 			$data['altitude'] = $line['alt']; // altitude
1567 1567
 			$data['latitude'] = $line['lat']; // lat
@@ -1573,94 +1573,94 @@  discard block
 block discarded – undo
1573 1573
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1574 1574
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1575 1575
 			unset($data);
1576
-		    }
1576
+			}
1577 1577
 		}
1578 1578
 		if ($globalDebug) echo 'No more data...'."\n";
1579 1579
 		unset($buffer);
1580
-	    }
1581
-	    $last_exec[$id]['last'] = time();
1580
+		}
1581
+		$last_exec[$id]['last'] = time();
1582 1582
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1583 1583
 	} 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') {
1584
-	    //$last_exec[$id]['last'] = time();
1585
-	    //$read = array( $sockets[$id] );
1586
-	    $read = $sockets;
1587
-	    $write = NULL;
1588
-	    $e = NULL;
1589
-	    $n = socket_select($read, $write, $e, $timeout);
1590
-	    if ($e != NULL) var_dump($e);
1591
-	    if ($n > 0) {
1584
+		//$last_exec[$id]['last'] = time();
1585
+		//$read = array( $sockets[$id] );
1586
+		$read = $sockets;
1587
+		$write = NULL;
1588
+		$e = NULL;
1589
+		$n = socket_select($read, $write, $e, $timeout);
1590
+		if ($e != NULL) var_dump($e);
1591
+		if ($n > 0) {
1592 1592
 		$reset = 0;
1593 1593
 		foreach ($read as $nb => $r) {
1594
-		    //$value = $formats[$nb];
1595
-		    $format = $globalSources[$nb]['format'];
1596
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1594
+			//$value = $formats[$nb];
1595
+			$format = $globalSources[$nb]['format'];
1596
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1597 1597
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1598
-		    } elseif ($format === 'vrstcp') {
1598
+			} elseif ($format === 'vrstcp') {
1599 1599
 			$buffer = @socket_read($r, 6000);
1600
-		    } else {
1600
+			} else {
1601 1601
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1602
-		    }
1603
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1604
-		    //echo $buffer."\n";
1605
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1606
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1607
-		    $error = false;
1608
-		    //$SI::del();
1609
-		    if ($buffer !== FALSE) {
1602
+			}
1603
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1604
+			//echo $buffer."\n";
1605
+			// lets play nice and handle signals such as ctrl-c/kill properly
1606
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1607
+			$error = false;
1608
+			//$SI::del();
1609
+			if ($buffer !== FALSE) {
1610 1610
 			if ($format === 'vrstcp') {
1611
-			    $buffer = explode('},{',$buffer);
1611
+				$buffer = explode('},{',$buffer);
1612 1612
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1613
-		    }
1614
-		    // SBS format is CSV format
1615
-		    if ($buffer !== FALSE && $buffer !== '') {
1613
+			}
1614
+			// SBS format is CSV format
1615
+			if ($buffer !== FALSE && $buffer !== '') {
1616 1616
 			$tt[$format] = 0;
1617 1617
 			if ($format === 'acarssbs3') {
1618
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1619
-			    $ACARS->add(trim($buffer));
1620
-			    $ACARS->deleteLiveAcarsData();
1618
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1619
+				$ACARS->add(trim($buffer));
1620
+				$ACARS->deleteLiveAcarsData();
1621 1621
 			} elseif ($format === 'raw') {
1622
-			    // AVR format
1623
-			    $data = $SBS->parse($buffer);
1624
-			    if (is_array($data)) {
1622
+				// AVR format
1623
+				$data = $SBS->parse($buffer);
1624
+				if (is_array($data)) {
1625 1625
 				$data['datetime'] = date('Y-m-d H:i:s');
1626 1626
 				$data['format_source'] = 'raw';
1627 1627
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1628 1628
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1629 1629
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1630 1630
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1631
-			    }
1631
+				}
1632 1632
 			} elseif ($format === 'ais') {
1633
-			    $ais_data = $AIS->parse_line(trim($buffer));
1634
-			    $data = array();
1635
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1636
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1637
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1638
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1639
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1640
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1641
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1642
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1643
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1644
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1645
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1646
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1647
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1648
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1649
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1650
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1633
+				$ais_data = $AIS->parse_line(trim($buffer));
1634
+				$data = array();
1635
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1636
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1637
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1638
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1639
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1640
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1641
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1642
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1643
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1644
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1645
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1646
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1647
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1648
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1649
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1650
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1651 1651
 
1652
-			    if (isset($ais_data['timestamp'])) {
1652
+				if (isset($ais_data['timestamp'])) {
1653 1653
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1654
-			    } else {
1654
+				} else {
1655 1655
 				$data['datetime'] = date('Y-m-d H:i:s');
1656
-			    }
1657
-			    $data['format_source'] = 'aisnmea';
1658
-    			    $data['id_source'] = $id_source;
1659
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1660
-			    unset($data);
1661
-                        } elseif ($format === 'flightgearsp') {
1662
-                    	    //echo $buffer."\n";
1663
-                    	    if (strlen($buffer) > 5) {
1656
+				}
1657
+				$data['format_source'] = 'aisnmea';
1658
+					$data['id_source'] = $id_source;
1659
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1660
+				unset($data);
1661
+						} elseif ($format === 'flightgearsp') {
1662
+							//echo $buffer."\n";
1663
+							if (strlen($buffer) > 5) {
1664 1664
 				$line = explode(',',$buffer);
1665 1665
 				$data = array();
1666 1666
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1677,38 +1677,38 @@  discard block
 block discarded – undo
1677 1677
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1678 1678
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1679 1679
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1680
-			    }
1681
-                        } elseif ($format === 'acars') {
1682
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1683
-			    $ACARS->add(trim($buffer));
1684
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1685
-			    $ACARS->deleteLiveAcarsData();
1680
+				}
1681
+						} elseif ($format === 'acars') {
1682
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1683
+				$ACARS->add(trim($buffer));
1684
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1685
+				$ACARS->deleteLiveAcarsData();
1686 1686
 			} elseif ($format === 'flightgearmp') {
1687
-			    if (substr($buffer,0,1) != '#') {
1687
+				if (substr($buffer,0,1) != '#') {
1688 1688
 				$data = array();
1689 1689
 				//echo $buffer."\n";
1690 1690
 				$line = explode(' ',$buffer);
1691 1691
 				if (count($line) === 11) {
1692
-				    $userserver = explode('@',$line[0]);
1693
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1694
-				    $data['ident'] = $userserver[0];
1695
-				    $data['registration'] = $userserver[0];
1696
-				    $data['latitude'] = $line[4];
1697
-				    $data['longitude'] = $line[5];
1698
-				    $data['altitude'] = $line[6];
1699
-				    $data['datetime'] = date('Y-m-d H:i:s');
1700
-				    $aircraft_type = $line[10];
1701
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1702
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1703
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1704
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1692
+					$userserver = explode('@',$line[0]);
1693
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1694
+					$data['ident'] = $userserver[0];
1695
+					$data['registration'] = $userserver[0];
1696
+					$data['latitude'] = $line[4];
1697
+					$data['longitude'] = $line[5];
1698
+					$data['altitude'] = $line[6];
1699
+					$data['datetime'] = date('Y-m-d H:i:s');
1700
+					$aircraft_type = $line[10];
1701
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1702
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1703
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1704
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1705
+				}
1705 1706
 				}
1706
-			    }
1707 1707
 			} elseif ($format === 'beast') {
1708
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1709
-			    die;
1708
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1709
+				die;
1710 1710
 			} elseif ($format === 'vrstcp') {
1711
-			    foreach($buffer as $all_data) {
1711
+				foreach($buffer as $all_data) {
1712 1712
 				$line = json_decode('{'.$all_data.'}',true);
1713 1713
 				$data = array();
1714 1714
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1728,158 +1728,158 @@  discard block
 block discarded – undo
1728 1728
 				*/
1729 1729
 				$data['datetime'] = date('Y-m-d H:i:s');
1730 1730
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1731
-		    		$data['format_source'] = 'vrstcp';
1731
+					$data['format_source'] = 'vrstcp';
1732 1732
 				$data['id_source'] = $id_source;
1733 1733
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1734 1734
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1735 1735
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1736 1736
 				unset($data);
1737
-			    }
1737
+				}
1738 1738
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1739
-			    $line = explode("\t", $buffer);
1740
-			    for($k = 0; $k < count($line); $k=$k+2) {
1739
+				$line = explode("\t", $buffer);
1740
+				for($k = 0; $k < count($line); $k=$k+2) {
1741 1741
 				$key = $line[$k];
1742
-			        $lined[$key] = $line[$k+1];
1743
-			    }
1744
-    			    if (count($lined) > 3) {
1745
-    				$data['hex'] = $lined['hexid'];
1746
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1747
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1748
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1749
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1750
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1751
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1752
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1753
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1754
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1755
-    				$data['id_source'] = $id_source;
1756
-    				$data['format_source'] = 'tsv';
1757
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1758
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1742
+					$lined[$key] = $line[$k+1];
1743
+				}
1744
+					if (count($lined) > 3) {
1745
+					$data['hex'] = $lined['hexid'];
1746
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1747
+					$data['datetime'] = date('Y-m-d H:i:s');;
1748
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1749
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1750
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1751
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1752
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1753
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1754
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1755
+					$data['id_source'] = $id_source;
1756
+					$data['format_source'] = 'tsv';
1757
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1758
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1759 1759
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1760
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1761
-    				unset($lined);
1762
-    				unset($data);
1763
-    			    } else $error = true;
1760
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1761
+					unset($lined);
1762
+					unset($data);
1763
+					} else $error = true;
1764 1764
 			} elseif ($format === 'aprs' && $use_aprs) {
1765
-			    if ($aprs_connect === 0) {
1765
+				if ($aprs_connect === 0) {
1766 1766
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1767 1767
 				$aprs_connect = 1;
1768
-			    }
1768
+				}
1769 1769
 			    
1770
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1770
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1771 1771
 				$aprs_last_tx = time();
1772 1772
 				$data_aprs = "# Keep alive";
1773 1773
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1774
-			    }
1774
+				}
1775 1775
 			    
1776
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1777
-			    //echo 'APRS data : '.$buffer."\n";
1778
-			    $buffer = str_replace('APRS <- ','',$buffer);
1779
-			    $buffer = str_replace('APRS -> ','',$buffer);
1780
-			    //echo $buffer."\n";
1781
-			    date_default_timezone_set('UTC');
1782
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1776
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1777
+				//echo 'APRS data : '.$buffer."\n";
1778
+				$buffer = str_replace('APRS <- ','',$buffer);
1779
+				$buffer = str_replace('APRS -> ','',$buffer);
1780
+				//echo $buffer."\n";
1781
+				date_default_timezone_set('UTC');
1782
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1783 1783
 				$line = $APRS->parse($buffer);
1784 1784
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1785 1785
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1786
-				    $aprs_last_tx = time();
1787
-				    $data = array();
1788
-				    //print_r($line);
1789
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1790
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1791
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1792
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1793
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1794
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1795
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1796
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1797
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1798
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1799
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1800
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1801
-				    $data['latitude'] = $line['latitude'];
1802
-				    $data['longitude'] = $line['longitude'];
1803
-				    //$data['verticalrate'] = $line[16];
1804
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1805
-				    //else $data['speed'] = 0;
1806
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1807
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1808
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1809
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1786
+					$aprs_last_tx = time();
1787
+					$data = array();
1788
+					//print_r($line);
1789
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1790
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1791
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1792
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1793
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1794
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1795
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1796
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1797
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1798
+					else $data['datetime'] = date('Y-m-d H:i:s');
1799
+					//$data['datetime'] = date('Y-m-d H:i:s');
1800
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1801
+					$data['latitude'] = $line['latitude'];
1802
+					$data['longitude'] = $line['longitude'];
1803
+					//$data['verticalrate'] = $line[16];
1804
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1805
+					//else $data['speed'] = 0;
1806
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1807
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1808
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1809
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1810 1810
 				    
1811
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1812
-				    //else echo 'No heading...'."\n";
1813
-				    //else $data['heading'] = 0;
1814
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1815
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1816
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1817
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1818
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1819
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1820
-    				    $data['id_source'] = $id_source;
1821
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1822
-				    else $data['format_source'] = 'aprs';
1823
-				    $data['source_name'] = $line['source'];
1824
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1825
-				    else $data['source_type'] = 'flarm';
1826
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1827
-				    $currentdate = date('Y-m-d H:i:s');
1828
-				    $aprsdate = strtotime($data['datetime']);
1829
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1830
-				    // Accept data if time <= system time + 20s
1831
-				    //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'])))) {
1832
-				    if (
1811
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1812
+					//else echo 'No heading...'."\n";
1813
+					//else $data['heading'] = 0;
1814
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1815
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1816
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1817
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1818
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1819
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1820
+						$data['id_source'] = $id_source;
1821
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1822
+					else $data['format_source'] = 'aprs';
1823
+					$data['source_name'] = $line['source'];
1824
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1825
+					else $data['source_type'] = 'flarm';
1826
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1827
+					$currentdate = date('Y-m-d H:i:s');
1828
+					$aprsdate = strtotime($data['datetime']);
1829
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1830
+					// Accept data if time <= system time + 20s
1831
+					//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'])))) {
1832
+					if (
1833 1833
 					($data['source_type'] === 'modes') || 
1834 1834
 					isset($line['stealth']) && 
1835 1835
 					(!isset($data['hex']) || $data['hex'] != 'FFFFFF') && 
1836 1836
 					 ($line['stealth'] === 0 || $line['stealth'] == '') && 
1837 1837
 					 (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1838 1838
 					$send = $SI->add($data);
1839
-				    } elseif ($data['source_type'] === 'ais') {
1839
+					} elseif ($data['source_type'] === 'ais') {
1840 1840
 					$data['type'] = '';
1841 1841
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1842
-				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1842
+					} elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1843 1843
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1844
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1845
-					    //$line['symbol'] === 'Balloon' ||
1846
-					    $line['symbol'] === 'Glider' || 
1847
-					    $line['symbol'] === 'No. Plane' || 
1848
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1849
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1850
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1851
-					    $send = $SI->add($data);
1852
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1853
-					    $line['symbol'] === 'Yacht (Sail)' || 
1854
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1855
-					    $send = $MI->add($data);
1856
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1857
-					    $line['symbol'] === 'Car' || 
1858
-					    $line['symbol'] === 'Ambulance' || 
1859
-					    $line['symbol'] === 'Van' || 
1860
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1861
-					    $line['symbol'] === 'Motorcycle' || 
1862
-					    $line['symbol'] === 'Tractor' || 
1863
-					    $line['symbol'] === 'Police' || 
1864
-					    $line['symbol'] === 'Bike' || 
1865
-					    $line['symbol'] === 'Jogger' || 
1866
-					    $line['symbol'] === 'Horse' || 
1867
-					    $line['symbol'] === 'Bus' || 
1868
-					    $line['symbol'] === 'Jeep' || 
1869
-					    $line['symbol'] === 'Recreational Vehicle' || 
1870
-					    $line['symbol'] === 'Yacht (Sail)' || 
1871
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1872
-					    $line['symbol'] === 'Firetruck' || 
1873
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1874
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1875
-					    $line['symbol'] === 'SUV' ||
1876
-					    $line['symbol'] === 'Snowmobile' ||
1877
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1878
-				    //} 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') {
1844
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1845
+						//$line['symbol'] === 'Balloon' ||
1846
+						$line['symbol'] === 'Glider' || 
1847
+						$line['symbol'] === 'No. Plane' || 
1848
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1849
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1850
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1851
+						$send = $SI->add($data);
1852
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1853
+						$line['symbol'] === 'Yacht (Sail)' || 
1854
+						$line['symbol'] === 'Ship (Power Boat)')) {
1855
+						$send = $MI->add($data);
1856
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1857
+						$line['symbol'] === 'Car' || 
1858
+						$line['symbol'] === 'Ambulance' || 
1859
+						$line['symbol'] === 'Van' || 
1860
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1861
+						$line['symbol'] === 'Motorcycle' || 
1862
+						$line['symbol'] === 'Tractor' || 
1863
+						$line['symbol'] === 'Police' || 
1864
+						$line['symbol'] === 'Bike' || 
1865
+						$line['symbol'] === 'Jogger' || 
1866
+						$line['symbol'] === 'Horse' || 
1867
+						$line['symbol'] === 'Bus' || 
1868
+						$line['symbol'] === 'Jeep' || 
1869
+						$line['symbol'] === 'Recreational Vehicle' || 
1870
+						$line['symbol'] === 'Yacht (Sail)' || 
1871
+						$line['symbol'] === 'Ship (Power Boat)' || 
1872
+						$line['symbol'] === 'Firetruck' || 
1873
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1874
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1875
+						$line['symbol'] === 'SUV' ||
1876
+						$line['symbol'] === 'Snowmobile' ||
1877
+						$line['symbol'] === 'Mobile Satellite Station')) {
1878
+					//} 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') {
1879 1879
 				//    } 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') {
1880 1880
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1881 1881
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1882
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1882
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1883 1883
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1884 1884
 					$Source->deleteOldLocationByType('gs');
1885 1885
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1887,7 +1887,7 @@  discard block
 block discarded – undo
1887 1887
 					} else {
1888 1888
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1889 1889
 					}
1890
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1890
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1891 1891
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1892 1892
 					if ($globalDebug) echo '# Weather Station added'."\n";
1893 1893
 					$Source->deleteOldLocationByType('wx');
@@ -1897,7 +1897,7 @@  discard block
 block discarded – undo
1897 1897
 					} else {
1898 1898
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1899 1899
 					}
1900
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1900
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1901 1901
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1902 1902
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1903 1903
 					$Source->deleteOldLocationByType('lightning');
@@ -1906,11 +1906,11 @@  discard block
 block discarded – undo
1906 1906
 					} else {
1907 1907
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1908 1908
 					}
1909
-				    } elseif ($globalDebug) {
1910
-				    	echo '/!\ Not added: '.$buffer."\n";
1911
-				    	print_r($line);
1912
-				    }
1913
-				    unset($data);
1909
+					} elseif ($globalDebug) {
1910
+						echo '/!\ Not added: '.$buffer."\n";
1911
+						print_r($line);
1912
+					}
1913
+					unset($data);
1914 1914
 				}
1915 1915
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1916 1916
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1929,12 +1929,12 @@  discard block
 block discarded – undo
1929 1929
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1930 1930
 					$globalSources[$nb]['last_weather_clean'] = time();
1931 1931
 				}
1932
-			    }
1932
+				}
1933 1933
 			} else {
1934
-			    $line = explode(',', $buffer);
1935
-    			    if (count($line) > 20) {
1936
-    			    	$data['hex'] = $line[4];
1937
-    				/*
1934
+				$line = explode(',', $buffer);
1935
+					if (count($line) > 20) {
1936
+						$data['hex'] = $line[4];
1937
+					/*
1938 1938
     				$data['datetime'] = $line[6].' '.$line[7];
1939 1939
     					date_default_timezone_set($globalTimezone);
1940 1940
     					$datetime = new DateTime($data['datetime']);
@@ -1942,31 +1942,31 @@  discard block
 block discarded – undo
1942 1942
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1943 1943
     					date_default_timezone_set('UTC');
1944 1944
     				*/
1945
-    				// Force datetime to current UTC datetime
1946
-    				date_default_timezone_set('UTC');
1947
-    				$data['datetime'] = date('Y-m-d H:i:s');
1948
-    				$data['ident'] = trim($line[10]);
1949
-    				$data['latitude'] = $line[14];
1950
-    				$data['longitude'] = $line[15];
1951
-    				$data['verticalrate'] = $line[16];
1952
-    				$data['emergency'] = $line[20];
1953
-    				$data['speed'] = $line[12];
1954
-    				$data['squawk'] = $line[17];
1955
-    				$data['altitude'] = $line[11];
1956
-    				$data['heading'] = $line[13];
1957
-    				$data['ground'] = $line[21];
1958
-    				$data['emergency'] = $line[19];
1959
-    				$data['format_source'] = 'sbs';
1945
+					// Force datetime to current UTC datetime
1946
+					date_default_timezone_set('UTC');
1947
+					$data['datetime'] = date('Y-m-d H:i:s');
1948
+					$data['ident'] = trim($line[10]);
1949
+					$data['latitude'] = $line[14];
1950
+					$data['longitude'] = $line[15];
1951
+					$data['verticalrate'] = $line[16];
1952
+					$data['emergency'] = $line[20];
1953
+					$data['speed'] = $line[12];
1954
+					$data['squawk'] = $line[17];
1955
+					$data['altitude'] = $line[11];
1956
+					$data['heading'] = $line[13];
1957
+					$data['ground'] = $line[21];
1958
+					$data['emergency'] = $line[19];
1959
+					$data['format_source'] = 'sbs';
1960 1960
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1961 1961
 				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
1962
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1962
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1963 1963
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1964
-    				$data['id_source'] = $id_source;
1965
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1966
-    				else $error = true;
1967
-    				unset($data);
1968
-    			    } else $error = true;
1969
-			    if ($error) {
1964
+					$data['id_source'] = $id_source;
1965
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1966
+					else $error = true;
1967
+					unset($data);
1968
+					} else $error = true;
1969
+				if ($error) {
1970 1970
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1971 1971
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1972 1972
 				} else {
@@ -1982,13 +1982,13 @@  discard block
 block discarded – undo
1982 1982
 					connect_all($sourceer);
1983 1983
 					$sourceer = array();
1984 1984
 				}
1985
-			    }
1985
+				}
1986 1986
 			}
1987 1987
 			// Sleep for xxx microseconds
1988 1988
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1989
-		    } else {
1989
+			} else {
1990 1990
 			if ($format === 'flightgearmp') {
1991
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1991
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1992 1992
 				//@socket_close($r);
1993 1993
 				sleep($globalMinFetch);
1994 1994
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1997,9 +1997,9 @@  discard block
 block discarded – undo
1997 1997
 				break;
1998 1998
 				
1999 1999
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2000
-			    if (isset($tt[$format])) $tt[$format]++;
2001
-			    else $tt[$format] = 0;
2002
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
2000
+				if (isset($tt[$format])) $tt[$format]++;
2001
+				else $tt[$format] = 0;
2002
+				if ($tt[$format] > 30 || $buffer === FALSE) {
2003 2003
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2004 2004
 				//@socket_close($r);
2005 2005
 				sleep(2);
@@ -2010,24 +2010,24 @@  discard block
 block discarded – undo
2010 2010
 				//connect_all($globalSources);
2011 2011
 				$tt[$format]=0;
2012 2012
 				break;
2013
-			    } 
2014
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2013
+				} 
2014
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2015
+			}
2015 2016
 			}
2016
-		    }
2017 2017
 		}
2018
-	    } else {
2018
+		} else {
2019 2019
 		$error = socket_strerror(socket_last_error());
2020 2020
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2021 2021
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2022 2022
 			if (isset($globalDebug)) echo "Restarting...\n";
2023 2023
 			// Restart the script if possible
2024 2024
 			if (is_array($sockets)) {
2025
-			    if ($globalDebug) echo "Shutdown all sockets...";
2025
+				if ($globalDebug) echo "Shutdown all sockets...";
2026 2026
 			    
2027
-			    foreach ($sockets as $sock) {
2027
+				foreach ($sockets as $sock) {
2028 2028
 				@socket_shutdown($sock,2);
2029 2029
 				@socket_close($sock);
2030
-			    }
2030
+				}
2031 2031
 			    
2032 2032
 			}
2033 2033
 			if ($globalDebug) echo "Waiting...";
@@ -2042,15 +2042,15 @@  discard block
 block discarded – undo
2042 2042
 			if ($globalDebug) echo "Restart all connections...";
2043 2043
 			connect_all($globalSources);
2044 2044
 		}
2045
-	    }
2045
+		}
2046 2046
 	}
2047 2047
 	if ($globalDaemon === false) {
2048
-	    if ($globalDebug) echo 'Check all...'."\n";
2049
-	    if (isset($SI)) $SI->checkAll();
2050
-	    if (isset($TI)) $TI->checkAll();
2051
-	    if (isset($MI)) $MI->checkAll();
2048
+		if ($globalDebug) echo 'Check all...'."\n";
2049
+		if (isset($SI)) $SI->checkAll();
2050
+		if (isset($TI)) $TI->checkAll();
2051
+		if (isset($MI)) $MI->checkAll();
2052
+	}
2052 2053
 	}
2053
-    }
2054 2054
 }
2055 2055
 
2056 2056
 ?>
Please login to merge, or discard this patch.