Completed
Push — master ( 3e0d90...3d34c0 )
by Yannick
12:50 queued 04:55
created
scripts/daemon-spotter.php 1 patch
Indentation   +866 added lines, -866 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17 17
 if (isset($globalMarine) && $globalMarine) {
18
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
18
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 20
 }
21 21
 
22 22
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -24,42 +24,42 @@  discard block
 block discarded – undo
24 24
 // Check if schema is at latest version
25 25
 $Connection = new Connection();
26 26
 if ($Connection->latest() === false) {
27
-    echo "You MUST update to latest schema. Run install/index.php";
28
-    exit();
27
+	echo "You MUST update to latest schema. Run install/index.php";
28
+	exit();
29 29
 }
30 30
 if (PHP_SAPI != 'cli') {
31
-    echo "This script MUST be called from console, not a web browser.";
31
+	echo "This script MUST be called from console, not a web browser.";
32 32
 //    exit();
33 33
 }
34 34
 
35 35
 // This is to be compatible with old version of settings.php
36 36
 if (!isset($globalSources)) {
37
-    if (isset($globalSBS1Hosts)) {
38
-        //$hosts = $globalSBS1Hosts;
39
-        foreach ($globalSBS1Hosts as $host) {
40
-	    $globalSources[] = array('host' => $host);
41
-    	}
42
-    } else {
43
-        if (!isset($globalSBS1Host)) {
44
-	    echo '$globalSources MUST be defined !';
45
-	    die;
37
+	if (isset($globalSBS1Hosts)) {
38
+		//$hosts = $globalSBS1Hosts;
39
+		foreach ($globalSBS1Hosts as $host) {
40
+		$globalSources[] = array('host' => $host);
41
+		}
42
+	} else {
43
+		if (!isset($globalSBS1Host)) {
44
+		echo '$globalSources MUST be defined !';
45
+		die;
46 46
 	}
47 47
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
48 48
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
49
-    }
49
+	}
50 50
 }
51 51
 
52 52
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
53 53
 //if (isset($options['s'])) $hosts = array($options['s']);
54 54
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 55
 if (isset($options['s'])) {
56
-    $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
-    else $globalSources[] = array('host' => $options['s']);
56
+	$globalSources = array();
57
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
+	else $globalSources[] = array('host' => $options['s']);
59 59
 } elseif (isset($options['source'])) {
60
-    $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
-    else $globalSources[] = array('host' => $options['source']);
60
+	$globalSources = array();
61
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
+	else $globalSources[] = array('host' => $options['source']);
63 63
 }
64 64
 if (isset($options['aprsserverhost'])) {
65 65
 	$globalServerAPRS = TRUE;
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 if (isset($options['idsource'])) $id_source = $options['idsource'];
75 75
 else $id_source = 1;
76 76
 if (isset($globalServer) && $globalServer) {
77
-    if ($globalDebug) echo "Using Server Mode\n";
78
-    $SI=new SpotterServer();
77
+	if ($globalDebug) echo "Using Server Mode\n";
78
+	$SI=new SpotterServer();
79 79
 /*
80 80
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 81
     $SI = new adsb2aprs();
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 } else $SI=new SpotterImport($Connection->db);
85 85
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
86 86
 if (isset($globalMarine) && $globalMarine) {
87
-    $AIS = new AIS();
88
-    $MI = new MarineImport($Connection->db);
87
+	$AIS = new AIS();
88
+	$MI = new MarineImport($Connection->db);
89 89
 }
90 90
 //$APRS=new APRS($Connection->db);
91 91
 $SBS=new SBS();
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 //$servertz = system('date +%Z');
96 96
 // signal handler - playing nice with sockets and dump1090
97 97
 if (function_exists('pcntl_fork')) {
98
-    pcntl_signal(SIGINT,  function() {
99
-        global $sockets;
100
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101
-        die("Bye!\n");
102
-    });
103
-    pcntl_signal_dispatch();
98
+	pcntl_signal(SIGINT,  function() {
99
+		global $sockets;
100
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101
+		die("Bye!\n");
102
+	});
103
+	pcntl_signal_dispatch();
104 104
 }
105 105
 
106 106
 // let's try and connect
@@ -110,153 +110,153 @@  discard block
 block discarded – undo
110 110
 $reset = 0;
111 111
 
112 112
 function connect_all($hosts) {
113
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115
-    $reset++;
116
-    if ($globalDebug) echo 'Connect to all...'."\n";
117
-    foreach ($hosts as $id => $value) {
113
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115
+	$reset++;
116
+	if ($globalDebug) echo 'Connect to all...'."\n";
117
+	foreach ($hosts as $id => $value) {
118 118
 	$host = $value['host'];
119 119
 	$globalSources[$id]['last_exec'] = 0;
120 120
 	// Here we check type of source(s)
121 121
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
-        	//$formats[$id] = 'deltadbtxt';
124
-        	$globalSources[$id]['format'] = 'deltadbtxt';
125
-        	//$last_exec['deltadbtxt'] = 0;
126
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
128
-        	//$formats[$id] = 'vatsimtxt';
129
-        	$globalSources[$id]['format'] = 'vatsimtxt';
130
-        	//$last_exec['vatsimtxt'] = 0;
131
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
133
-        	//$formats[$id] = 'aircraftlistjson';
134
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
135
-        	//$last_exec['aircraftlistjson'] = 0;
136
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
-    	    } else if (preg_match('/opensky/i',$host)) {
138
-        	//$formats[$id] = 'aircraftlistjson';
139
-        	$globalSources[$id]['format'] = 'opensky';
140
-        	//$last_exec['aircraftlistjson'] = 0;
141
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
143
-        	//$formats[$id] = 'radarvirtueljson';
144
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
145
-        	//$last_exec['radarvirtueljson'] = 0;
146
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
147
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
148
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149
-        	    exit(0);
150
-        	}
151
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
152
-        	//$formats[$id] = 'planeupdatefaa';
153
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
154
-        	//$last_exec['planeupdatefaa'] = 0;
155
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
156
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
157
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158
-        	    exit(0);
159
-        	}
160
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
161
-        	//$formats[$id] = 'phpvmacars';
162
-        	$globalSources[$id]['format'] = 'phpvmacars';
163
-        	//$last_exec['phpvmacars'] = 0;
164
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
165
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
166
-        	//$formats[$id] = 'phpvmacars';
167
-        	$globalSources[$id]['format'] = 'vam';
168
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
169
-            } else if (preg_match('/whazzup/i',$host)) {
170
-        	//$formats[$id] = 'whazzup';
171
-        	$globalSources[$id]['format'] = 'whazzup';
172
-        	//$last_exec['whazzup'] = 0;
173
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
174
-            } else if (preg_match('/recentpireps/i',$host)) {
175
-        	//$formats[$id] = 'pirepsjson';
176
-        	$globalSources[$id]['format'] = 'pirepsjson';
177
-        	//$last_exec['pirepsjson'] = 0;
178
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
179
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
180
-        	//$formats[$id] = 'fr24json';
181
-        	$globalSources[$id]['format'] = 'fr24json';
182
-        	//$last_exec['fr24json'] = 0;
183
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
184
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
185
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
186
-        	    exit(0);
187
-        	}
188
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
189
-        	//$formats[$id] = 'fr24json';
190
-        	$globalSources[$id]['format'] = 'myshiptracking';
191
-        	//$last_exec['fr24json'] = 0;
192
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
193
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
194
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
195
-        	    exit(0);
196
-        	}
197
-            //} else if (preg_match('/10001/',$host)) {
198
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
199
-        	//$formats[$id] = 'tsv';
200
-        	$globalSources[$id]['format'] = 'tsv';
201
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
202
-            }
203
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
204
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
205
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
206
-    		    if ($idf !== false) {
207
-    			$httpfeeds[$id] = $idf;
208
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
209
-    		    }
210
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
211
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
212
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
213
-	    $hostport = explode(':',$host);
214
-	    if (isset($hostport[1])) {
122
+			if (preg_match('/deltadb.txt$/i',$host)) {
123
+			//$formats[$id] = 'deltadbtxt';
124
+			$globalSources[$id]['format'] = 'deltadbtxt';
125
+			//$last_exec['deltadbtxt'] = 0;
126
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
128
+			//$formats[$id] = 'vatsimtxt';
129
+			$globalSources[$id]['format'] = 'vatsimtxt';
130
+			//$last_exec['vatsimtxt'] = 0;
131
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
133
+			//$formats[$id] = 'aircraftlistjson';
134
+			$globalSources[$id]['format'] = 'aircraftlistjson';
135
+			//$last_exec['aircraftlistjson'] = 0;
136
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
+			} else if (preg_match('/opensky/i',$host)) {
138
+			//$formats[$id] = 'aircraftlistjson';
139
+			$globalSources[$id]['format'] = 'opensky';
140
+			//$last_exec['aircraftlistjson'] = 0;
141
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
143
+			//$formats[$id] = 'radarvirtueljson';
144
+			$globalSources[$id]['format'] = 'radarvirtueljson';
145
+			//$last_exec['radarvirtueljson'] = 0;
146
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
147
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
148
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149
+				exit(0);
150
+			}
151
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
152
+			//$formats[$id] = 'planeupdatefaa';
153
+			$globalSources[$id]['format'] = 'planeupdatefaa';
154
+			//$last_exec['planeupdatefaa'] = 0;
155
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
156
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
157
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158
+				exit(0);
159
+			}
160
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
161
+			//$formats[$id] = 'phpvmacars';
162
+			$globalSources[$id]['format'] = 'phpvmacars';
163
+			//$last_exec['phpvmacars'] = 0;
164
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
165
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
166
+			//$formats[$id] = 'phpvmacars';
167
+			$globalSources[$id]['format'] = 'vam';
168
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
169
+			} else if (preg_match('/whazzup/i',$host)) {
170
+			//$formats[$id] = 'whazzup';
171
+			$globalSources[$id]['format'] = 'whazzup';
172
+			//$last_exec['whazzup'] = 0;
173
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
174
+			} else if (preg_match('/recentpireps/i',$host)) {
175
+			//$formats[$id] = 'pirepsjson';
176
+			$globalSources[$id]['format'] = 'pirepsjson';
177
+			//$last_exec['pirepsjson'] = 0;
178
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
179
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
180
+			//$formats[$id] = 'fr24json';
181
+			$globalSources[$id]['format'] = 'fr24json';
182
+			//$last_exec['fr24json'] = 0;
183
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
184
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
185
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
186
+				exit(0);
187
+			}
188
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
189
+			//$formats[$id] = 'fr24json';
190
+			$globalSources[$id]['format'] = 'myshiptracking';
191
+			//$last_exec['fr24json'] = 0;
192
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
193
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
194
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
195
+				exit(0);
196
+			}
197
+			//} else if (preg_match('/10001/',$host)) {
198
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
199
+			//$formats[$id] = 'tsv';
200
+			$globalSources[$id]['format'] = 'tsv';
201
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
202
+			}
203
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
204
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
205
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
206
+				if ($idf !== false) {
207
+				$httpfeeds[$id] = $idf;
208
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
209
+				}
210
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
211
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
212
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
213
+		$hostport = explode(':',$host);
214
+		if (isset($hostport[1])) {
215 215
 		$port = $hostport[1];
216 216
 		$hostn = $hostport[0];
217
-	    } else {
217
+		} else {
218 218
 		$port = $globalSources[$id]['port'];
219 219
 		$hostn = $globalSources[$id]['host'];
220
-	    }
221
-	    $Common = new Common();
222
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
223
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
224
-    	    } else {
225
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
226
-	    }
227
-	    if ($s) {
228
-    	        $sockets[$id] = $s;
229
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
230
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
220
+		}
221
+		$Common = new Common();
222
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
223
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
224
+			} else {
225
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
226
+		}
227
+		if ($s) {
228
+				$sockets[$id] = $s;
229
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
230
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
231 231
 			//$formats[$id] = 'aprs';
232 232
 			$globalSources[$id]['format'] = 'aprs';
233 233
 			//$aprs_connect = 0;
234 234
 			//$use_aprs = true;
235
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
235
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
236 236
 			$globalSources[$id]['format'] = 'vrstcp';
237
-    		    } elseif ($port == '10001') {
238
-        		//$formats[$id] = 'tsv';
239
-        		$globalSources[$id]['format'] = 'tsv';
240
-		    } elseif ($port == '30002') {
241
-        		//$formats[$id] = 'raw';
242
-        		$globalSources[$id]['format'] = 'raw';
243
-		    } elseif ($port == '5001') {
244
-        		//$formats[$id] = 'raw';
245
-        		$globalSources[$id]['format'] = 'flightgearmp';
246
-		    } elseif ($port == '30005') {
237
+				} elseif ($port == '10001') {
238
+				//$formats[$id] = 'tsv';
239
+				$globalSources[$id]['format'] = 'tsv';
240
+			} elseif ($port == '30002') {
241
+				//$formats[$id] = 'raw';
242
+				$globalSources[$id]['format'] = 'raw';
243
+			} elseif ($port == '5001') {
244
+				//$formats[$id] = 'raw';
245
+				$globalSources[$id]['format'] = 'flightgearmp';
246
+			} elseif ($port == '30005') {
247 247
 			// Not yet supported
248
-        		//$formats[$id] = 'beast';
249
-        		$globalSources[$id]['format'] = 'beast';
250
-		    //} else $formats[$id] = 'sbs';
251
-		    } else $globalSources[$id]['format'] = 'sbs';
252
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
248
+				//$formats[$id] = 'beast';
249
+				$globalSources[$id]['format'] = 'beast';
250
+			//} else $formats[$id] = 'sbs';
251
+			} else $globalSources[$id]['format'] = 'sbs';
252
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
253 253
 		}
254 254
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
255
-            } else {
255
+			} else {
256 256
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
257
-    	    }
258
-        }
259
-    }
257
+			}
258
+		}
259
+	}
260 260
 }
261 261
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
262 262
 
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
 //connect_all($globalSources);
280 280
 
281 281
 if (isset($globalProxy) && $globalProxy) {
282
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
282
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
283 283
 } else {
284
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
284
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
285 285
 }
286 286
 
287 287
 // APRS Configuration
@@ -290,18 +290,18 @@  discard block
 block discarded – undo
290 290
 	die;
291 291
 }
292 292
 foreach ($globalSources as $key => $source) {
293
-    if (!isset($source['format'])) {
294
-        $globalSources[$key]['format'] = 'auto';
295
-    }
293
+	if (!isset($source['format'])) {
294
+		$globalSources[$key]['format'] = 'auto';
295
+	}
296 296
 }
297 297
 connect_all($globalSources);
298 298
 foreach ($globalSources as $key => $source) {
299
-    if (isset($source['format']) && $source['format'] == 'aprs') {
299
+	if (isset($source['format']) && $source['format'] == 'aprs') {
300 300
 	$aprs_connect = 0;
301 301
 	$use_aprs = true;
302 302
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
303 303
 	break;
304
-    }
304
+	}
305 305
 }
306 306
 
307 307
 if ($use_aprs) {
@@ -342,117 +342,117 @@  discard block
 block discarded – undo
342 342
 
343 343
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
344 344
 while ($i > 0) {
345
-    if (!$globalDaemon) $i = $endtime-time();
346
-    // Delete old ATC
347
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
345
+	if (!$globalDaemon) $i = $endtime-time();
346
+	// Delete old ATC
347
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
348 348
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
349
-        $ATC->deleteOldATC();
350
-    }
349
+		$ATC->deleteOldATC();
350
+	}
351 351
     
352
-    //if (count($last_exec) > 0) {
353
-    if (count($last_exec) == count($globalSources)) {
352
+	//if (count($last_exec) > 0) {
353
+	if (count($last_exec) == count($globalSources)) {
354 354
 	$max = $globalMinFetch;
355 355
 	foreach ($last_exec as $last) {
356
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
356
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
357 357
 	}
358 358
 	if ($max != $globalMinFetch) {
359
-	    if ($globalDebug) echo 'Sleeping...'."\n";
360
-	    sleep($globalMinFetch-$max+2);
359
+		if ($globalDebug) echo 'Sleeping...'."\n";
360
+		sleep($globalMinFetch-$max+2);
361
+	}
361 362
 	}
362
-    }
363 363
 
364 364
     
365
-    //foreach ($formats as $id => $value) {
366
-    foreach ($globalSources as $id => $value) {
365
+	//foreach ($formats as $id => $value) {
366
+	foreach ($globalSources as $id => $value) {
367 367
 	date_default_timezone_set('UTC');
368 368
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
369 369
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
370
-	    //$buffer = $Common->getData($hosts[$id]);
371
-	    $buffer = $Common->getData($value['host']);
372
-	    if ($buffer != '') $reset = 0;
373
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374
-	    $buffer = explode('\n',$buffer);
375
-	    foreach ($buffer as $line) {
376
-    		if ($line != '' && count($line) > 7) {
377
-    		    $line = explode(',', $line);
378
-	            $data = array();
379
-	            $data['hex'] = $line[1]; // hex
380
-	            $data['ident'] = $line[2]; // ident
381
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
382
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
383
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
384
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
385
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
386
-	            $data['verticalrate'] = ''; // vertical rate
387
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
388
-	            $data['emergency'] = ''; // emergency
389
-		    $data['datetime'] = date('Y-m-d H:i:s');
390
-		    $data['format_source'] = 'deltadbtxt';
391
-    		    $data['id_source'] = $id_source;
392
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
393
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
394
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
395
-    		    $SI->add($data);
396
-		    unset($data);
397
-    		}
398
-    	    }
399
-    	    $last_exec[$id]['last'] = time();
370
+		//$buffer = $Common->getData($hosts[$id]);
371
+		$buffer = $Common->getData($value['host']);
372
+		if ($buffer != '') $reset = 0;
373
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374
+		$buffer = explode('\n',$buffer);
375
+		foreach ($buffer as $line) {
376
+			if ($line != '' && count($line) > 7) {
377
+				$line = explode(',', $line);
378
+				$data = array();
379
+				$data['hex'] = $line[1]; // hex
380
+				$data['ident'] = $line[2]; // ident
381
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
382
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
383
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
384
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
385
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
386
+				$data['verticalrate'] = ''; // vertical rate
387
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
388
+				$data['emergency'] = ''; // emergency
389
+			$data['datetime'] = date('Y-m-d H:i:s');
390
+			$data['format_source'] = 'deltadbtxt';
391
+				$data['id_source'] = $id_source;
392
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
393
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
394
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
395
+				$SI->add($data);
396
+			unset($data);
397
+			}
398
+			}
399
+			$last_exec[$id]['last'] = time();
400 400
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
401
-	    date_default_timezone_set('CET');
402
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
403
-	    date_default_timezone_set('UTC');
404
-	    if ($buffer != '') $reset = 0;
405
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
406
-	    $buffer = explode('\n',$buffer);
407
-	    foreach ($buffer as $line) {
401
+		date_default_timezone_set('CET');
402
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
403
+		date_default_timezone_set('UTC');
404
+		if ($buffer != '') $reset = 0;
405
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
406
+		$buffer = explode('\n',$buffer);
407
+		foreach ($buffer as $line) {
408 408
 		if ($line != '') {
409
-		    echo "'".$line."'\n";
410
-		    $add = false;
411
-		    $ais_data = $AIS->parse_line(trim($line));
412
-		    $data = array();
413
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
414
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
415
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
416
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
417
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
418
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
419
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
420
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
421
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
422
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
423
-		    if (isset($ais_data['timestamp'])) {
409
+			echo "'".$line."'\n";
410
+			$add = false;
411
+			$ais_data = $AIS->parse_line(trim($line));
412
+			$data = array();
413
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
414
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
415
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
416
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
417
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
418
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
419
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
420
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
421
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
422
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
423
+			if (isset($ais_data['timestamp'])) {
424 424
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
425 425
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
426
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
427
-			    $add = true;
426
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
427
+				$add = true;
428 428
 			}
429
-		    } else {
429
+			} else {
430 430
 			$data['datetime'] = date('Y-m-d H:i:s');
431 431
 			$add = true;
432
-		    }
433
-		    $data['format_source'] = 'aisnmeatxt';
434
-    		    $data['id_source'] = $id_source;
435
-		    //print_r($data);
436
-		    echo 'Add...'."\n";
437
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
438
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
439
-		    unset($data);
432
+			}
433
+			$data['format_source'] = 'aisnmeatxt';
434
+				$data['id_source'] = $id_source;
435
+			//print_r($data);
436
+			echo 'Add...'."\n";
437
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
438
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
439
+			unset($data);
440 440
 		}
441
-    	    }
442
-    	    $last_exec[$id]['last'] = time();
441
+			}
442
+			$last_exec[$id]['last'] = time();
443 443
 	} elseif ($value['format'] == 'aisnmeahttp') {
444
-	    $arr = $httpfeeds;
445
-	    $w = $e = null;
444
+		$arr = $httpfeeds;
445
+		$w = $e = null;
446 446
 	    
447
-	    if (isset($arr[$id])) {
447
+		if (isset($arr[$id])) {
448 448
 		$nn = stream_select($arr,$w,$e,$timeout);
449 449
 		if ($nn > 0) {
450
-		    foreach ($httpfeeds as $feed) {
450
+			foreach ($httpfeeds as $feed) {
451 451
 			$buffer = stream_get_line($feed,2000,"\n");
452 452
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
453 453
 			$buffer = explode('\n',$buffer);
454 454
 			foreach ($buffer as $line) {
455
-			    if ($line != '') {
455
+				if ($line != '') {
456 456
 				$ais_data = $AIS->parse_line(trim($line));
457 457
 				$data = array();
458 458
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -469,39 +469,39 @@  discard block
 block discarded – undo
469 469
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
470 470
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
471 471
 				if (isset($ais_data['timestamp'])) {
472
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
472
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
473 473
 				} else {
474
-				    $data['datetime'] = date('Y-m-d H:i:s');
474
+					$data['datetime'] = date('Y-m-d H:i:s');
475 475
 				}
476 476
 				$data['format_source'] = 'aisnmeahttp';
477 477
 				$data['id_source'] = $id_source;
478 478
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
479 479
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
480 480
 				unset($data);
481
-			    }
481
+				}
482
+			}
482 483
 			}
483
-		    }
484 484
 		} else {
485
-		    $format = $value['format'];
486
-		    if (isset($tt[$format])) $tt[$format]++;
487
-		    else $tt[$format] = 0;
488
-		    if ($tt[$format] > 30) {
485
+			$format = $value['format'];
486
+			if (isset($tt[$format])) $tt[$format]++;
487
+			else $tt[$format] = 0;
488
+			if ($tt[$format] > 30) {
489 489
 			sleep(2);
490 490
 			$sourceeen[] = $value;
491 491
 			connect_all($sourceeen);
492 492
 			$sourceeen = array();
493
-		    }
493
+			}
494
+		}
494 495
 		}
495
-	    }
496 496
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
497
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
498
-	    if ($buffer != '') {
497
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
498
+		if ($buffer != '') {
499 499
 		//echo $buffer;
500 500
 		$all_data = json_decode($buffer,true);
501 501
 		//print_r($all_data);
502 502
 		if (isset($all_data[0]['DATA'])) {
503 503
 		foreach ($all_data[0]['DATA'] as $line) {
504
-		    if ($line != '') {
504
+			if ($line != '') {
505 505
 			$data = array();
506 506
 			$data['ident'] = $line['NAME'];
507 507
 			$data['mmsi'] = $line['MMSI'];
@@ -518,89 +518,89 @@  discard block
 block discarded – undo
518 518
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
519 519
 			$MI->add($data);
520 520
 			unset($data);
521
-		    }
521
+			}
522 522
 		}
523 523
 		}
524 524
 		
525
-	    }
526
-    	    $last_exec[$id]['last'] = time();
525
+		}
526
+			$last_exec[$id]['last'] = time();
527 527
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
528
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
529
-	    if ($buffer != '') {
528
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
529
+		if ($buffer != '') {
530 530
 		$all_data = json_decode($buffer,true);
531 531
 		if (isset($all_data[0]['mmsi'])) {
532
-		    foreach ($all_data as $line) {
532
+			foreach ($all_data as $line) {
533 533
 			if ($line != '') {
534
-			    $data = array();
535
-			    $data['ident'] = $line['shipname'];
536
-			    $data['callsign'] = $line['callsign'];
537
-			    $data['mmsi'] = $line['mmsi'];
538
-			    $data['speed'] = $line['sog'];
539
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
540
-			    $data['latitude'] = $line['latitude'];
541
-			    $data['longitude'] = $line['longitude'];
542
-			    $data['type_id'] = $line['shiptype'];
543
-			    $data['arrival_code'] = $line['destination'];
544
-			    $data['datetime'] = $line['time'];
545
-			    $data['format_source'] = 'boatbeaconapp';
546
-			    $data['id_source'] = $id_source;
547
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
548
-			    $MI->add($data);
549
-			    unset($data);
534
+				$data = array();
535
+				$data['ident'] = $line['shipname'];
536
+				$data['callsign'] = $line['callsign'];
537
+				$data['mmsi'] = $line['mmsi'];
538
+				$data['speed'] = $line['sog'];
539
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
540
+				$data['latitude'] = $line['latitude'];
541
+				$data['longitude'] = $line['longitude'];
542
+				$data['type_id'] = $line['shiptype'];
543
+				$data['arrival_code'] = $line['destination'];
544
+				$data['datetime'] = $line['time'];
545
+				$data['format_source'] = 'boatbeaconapp';
546
+				$data['id_source'] = $id_source;
547
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
548
+				$MI->add($data);
549
+				unset($data);
550
+			}
550 551
 			}
551
-		    }
552 552
 		}
553 553
 		
554
-	    }
555
-    	    $last_exec[$id]['last'] = time();
554
+		}
555
+			$last_exec[$id]['last'] = time();
556 556
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
557
-	    echo 'download...';
558
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
559
-	    echo 'done !'."\n";
560
-	    if ($buffer != '') $reset = 0;
561
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
562
-	    $buffer = explode('\n',$buffer);
563
-	    foreach ($buffer as $line) {
557
+		echo 'download...';
558
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
559
+		echo 'done !'."\n";
560
+		if ($buffer != '') $reset = 0;
561
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
562
+		$buffer = explode('\n',$buffer);
563
+		foreach ($buffer as $line) {
564 564
 		if ($line != '') {
565
-		    $data = array();
566
-		    $data['mmsi'] = (int)substr($line,0,9);
567
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
568
-		    //$data['status'] = substr($line,21,2);
569
-		    //$data['type'] = substr($line,24,3);
570
-		    $data['latitude'] = substr($line,29,9);
571
-		    $data['longitude'] = substr($line,41,9);
572
-		    $data['speed'] = round(substr($line,51,5));
573
-		    //$data['course'] = substr($line,57,5);
574
-		    $data['heading'] = round(substr($line,63,3));
575
-		    //$data['draft'] = substr($line,67,4);
576
-		    //$data['length'] = substr($line,72,3);
577
-		    //$data['beam'] = substr($line,76,2);
578
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
579
-		    //$data['callsign'] = trim(substr($line,100,7);
580
-		    //$data['dest'] = substr($line,108,20);
581
-		    //$data['etaDate'] = substr($line,129,5);
582
-		    //$data['etaTime'] = substr($line,135,5);
583
-		    $data['format_source'] = 'shipplotter';
584
-    		    $data['id_source'] = $id_source;
585
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
586
-		    //print_r($data);
587
-		    echo 'Add...'."\n";
588
-		    $MI->add($data);
589
-		    unset($data);
565
+			$data = array();
566
+			$data['mmsi'] = (int)substr($line,0,9);
567
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
568
+			//$data['status'] = substr($line,21,2);
569
+			//$data['type'] = substr($line,24,3);
570
+			$data['latitude'] = substr($line,29,9);
571
+			$data['longitude'] = substr($line,41,9);
572
+			$data['speed'] = round(substr($line,51,5));
573
+			//$data['course'] = substr($line,57,5);
574
+			$data['heading'] = round(substr($line,63,3));
575
+			//$data['draft'] = substr($line,67,4);
576
+			//$data['length'] = substr($line,72,3);
577
+			//$data['beam'] = substr($line,76,2);
578
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
579
+			//$data['callsign'] = trim(substr($line,100,7);
580
+			//$data['dest'] = substr($line,108,20);
581
+			//$data['etaDate'] = substr($line,129,5);
582
+			//$data['etaTime'] = substr($line,135,5);
583
+			$data['format_source'] = 'shipplotter';
584
+				$data['id_source'] = $id_source;
585
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
586
+			//print_r($data);
587
+			echo 'Add...'."\n";
588
+			$MI->add($data);
589
+			unset($data);
590 590
 		}
591
-    	    }
592
-    	    $last_exec[$id]['last'] = time();
591
+			}
592
+			$last_exec[$id]['last'] = time();
593 593
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
594 594
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
595
-	    //$buffer = $Common->getData($hosts[$id]);
596
-	    $buffer = $Common->getData($value['host']);
597
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598
-	    $buffer = explode('\n',$buffer);
599
-	    $reset = 0;
600
-	    foreach ($buffer as $line) {
601
-    		if ($line != '') {
602
-    		    $line = explode(':', $line);
603
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
595
+		//$buffer = $Common->getData($hosts[$id]);
596
+		$buffer = $Common->getData($value['host']);
597
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598
+		$buffer = explode('\n',$buffer);
599
+		$reset = 0;
600
+		foreach ($buffer as $line) {
601
+			if ($line != '') {
602
+				$line = explode(':', $line);
603
+				if (count($line) > 30 && $line[0] != 'callsign') {
604 604
 			$data = array();
605 605
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
606 606
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -613,37 +613,37 @@  discard block
 block discarded – undo
613 613
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
614 614
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
615 615
 			$data['latitude'] = $line[5]; // lat
616
-	        	$data['longitude'] = $line[6]; // long
617
-	        	$data['verticalrate'] = ''; // vertical rate
618
-	        	$data['squawk'] = ''; // squawk
619
-	        	$data['emergency'] = ''; // emergency
620
-	        	$data['waypoints'] = $line[30];
616
+				$data['longitude'] = $line[6]; // long
617
+				$data['verticalrate'] = ''; // vertical rate
618
+				$data['squawk'] = ''; // squawk
619
+				$data['emergency'] = ''; // emergency
620
+				$data['waypoints'] = $line[30];
621 621
 			$data['datetime'] = date('Y-m-d H:i:s');
622 622
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
623 623
 			//if (isset($line[37])) $data['last_update'] = $line[37];
624
-		        $data['departure_airport_icao'] = $line[11];
625
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
626
-		        $data['arrival_airport_icao'] = $line[13];
624
+				$data['departure_airport_icao'] = $line[11];
625
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
626
+				$data['arrival_airport_icao'] = $line[13];
627 627
 			$data['frequency'] = $line[4];
628 628
 			$data['type'] = $line[18];
629 629
 			$data['range'] = $line[19];
630 630
 			if (isset($line[35])) $data['info'] = $line[35];
631
-    			$data['id_source'] = $id_source;
632
-	    		//$data['arrival_airport_time'] = ;
633
-	    		if ($line[9] != '') {
634
-	    		    $aircraft_data = explode('/',$line[9]);
635
-	    		    if (isset($aircraft_data[1])) {
636
-	    			$data['aircraft_icao'] = $aircraft_data[1];
637
-	    		    }
638
-        		}
639
-	    		/*
631
+				$data['id_source'] = $id_source;
632
+				//$data['arrival_airport_time'] = ;
633
+				if ($line[9] != '') {
634
+					$aircraft_data = explode('/',$line[9]);
635
+					if (isset($aircraft_data[1])) {
636
+					$data['aircraft_icao'] = $aircraft_data[1];
637
+					}
638
+				}
639
+				/*
640 640
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
641 641
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
642 642
 	    		*/
643
-	    		$data['format_source'] = $value['format'];
643
+				$data['format_source'] = $value['format'];
644 644
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
645 645
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
646
-    			if ($line[3] == 'PILOT') $SI->add($data);
646
+				if ($line[3] == 'PILOT') $SI->add($data);
647 647
 			elseif ($line[3] == 'ATC') {
648 648
 				//print_r($data);
649 649
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -661,255 +661,255 @@  discard block
 block discarded – undo
661 661
 				if (!isset($data['source_name'])) $data['source_name'] = '';
662 662
 				if (isset($ATC)) 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']);
663 663
 			}
664
-    			unset($data);
665
-    		    }
666
-    		}
667
-    	    }
668
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
669
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
670
-    	    $last_exec[$id]['last'] = time();
671
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
672
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
673
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
674
-	    if ($buffer != '') {
675
-	    $all_data = json_decode($buffer,true);
676
-	    if (isset($all_data['acList'])) {
664
+				unset($data);
665
+				}
666
+			}
667
+			}
668
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
669
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
670
+			$last_exec[$id]['last'] = time();
671
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
672
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
673
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
674
+		if ($buffer != '') {
675
+		$all_data = json_decode($buffer,true);
676
+		if (isset($all_data['acList'])) {
677 677
 		$reset = 0;
678 678
 		foreach ($all_data['acList'] as $line) {
679
-		    $data = array();
680
-		    $data['hex'] = $line['Icao']; // hex
681
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
682
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
683
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
684
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
685
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
686
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
687
-		    //$data['verticalrate'] = $line['']; // verticale rate
688
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
689
-		    $data['emergency'] = ''; // emergency
690
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
679
+			$data = array();
680
+			$data['hex'] = $line['Icao']; // hex
681
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
682
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
683
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
684
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
685
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
686
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
687
+			//$data['verticalrate'] = $line['']; // verticale rate
688
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
689
+			$data['emergency'] = ''; // emergency
690
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
691 691
 		    
692
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
693
-		    else $data['datetime'] = date('Y-m-d H:i:s');
692
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
693
+			else $data['datetime'] = date('Y-m-d H:i:s');
694 694
 		    
695
-		    //$data['datetime'] = date('Y-m-d H:i:s');
696
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
697
-	    	    $data['format_source'] = 'aircraftlistjson';
698
-		    $data['id_source'] = $id_source;
699
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
700
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
701
-		    if (isset($data['latitude'])) $SI->add($data);
702
-		    unset($data);
695
+			//$data['datetime'] = date('Y-m-d H:i:s');
696
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
697
+				$data['format_source'] = 'aircraftlistjson';
698
+			$data['id_source'] = $id_source;
699
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
700
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
701
+			if (isset($data['latitude'])) $SI->add($data);
702
+			unset($data);
703 703
 		}
704
-	    } elseif (is_array($all_data)) {
704
+		} elseif (is_array($all_data)) {
705 705
 		$reset = 0;
706 706
 		foreach ($all_data as $line) {
707
-		    $data = array();
708
-		    $data['hex'] = $line['hex']; // hex
709
-		    $data['ident'] = $line['flight']; // ident
710
-		    $data['altitude'] = $line['altitude']; // altitude
711
-		    $data['speed'] = $line['speed']; // speed
712
-		    $data['heading'] = $line['track']; // heading
713
-		    $data['latitude'] = $line['lat']; // lat
714
-		    $data['longitude'] = $line['lon']; // long
715
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
716
-		    $data['squawk'] = $line['squawk']; // squawk
717
-		    $data['emergency'] = ''; // emergency
718
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
719
-		    else $data['datetime'] = date('Y-m-d H:i:s');
720
-	    	    $data['format_source'] = 'aircraftlistjson';
721
-    		    $data['id_source'] = $id_source;
722
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
723
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
724
-		    $SI->add($data);
725
-		    unset($data);
707
+			$data = array();
708
+			$data['hex'] = $line['hex']; // hex
709
+			$data['ident'] = $line['flight']; // ident
710
+			$data['altitude'] = $line['altitude']; // altitude
711
+			$data['speed'] = $line['speed']; // speed
712
+			$data['heading'] = $line['track']; // heading
713
+			$data['latitude'] = $line['lat']; // lat
714
+			$data['longitude'] = $line['lon']; // long
715
+			$data['verticalrate'] = $line['vrt']; // verticale rate
716
+			$data['squawk'] = $line['squawk']; // squawk
717
+			$data['emergency'] = ''; // emergency
718
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
719
+			else $data['datetime'] = date('Y-m-d H:i:s');
720
+				$data['format_source'] = 'aircraftlistjson';
721
+				$data['id_source'] = $id_source;
722
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
723
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
724
+			$SI->add($data);
725
+			unset($data);
726
+		}
726 727
 		}
727
-	    }
728
-	    }
729
-    	    //$last_exec['aircraftlistjson'] = time();
730
-    	    $last_exec[$id]['last'] = time();
731
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
732
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
733
-	    $buffer = $Common->getData($value['host']);
734
-	    $all_data = json_decode($buffer,true);
735
-	    if (isset($all_data['planes'])) {
728
+		}
729
+			//$last_exec['aircraftlistjson'] = time();
730
+			$last_exec[$id]['last'] = time();
731
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
732
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
733
+		$buffer = $Common->getData($value['host']);
734
+		$all_data = json_decode($buffer,true);
735
+		if (isset($all_data['planes'])) {
736 736
 		$reset = 0;
737 737
 		foreach ($all_data['planes'] as $key => $line) {
738
-		    $data = array();
739
-		    $data['hex'] = $key; // hex
740
-		    $data['ident'] = $line[3]; // ident
741
-		    $data['altitude'] = $line[6]; // altitude
742
-		    $data['speed'] = $line[8]; // speed
743
-		    $data['heading'] = $line[7]; // heading
744
-		    $data['latitude'] = $line[4]; // lat
745
-		    $data['longitude'] = $line[5]; // long
746
-		    //$data['verticalrate'] = $line[]; // verticale rate
747
-		    $data['squawk'] = $line[10]; // squawk
748
-		    $data['emergency'] = ''; // emergency
749
-		    $data['registration'] = $line[2];
750
-		    $data['aircraft_icao'] = $line[0];
751
-		    $deparr = explode('-',$line[1]);
752
-		    if (count($deparr) == 2) {
738
+			$data = array();
739
+			$data['hex'] = $key; // hex
740
+			$data['ident'] = $line[3]; // ident
741
+			$data['altitude'] = $line[6]; // altitude
742
+			$data['speed'] = $line[8]; // speed
743
+			$data['heading'] = $line[7]; // heading
744
+			$data['latitude'] = $line[4]; // lat
745
+			$data['longitude'] = $line[5]; // long
746
+			//$data['verticalrate'] = $line[]; // verticale rate
747
+			$data['squawk'] = $line[10]; // squawk
748
+			$data['emergency'] = ''; // emergency
749
+			$data['registration'] = $line[2];
750
+			$data['aircraft_icao'] = $line[0];
751
+			$deparr = explode('-',$line[1]);
752
+			if (count($deparr) == 2) {
753 753
 			$data['departure_airport_icao'] = $deparr[0];
754 754
 			$data['arrival_airport_icao'] = $deparr[1];
755
-		    }
756
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
757
-	    	    $data['format_source'] = 'planeupdatefaa';
758
-    		    $data['id_source'] = $id_source;
759
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
760
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
761
-		    $SI->add($data);
762
-		    unset($data);
755
+			}
756
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
757
+				$data['format_source'] = 'planeupdatefaa';
758
+				$data['id_source'] = $id_source;
759
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
760
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
761
+			$SI->add($data);
762
+			unset($data);
763
+		}
763 764
 		}
764
-	    }
765
-    	    //$last_exec['planeupdatefaa'] = time();
766
-    	    $last_exec[$id]['last'] = time();
767
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
768
-	    $buffer = $Common->getData($value['host']);
769
-	    $all_data = json_decode($buffer,true);
770
-	    if (isset($all_data['states'])) {
765
+			//$last_exec['planeupdatefaa'] = time();
766
+			$last_exec[$id]['last'] = time();
767
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
768
+		$buffer = $Common->getData($value['host']);
769
+		$all_data = json_decode($buffer,true);
770
+		if (isset($all_data['states'])) {
771 771
 		$reset = 0;
772 772
 		foreach ($all_data['states'] as $key => $line) {
773
-		    $data = array();
774
-		    $data['hex'] = $line[0]; // hex
775
-		    $data['ident'] = trim($line[1]); // ident
776
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
777
-		    $data['speed'] = round($line[9]*1.94384); // speed
778
-		    $data['heading'] = round($line[10]); // heading
779
-		    $data['latitude'] = $line[5]; // lat
780
-		    $data['longitude'] = $line[6]; // long
781
-		    $data['verticalrate'] = $line[11]; // verticale rate
782
-		    //$data['squawk'] = $line[10]; // squawk
783
-		    //$data['emergency'] = ''; // emergency
784
-		    //$data['registration'] = $line[2];
785
-		    //$data['aircraft_icao'] = $line[0];
786
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
787
-	    	    $data['format_source'] = 'opensky';
788
-    		    $data['id_source'] = $id_source;
789
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
790
-		    $SI->add($data);
791
-		    unset($data);
773
+			$data = array();
774
+			$data['hex'] = $line[0]; // hex
775
+			$data['ident'] = trim($line[1]); // ident
776
+			$data['altitude'] = round($line[7]*3.28084); // altitude
777
+			$data['speed'] = round($line[9]*1.94384); // speed
778
+			$data['heading'] = round($line[10]); // heading
779
+			$data['latitude'] = $line[5]; // lat
780
+			$data['longitude'] = $line[6]; // long
781
+			$data['verticalrate'] = $line[11]; // verticale rate
782
+			//$data['squawk'] = $line[10]; // squawk
783
+			//$data['emergency'] = ''; // emergency
784
+			//$data['registration'] = $line[2];
785
+			//$data['aircraft_icao'] = $line[0];
786
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
787
+				$data['format_source'] = 'opensky';
788
+				$data['id_source'] = $id_source;
789
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
790
+			$SI->add($data);
791
+			unset($data);
792
+		}
792 793
 		}
793
-	    }
794
-    	    //$last_exec['planeupdatefaa'] = time();
795
-    	    $last_exec[$id]['last'] = time();
796
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
797
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
798
-	    //$buffer = $Common->getData($hosts[$id]);
799
-	    $buffer = $Common->getData($value['host']);
800
-	    $all_data = json_decode($buffer,true);
801
-	    if (!empty($all_data)) $reset = 0;
802
-	    foreach ($all_data as $key => $line) {
794
+			//$last_exec['planeupdatefaa'] = time();
795
+			$last_exec[$id]['last'] = time();
796
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
797
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
798
+		//$buffer = $Common->getData($hosts[$id]);
799
+		$buffer = $Common->getData($value['host']);
800
+		$all_data = json_decode($buffer,true);
801
+		if (!empty($all_data)) $reset = 0;
802
+		foreach ($all_data as $key => $line) {
803 803
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
804
-		    $data = array();
805
-		    $data['hex'] = $line[0];
806
-		    $data['ident'] = $line[16]; //$line[13]
807
-	    	    $data['altitude'] = $line[4]; // altitude
808
-	    	    $data['speed'] = $line[5]; // speed
809
-	    	    $data['heading'] = $line[3]; // heading
810
-	    	    $data['latitude'] = $line[1]; // lat
811
-	    	    $data['longitude'] = $line[2]; // long
812
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
813
-	    	    $data['squawk'] = $line[6]; // squawk
814
-	    	    $data['aircraft_icao'] = $line[8];
815
-	    	    $data['registration'] = $line[9];
816
-		    $data['departure_airport_iata'] = $line[11];
817
-		    $data['arrival_airport_iata'] = $line[12];
818
-	    	    $data['emergency'] = ''; // emergency
819
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
820
-	    	    $data['format_source'] = 'fr24json';
821
-    		    $data['id_source'] = $id_source;
822
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
823
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
824
-		    $SI->add($data);
825
-		    unset($data);
804
+			$data = array();
805
+			$data['hex'] = $line[0];
806
+			$data['ident'] = $line[16]; //$line[13]
807
+				$data['altitude'] = $line[4]; // altitude
808
+				$data['speed'] = $line[5]; // speed
809
+				$data['heading'] = $line[3]; // heading
810
+				$data['latitude'] = $line[1]; // lat
811
+				$data['longitude'] = $line[2]; // long
812
+				$data['verticalrate'] = $line[15]; // verticale rate
813
+				$data['squawk'] = $line[6]; // squawk
814
+				$data['aircraft_icao'] = $line[8];
815
+				$data['registration'] = $line[9];
816
+			$data['departure_airport_iata'] = $line[11];
817
+			$data['arrival_airport_iata'] = $line[12];
818
+				$data['emergency'] = ''; // emergency
819
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
820
+				$data['format_source'] = 'fr24json';
821
+				$data['id_source'] = $id_source;
822
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
823
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
824
+			$SI->add($data);
825
+			unset($data);
826
+		}
826 827
 		}
827
-	    }
828
-    	    //$last_exec['fr24json'] = time();
829
-    	    $last_exec[$id]['last'] = time();
830
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
831
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
832
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
833
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
834
-	    //echo $buffer;
835
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
836
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
837
-	    $all_data = json_decode($buffer,true);
838
-	    if (json_last_error() != JSON_ERROR_NONE) {
828
+			//$last_exec['fr24json'] = time();
829
+			$last_exec[$id]['last'] = time();
830
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
831
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
832
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
833
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
834
+		//echo $buffer;
835
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
836
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
837
+		$all_data = json_decode($buffer,true);
838
+		if (json_last_error() != JSON_ERROR_NONE) {
839 839
 		die(json_last_error_msg());
840
-	    }
841
-	    if (isset($all_data['mrkrs'])) {
840
+		}
841
+		if (isset($all_data['mrkrs'])) {
842 842
 		$reset = 0;
843 843
 		foreach ($all_data['mrkrs'] as $key => $line) {
844
-		    if (isset($line['inf'])) {
844
+			if (isset($line['inf'])) {
845 845
 			$data = array();
846 846
 			$data['hex'] = $line['inf']['ia'];
847 847
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
848
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
849
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
850
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
851
-	    		$data['latitude'] = $line['pt'][0]; // lat
852
-	    		$data['longitude'] = $line['pt'][1]; // long
853
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
854
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
855
-	    		//$data['aircraft_icao'] = $line[8];
856
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
848
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
849
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
850
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
851
+				$data['latitude'] = $line['pt'][0]; // lat
852
+				$data['longitude'] = $line['pt'][1]; // long
853
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
854
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
855
+				//$data['aircraft_icao'] = $line[8];
856
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
857 857
 			//$data['departure_airport_iata'] = $line[11];
858 858
 			//$data['arrival_airport_iata'] = $line[12];
859
-	    		//$data['emergency'] = ''; // emergency
859
+				//$data['emergency'] = ''; // emergency
860 860
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
861
-	    		$data['format_source'] = 'radarvirtueljson';
862
-    			$data['id_source'] = $id_source;
861
+				$data['format_source'] = 'radarvirtueljson';
862
+				$data['id_source'] = $id_source;
863 863
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
864 864
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
865 865
 			$SI->add($data);
866 866
 			unset($data);
867
-		    }
867
+			}
868
+		}
868 869
 		}
869
-	    }
870
-    	    //$last_exec['radarvirtueljson'] = time();
871
-    	    $last_exec[$id]['last'] = time();
872
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
873
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
874
-	    //$buffer = $Common->getData($hosts[$id]);
875
-	    $buffer = $Common->getData($value['host'].'?'.time());
876
-	    $all_data = json_decode(utf8_encode($buffer),true);
870
+			//$last_exec['radarvirtueljson'] = time();
871
+			$last_exec[$id]['last'] = time();
872
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
873
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
874
+		//$buffer = $Common->getData($hosts[$id]);
875
+		$buffer = $Common->getData($value['host'].'?'.time());
876
+		$all_data = json_decode(utf8_encode($buffer),true);
877 877
 	    
878
-	    if (isset($all_data['pireps'])) {
878
+		if (isset($all_data['pireps'])) {
879 879
 		$reset = 0;
880
-	        foreach ($all_data['pireps'] as $line) {
881
-		    $data = array();
882
-		    $data['id'] = $line['id'];
883
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
884
-		    $data['ident'] = $line['callsign']; // ident
885
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
886
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
887
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
888
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
889
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
890
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
891
-		    $data['latitude'] = $line['lat']; // lat
892
-		    $data['longitude'] = $line['lon']; // long
893
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
894
-		    //$data['squawk'] = $line['squawk']; // squawk
895
-		    //$data['emergency'] = ''; // emergency
896
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
897
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
898
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
899
-		    //$data['arrival_airport_time'] = $line['arrtime'];
900
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
901
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
902
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
903
-		    else $data['info'] = '';
904
-		    $data['format_source'] = 'pireps';
905
-    		    $data['id_source'] = $id_source;
906
-		    $data['datetime'] = date('Y-m-d H:i:s');
907
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
909
-		    if ($line['icon'] == 'plane') {
880
+			foreach ($all_data['pireps'] as $line) {
881
+			$data = array();
882
+			$data['id'] = $line['id'];
883
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
884
+			$data['ident'] = $line['callsign']; // ident
885
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
886
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
887
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
888
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
889
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
890
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
891
+			$data['latitude'] = $line['lat']; // lat
892
+			$data['longitude'] = $line['lon']; // long
893
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
894
+			//$data['squawk'] = $line['squawk']; // squawk
895
+			//$data['emergency'] = ''; // emergency
896
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
897
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
898
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
899
+			//$data['arrival_airport_time'] = $line['arrtime'];
900
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
901
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
902
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
903
+			else $data['info'] = '';
904
+			$data['format_source'] = 'pireps';
905
+				$data['id_source'] = $id_source;
906
+			$data['datetime'] = date('Y-m-d H:i:s');
907
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
909
+			if ($line['icon'] == 'plane') {
910 910
 			$SI->add($data);
911
-		    //    print_r($data);
912
-    		    } elseif ($line['icon'] == 'ct') {
911
+			//    print_r($data);
912
+				} elseif ($line['icon'] == 'ct') {
913 913
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
914 914
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
915 915
 			$typec = substr($data['ident'],-3);
@@ -924,197 +924,197 @@  discard block
 block discarded – undo
924 924
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
925 925
 			else $data['type'] = 'Observer';
926 926
 			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']);
927
-		    }
928
-		    unset($data);
927
+			}
928
+			unset($data);
929 929
 		}
930
-	    }
931
-    	    //$last_exec['pirepsjson'] = time();
932
-    	    $last_exec[$id]['last'] = time();
933
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
934
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
935
-	    //$buffer = $Common->getData($hosts[$id]);
936
-	    if ($globalDebug) echo 'Get Data...'."\n";
937
-	    $buffer = $Common->getData($value['host']);
938
-	    $all_data = json_decode($buffer,true);
939
-	    if ($buffer != '' && is_array($all_data)) {
930
+		}
931
+			//$last_exec['pirepsjson'] = time();
932
+			$last_exec[$id]['last'] = time();
933
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
934
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
935
+		//$buffer = $Common->getData($hosts[$id]);
936
+		if ($globalDebug) echo 'Get Data...'."\n";
937
+		$buffer = $Common->getData($value['host']);
938
+		$all_data = json_decode($buffer,true);
939
+		if ($buffer != '' && is_array($all_data)) {
940 940
 		$reset = 0;
941 941
 		foreach ($all_data as $line) {
942
-	    	    $data = array();
943
-	    	    //$data['id'] = $line['id']; // id not usable
944
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
945
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
946
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
947
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
948
-	    	    $data['ident'] = $line['flightnum']; // ident
949
-	    	    $data['altitude'] = $line['alt']; // altitude
950
-	    	    $data['speed'] = $line['gs']; // speed
951
-	    	    $data['heading'] = $line['heading']; // heading
952
-	    	    $data['latitude'] = $line['lat']; // lat
953
-	    	    $data['longitude'] = $line['lng']; // long
954
-	    	    $data['verticalrate'] = ''; // verticale rate
955
-	    	    $data['squawk'] = ''; // squawk
956
-	    	    $data['emergency'] = ''; // emergency
957
-	    	    //$data['datetime'] = $line['lastupdate'];
958
-	    	    $data['last_update'] = $line['lastupdate'];
959
-		    $data['datetime'] = date('Y-m-d H:i:s');
960
-	    	    $data['departure_airport_icao'] = $line['depicao'];
961
-	    	    $data['departure_airport_time'] = $line['deptime'];
962
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
963
-    		    $data['arrival_airport_time'] = $line['arrtime'];
964
-    		    $data['registration'] = $line['aircraft'];
965
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
966
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
967
-		    if (isset($line['aircraftname'])) {
942
+				$data = array();
943
+				//$data['id'] = $line['id']; // id not usable
944
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
945
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
946
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
947
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
948
+				$data['ident'] = $line['flightnum']; // ident
949
+				$data['altitude'] = $line['alt']; // altitude
950
+				$data['speed'] = $line['gs']; // speed
951
+				$data['heading'] = $line['heading']; // heading
952
+				$data['latitude'] = $line['lat']; // lat
953
+				$data['longitude'] = $line['lng']; // long
954
+				$data['verticalrate'] = ''; // verticale rate
955
+				$data['squawk'] = ''; // squawk
956
+				$data['emergency'] = ''; // emergency
957
+				//$data['datetime'] = $line['lastupdate'];
958
+				$data['last_update'] = $line['lastupdate'];
959
+			$data['datetime'] = date('Y-m-d H:i:s');
960
+				$data['departure_airport_icao'] = $line['depicao'];
961
+				$data['departure_airport_time'] = $line['deptime'];
962
+				$data['arrival_airport_icao'] = $line['arricao'];
963
+				$data['arrival_airport_time'] = $line['arrtime'];
964
+				$data['registration'] = $line['aircraft'];
965
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
966
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
967
+			if (isset($line['aircraftname'])) {
968 968
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
969 969
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
970
-	    		$aircraft_data = explode('-',$line['aircraftname']);
971
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
972
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
973
-	    		else {
974
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
975
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
976
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
977
-	    		}
978
-	    	    }
979
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
980
-    		    $data['id_source'] = $id_source;
981
-	    	    $data['format_source'] = 'phpvmacars';
982
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
983
-		    $SI->add($data);
984
-		    unset($data);
970
+				$aircraft_data = explode('-',$line['aircraftname']);
971
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
972
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
973
+				else {
974
+					$aircraft_data = explode(' ',$line['aircraftname']);
975
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
976
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
977
+				}
978
+				}
979
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
980
+				$data['id_source'] = $id_source;
981
+				$data['format_source'] = 'phpvmacars';
982
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
983
+			$SI->add($data);
984
+			unset($data);
985 985
 		}
986 986
 		if ($globalDebug) echo 'No more data...'."\n";
987 987
 		unset($buffer);
988 988
 		unset($all_data);
989
-	    }
990
-    	    //$last_exec['phpvmacars'] = time();
991
-    	    $last_exec[$id]['last'] = time();
992
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
993
-	    //$buffer = $Common->getData($hosts[$id]);
994
-	    if ($globalDebug) echo 'Get Data...'."\n";
995
-	    $buffer = $Common->getData($value['host']);
996
-	    $all_data = json_decode($buffer,true);
997
-	    if ($buffer != '' && is_array($all_data)) {
989
+		}
990
+			//$last_exec['phpvmacars'] = time();
991
+			$last_exec[$id]['last'] = time();
992
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
993
+		//$buffer = $Common->getData($hosts[$id]);
994
+		if ($globalDebug) echo 'Get Data...'."\n";
995
+		$buffer = $Common->getData($value['host']);
996
+		$all_data = json_decode($buffer,true);
997
+		if ($buffer != '' && is_array($all_data)) {
998 998
 		$reset = 0;
999 999
 		foreach ($all_data as $line) {
1000
-	    	    $data = array();
1001
-	    	    //$data['id'] = $line['id']; // id not usable
1002
-	    	    $data['id'] = trim($line['flight_id']);
1003
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1004
-	    	    $data['pilot_name'] = $line['pilot_name'];
1005
-	    	    $data['pilot_id'] = $line['pilot_id'];
1006
-	    	    $data['ident'] = trim($line['callsign']); // ident
1007
-	    	    $data['altitude'] = $line['altitude']; // altitude
1008
-	    	    $data['speed'] = $line['gs']; // speed
1009
-	    	    $data['heading'] = $line['heading']; // heading
1010
-	    	    $data['latitude'] = $line['latitude']; // lat
1011
-	    	    $data['longitude'] = $line['longitude']; // long
1012
-	    	    $data['verticalrate'] = ''; // verticale rate
1013
-	    	    $data['squawk'] = ''; // squawk
1014
-	    	    $data['emergency'] = ''; // emergency
1015
-	    	    //$data['datetime'] = $line['lastupdate'];
1016
-	    	    $data['last_update'] = $line['last_update'];
1017
-		    $data['datetime'] = date('Y-m-d H:i:s');
1018
-	    	    $data['departure_airport_icao'] = $line['departure'];
1019
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1020
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1021
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1022
-    		    //$data['registration'] = $line['aircraft'];
1023
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1024
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1025
-    		    $data['id_source'] = $id_source;
1026
-	    	    $data['format_source'] = 'vam';
1027
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1028
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1029
-		    $SI->add($data);
1030
-		    unset($data);
1000
+				$data = array();
1001
+				//$data['id'] = $line['id']; // id not usable
1002
+				$data['id'] = trim($line['flight_id']);
1003
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1004
+				$data['pilot_name'] = $line['pilot_name'];
1005
+				$data['pilot_id'] = $line['pilot_id'];
1006
+				$data['ident'] = trim($line['callsign']); // ident
1007
+				$data['altitude'] = $line['altitude']; // altitude
1008
+				$data['speed'] = $line['gs']; // speed
1009
+				$data['heading'] = $line['heading']; // heading
1010
+				$data['latitude'] = $line['latitude']; // lat
1011
+				$data['longitude'] = $line['longitude']; // long
1012
+				$data['verticalrate'] = ''; // verticale rate
1013
+				$data['squawk'] = ''; // squawk
1014
+				$data['emergency'] = ''; // emergency
1015
+				//$data['datetime'] = $line['lastupdate'];
1016
+				$data['last_update'] = $line['last_update'];
1017
+			$data['datetime'] = date('Y-m-d H:i:s');
1018
+				$data['departure_airport_icao'] = $line['departure'];
1019
+				//$data['departure_airport_time'] = $line['departure_time'];
1020
+				$data['arrival_airport_icao'] = $line['arrival'];
1021
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1022
+				//$data['registration'] = $line['aircraft'];
1023
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1024
+				$data['aircraft_icao'] = $line['plane_type'];
1025
+				$data['id_source'] = $id_source;
1026
+				$data['format_source'] = 'vam';
1027
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1028
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1029
+			$SI->add($data);
1030
+			unset($data);
1031 1031
 		}
1032 1032
 		if ($globalDebug) echo 'No more data...'."\n";
1033 1033
 		unset($buffer);
1034 1034
 		unset($all_data);
1035
-	    }
1036
-    	    //$last_exec['phpvmacars'] = time();
1037
-    	    $last_exec[$id]['last'] = time();
1035
+		}
1036
+			//$last_exec['phpvmacars'] = time();
1037
+			$last_exec[$id]['last'] = time();
1038 1038
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1039 1039
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1040
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1041
-    	    //$last_exec[$id]['last'] = time();
1040
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1041
+			//$last_exec[$id]['last'] = time();
1042 1042
 
1043
-	    //$read = array( $sockets[$id] );
1044
-	    $read = $sockets;
1045
-	    $write = NULL;
1046
-	    $e = NULL;
1047
-	    $n = socket_select($read, $write, $e, $timeout);
1048
-	    if ($e != NULL) var_dump($e);
1049
-	    if ($n > 0) {
1043
+		//$read = array( $sockets[$id] );
1044
+		$read = $sockets;
1045
+		$write = NULL;
1046
+		$e = NULL;
1047
+		$n = socket_select($read, $write, $e, $timeout);
1048
+		if ($e != NULL) var_dump($e);
1049
+		if ($n > 0) {
1050 1050
 		$reset = 0;
1051 1051
 		foreach ($read as $nb => $r) {
1052
-		    //$value = $formats[$nb];
1053
-		    $format = $globalSources[$nb]['format'];
1054
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1052
+			//$value = $formats[$nb];
1053
+			$format = $globalSources[$nb]['format'];
1054
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1055 1055
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1056
-		    } elseif ($format == 'vrstcp') {
1056
+			} elseif ($format == 'vrstcp') {
1057 1057
 			$buffer = @socket_read($r, 6000);
1058
-		    } else {
1058
+			} else {
1059 1059
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1060
-		    }
1061
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1062
-		    //echo $buffer."\n";
1063
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1064
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1065
-		    $error = false;
1066
-		    //$SI::del();
1067
-		    if ($format == 'vrstcp') {
1060
+			}
1061
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1062
+			//echo $buffer."\n";
1063
+			// lets play nice and handle signals such as ctrl-c/kill properly
1064
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1065
+			$error = false;
1066
+			//$SI::del();
1067
+			if ($format == 'vrstcp') {
1068 1068
 			$buffer = explode('},{',$buffer);
1069
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1070
-		    // SBS format is CSV format
1071
-		    if ($buffer !== FALSE && $buffer != '') {
1069
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1070
+			// SBS format is CSV format
1071
+			if ($buffer !== FALSE && $buffer != '') {
1072 1072
 			$tt[$format] = 0;
1073 1073
 			if ($format == 'acarssbs3') {
1074
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1075
-			    $ACARS->add(trim($buffer));
1076
-			    $ACARS->deleteLiveAcarsData();
1074
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1075
+				$ACARS->add(trim($buffer));
1076
+				$ACARS->deleteLiveAcarsData();
1077 1077
 			} elseif ($format == 'raw') {
1078
-			    // AVR format
1079
-			    $data = $SBS->parse($buffer);
1080
-			    if (is_array($data)) {
1078
+				// AVR format
1079
+				$data = $SBS->parse($buffer);
1080
+				if (is_array($data)) {
1081 1081
 				$data['datetime'] = date('Y-m-d H:i:s');
1082 1082
 				$data['format_source'] = 'raw';
1083 1083
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1084 1084
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1085 1085
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1086 1086
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1087
-			    }
1087
+				}
1088 1088
 			} elseif ($format == 'ais') {
1089
-			    $ais_data = $AIS->parse_line(trim($buffer));
1090
-			    $data = array();
1091
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1092
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1093
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1094
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1095
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1096
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1097
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1098
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1099
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1100
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1101
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1102
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1103
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1104
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1089
+				$ais_data = $AIS->parse_line(trim($buffer));
1090
+				$data = array();
1091
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1092
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1093
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1094
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1095
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1096
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1097
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1098
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1099
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1100
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1101
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1102
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1103
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1104
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1105 1105
 
1106
-			    if (isset($ais_data['timestamp'])) {
1106
+				if (isset($ais_data['timestamp'])) {
1107 1107
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1108
-			    } else {
1108
+				} else {
1109 1109
 				$data['datetime'] = date('Y-m-d H:i:s');
1110
-			    }
1111
-			    $data['format_source'] = 'aisnmea';
1112
-    			    $data['id_source'] = $id_source;
1113
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1114
-			    unset($data);
1115
-                        } elseif ($format == 'flightgearsp') {
1116
-                    	    //echo $buffer."\n";
1117
-                    	    if (strlen($buffer) > 5) {
1110
+				}
1111
+				$data['format_source'] = 'aisnmea';
1112
+					$data['id_source'] = $id_source;
1113
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1114
+				unset($data);
1115
+						} elseif ($format == 'flightgearsp') {
1116
+							//echo $buffer."\n";
1117
+							if (strlen($buffer) > 5) {
1118 1118
 				$line = explode(',',$buffer);
1119 1119
 				$data = array();
1120 1120
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1131,38 +1131,38 @@  discard block
 block discarded – undo
1131 1131
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1132 1132
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1133 1133
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1134
-			    }
1135
-                        } elseif ($format == 'acars') {
1136
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1137
-			    $ACARS->add(trim($buffer));
1138
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1139
-			    $ACARS->deleteLiveAcarsData();
1134
+				}
1135
+						} elseif ($format == 'acars') {
1136
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1137
+				$ACARS->add(trim($buffer));
1138
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1139
+				$ACARS->deleteLiveAcarsData();
1140 1140
 			} elseif ($format == 'flightgearmp') {
1141
-			    if (substr($buffer,0,1) != '#') {
1141
+				if (substr($buffer,0,1) != '#') {
1142 1142
 				$data = array();
1143 1143
 				//echo $buffer."\n";
1144 1144
 				$line = explode(' ',$buffer);
1145 1145
 				if (count($line) == 11) {
1146
-				    $userserver = explode('@',$line[0]);
1147
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1148
-				    $data['ident'] = $userserver[0];
1149
-				    $data['registration'] = $userserver[0];
1150
-				    $data['latitude'] = $line[4];
1151
-				    $data['longitude'] = $line[5];
1152
-				    $data['altitude'] = $line[6];
1153
-				    $data['datetime'] = date('Y-m-d H:i:s');
1154
-				    $aircraft_type = $line[10];
1155
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1156
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1157
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1158
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1146
+					$userserver = explode('@',$line[0]);
1147
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1148
+					$data['ident'] = $userserver[0];
1149
+					$data['registration'] = $userserver[0];
1150
+					$data['latitude'] = $line[4];
1151
+					$data['longitude'] = $line[5];
1152
+					$data['altitude'] = $line[6];
1153
+					$data['datetime'] = date('Y-m-d H:i:s');
1154
+					$aircraft_type = $line[10];
1155
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1156
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1157
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1158
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1159
+				}
1159 1160
 				}
1160
-			    }
1161 1161
 			} elseif ($format == 'beast') {
1162
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1163
-			    die;
1162
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1163
+				die;
1164 1164
 			} elseif ($format == 'vrstcp') {
1165
-			    foreach($buffer as $all_data) {
1165
+				foreach($buffer as $all_data) {
1166 1166
 				$line = json_decode('{'.$all_data.'}',true);
1167 1167
 				$data = array();
1168 1168
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1182,112 +1182,112 @@  discard block
 block discarded – undo
1182 1182
 				*/
1183 1183
 				$data['datetime'] = date('Y-m-d H:i:s');
1184 1184
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1185
-		    		$data['format_source'] = 'vrstcp';
1185
+					$data['format_source'] = 'vrstcp';
1186 1186
 				$data['id_source'] = $id_source;
1187 1187
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1188 1188
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1189 1189
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1190 1190
 				unset($data);
1191
-			    }
1191
+				}
1192 1192
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1193
-			    $line = explode("\t", $buffer);
1194
-			    for($k = 0; $k < count($line); $k=$k+2) {
1193
+				$line = explode("\t", $buffer);
1194
+				for($k = 0; $k < count($line); $k=$k+2) {
1195 1195
 				$key = $line[$k];
1196
-			        $lined[$key] = $line[$k+1];
1197
-			    }
1198
-    			    if (count($lined) > 3) {
1199
-    				$data['hex'] = $lined['hexid'];
1200
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1201
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1202
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1203
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1204
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1205
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1206
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1207
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1208
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1209
-    				$data['id_source'] = $id_source;
1210
-    				$data['format_source'] = 'tsv';
1211
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1212
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1196
+					$lined[$key] = $line[$k+1];
1197
+				}
1198
+					if (count($lined) > 3) {
1199
+					$data['hex'] = $lined['hexid'];
1200
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1201
+					$data['datetime'] = date('Y-m-d H:i:s');;
1202
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1203
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1204
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1205
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1206
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1207
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1208
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1209
+					$data['id_source'] = $id_source;
1210
+					$data['format_source'] = 'tsv';
1211
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1212
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1213 1213
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1214
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1215
-    				unset($lined);
1216
-    				unset($data);
1217
-    			    } else $error = true;
1214
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1215
+					unset($lined);
1216
+					unset($data);
1217
+					} else $error = true;
1218 1218
 			} elseif ($format == 'aprs' && $use_aprs) {
1219
-			    if ($aprs_connect == 0) {
1219
+				if ($aprs_connect == 0) {
1220 1220
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1221 1221
 				$aprs_connect = 1;
1222
-			    }
1222
+				}
1223 1223
 			    
1224
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1224
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1225 1225
 				$aprs_last_tx = time();
1226 1226
 				$data_aprs = "# Keep alive";
1227 1227
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1228
-			    }
1228
+				}
1229 1229
 			    
1230
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1231
-			    //echo 'APRS data : '.$buffer."\n";
1232
-			    $buffer = str_replace('APRS <- ','',$buffer);
1233
-			    $buffer = str_replace('APRS -> ','',$buffer);
1234
-			    //echo $buffer."\n";
1235
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1230
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1231
+				//echo 'APRS data : '.$buffer."\n";
1232
+				$buffer = str_replace('APRS <- ','',$buffer);
1233
+				$buffer = str_replace('APRS -> ','',$buffer);
1234
+				//echo $buffer."\n";
1235
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1236 1236
 				$line = $APRS->parse($buffer);
1237 1237
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1238 1238
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1239
-				    $aprs_last_tx = time();
1240
-				    $data = array();
1241
-				    //print_r($line);
1242
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1243
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1244
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1245
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1246
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1247
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1248
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1249
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1250
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1251
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1252
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1253
-				    $data['latitude'] = $line['latitude'];
1254
-				    $data['longitude'] = $line['longitude'];
1255
-				    //$data['verticalrate'] = $line[16];
1256
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1257
-				    else $data['speed'] = 0;
1258
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1259
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1260
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1261
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1262
-				    //else $data['heading'] = 0;
1263
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1264
-				    if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1265
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1266
-    				    $data['id_source'] = $id_source;
1267
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1268
-				    else $data['format_source'] = 'aprs';
1269
-				    $data['source_name'] = $line['source'];
1270
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1271
-				    else $data['source_type'] = 'flarm';
1272
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1273
-				    $currentdate = date('Y-m-d H:i:s');
1274
-				    $aprsdate = strtotime($data['datetime']);
1275
-				    // Accept data if time <= system time + 20s
1276
-				    //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'])))) {
1277
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1239
+					$aprs_last_tx = time();
1240
+					$data = array();
1241
+					//print_r($line);
1242
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1243
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1244
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1245
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1246
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1247
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1248
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1249
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1250
+					else $data['datetime'] = date('Y-m-d H:i:s');
1251
+					//$data['datetime'] = date('Y-m-d H:i:s');
1252
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1253
+					$data['latitude'] = $line['latitude'];
1254
+					$data['longitude'] = $line['longitude'];
1255
+					//$data['verticalrate'] = $line[16];
1256
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1257
+					else $data['speed'] = 0;
1258
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1259
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1260
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1261
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1262
+					//else $data['heading'] = 0;
1263
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1264
+					if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1265
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1266
+						$data['id_source'] = $id_source;
1267
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1268
+					else $data['format_source'] = 'aprs';
1269
+					$data['source_name'] = $line['source'];
1270
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1271
+					else $data['source_type'] = 'flarm';
1272
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1273
+					$currentdate = date('Y-m-d H:i:s');
1274
+					$aprsdate = strtotime($data['datetime']);
1275
+					// Accept data if time <= system time + 20s
1276
+					//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'])))) {
1277
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1278 1278
 					$send = $SI->add($data);
1279
-				    } elseif ($data['source_type'] == 'ais') {
1279
+					} elseif ($data['source_type'] == 'ais') {
1280 1280
 					echo 'add...'."\n";
1281 1281
 					$send = $MI->add($data);
1282
-				    } elseif (isset($line['stealth'])) {
1282
+					} elseif (isset($line['stealth'])) {
1283 1283
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1284 1284
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1285
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1286
-				    } 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') {
1285
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1286
+					} 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') {
1287 1287
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1288 1288
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1289
-				    }
1290
-				    unset($data);
1289
+					}
1290
+					unset($data);
1291 1291
 				} 
1292 1292
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1293 1293
 					echo '!! Weather Station not yet supported'."\n";
@@ -1297,12 +1297,12 @@  discard block
 block discarded – undo
1297 1297
 				}
1298 1298
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1299 1299
 				//elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1300
-			    }
1300
+				}
1301 1301
 			} else {
1302
-			    $line = explode(',', $buffer);
1303
-    			    if (count($line) > 20) {
1304
-    			    	$data['hex'] = $line[4];
1305
-    				/*
1302
+				$line = explode(',', $buffer);
1303
+					if (count($line) > 20) {
1304
+						$data['hex'] = $line[4];
1305
+					/*
1306 1306
     				$data['datetime'] = $line[6].' '.$line[7];
1307 1307
     					date_default_timezone_set($globalTimezone);
1308 1308
     					$datetime = new DateTime($data['datetime']);
@@ -1310,30 +1310,30 @@  discard block
 block discarded – undo
1310 1310
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1311 1311
     					date_default_timezone_set('UTC');
1312 1312
     				*/
1313
-    				// Force datetime to current UTC datetime
1314
-    				date_default_timezone_set('UTC');
1315
-    				$data['datetime'] = date('Y-m-d H:i:s');
1316
-    				$data['ident'] = trim($line[10]);
1317
-    				$data['latitude'] = $line[14];
1318
-    				$data['longitude'] = $line[15];
1319
-    				$data['verticalrate'] = $line[16];
1320
-    				$data['emergency'] = $line[20];
1321
-    				$data['speed'] = $line[12];
1322
-    				$data['squawk'] = $line[17];
1323
-    				$data['altitude'] = $line[11];
1324
-    				$data['heading'] = $line[13];
1325
-    				$data['ground'] = $line[21];
1326
-    				$data['emergency'] = $line[19];
1327
-    				$data['format_source'] = 'sbs';
1313
+					// Force datetime to current UTC datetime
1314
+					date_default_timezone_set('UTC');
1315
+					$data['datetime'] = date('Y-m-d H:i:s');
1316
+					$data['ident'] = trim($line[10]);
1317
+					$data['latitude'] = $line[14];
1318
+					$data['longitude'] = $line[15];
1319
+					$data['verticalrate'] = $line[16];
1320
+					$data['emergency'] = $line[20];
1321
+					$data['speed'] = $line[12];
1322
+					$data['squawk'] = $line[17];
1323
+					$data['altitude'] = $line[11];
1324
+					$data['heading'] = $line[13];
1325
+					$data['ground'] = $line[21];
1326
+					$data['emergency'] = $line[19];
1327
+					$data['format_source'] = 'sbs';
1328 1328
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1329
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1329
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1330 1330
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1331
-    				$data['id_source'] = $id_source;
1332
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1333
-    				else $error = true;
1334
-    				unset($data);
1335
-    			    } else $error = true;
1336
-			    if ($error) {
1331
+					$data['id_source'] = $id_source;
1332
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1333
+					else $error = true;
1334
+					unset($data);
1335
+					} else $error = true;
1336
+				if ($error) {
1337 1337
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1338 1338
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1339 1339
 				} else {
@@ -1349,13 +1349,13 @@  discard block
 block discarded – undo
1349 1349
 					connect_all($sourceer);
1350 1350
 					$sourceer = array();
1351 1351
 				}
1352
-			    }
1352
+				}
1353 1353
 			}
1354 1354
 			// Sleep for xxx microseconds
1355 1355
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1356
-		    } else {
1356
+			} else {
1357 1357
 			if ($format == 'flightgearmp') {
1358
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1358
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1359 1359
 				//@socket_close($r);
1360 1360
 				sleep($globalMinFetch);
1361 1361
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1364,9 +1364,9 @@  discard block
 block discarded – undo
1364 1364
 				break;
1365 1365
 				
1366 1366
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1367
-			    if (isset($tt[$format])) $tt[$format]++;
1368
-			    else $tt[$format] = 0;
1369
-			    if ($tt[$format] > 30) {
1367
+				if (isset($tt[$format])) $tt[$format]++;
1368
+				else $tt[$format] = 0;
1369
+				if ($tt[$format] > 30) {
1370 1370
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1371 1371
 				//@socket_close($r);
1372 1372
 				sleep(2);
@@ -1377,23 +1377,23 @@  discard block
 block discarded – undo
1377 1377
 				//connect_all($globalSources);
1378 1378
 				$tt[$format]=0;
1379 1379
 				break;
1380
-			    }
1380
+				}
1381
+			}
1381 1382
 			}
1382
-		    }
1383 1383
 		}
1384
-	    } else {
1384
+		} else {
1385 1385
 		$error = socket_strerror(socket_last_error());
1386 1386
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1387 1387
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1388 1388
 			if (isset($globalDebug)) echo "Restarting...\n";
1389 1389
 			// Restart the script if possible
1390 1390
 			if (is_array($sockets)) {
1391
-			    if ($globalDebug) echo "Shutdown all sockets...";
1391
+				if ($globalDebug) echo "Shutdown all sockets...";
1392 1392
 			    
1393
-			    foreach ($sockets as $sock) {
1393
+				foreach ($sockets as $sock) {
1394 1394
 				@socket_shutdown($sock,2);
1395 1395
 				@socket_close($sock);
1396
-			    }
1396
+				}
1397 1397
 			    
1398 1398
 			}
1399 1399
 			if ($globalDebug) echo "Waiting...";
@@ -1408,13 +1408,13 @@  discard block
 block discarded – undo
1408 1408
 			if ($globalDebug) echo "Restart all connections...";
1409 1409
 			connect_all($globalSources);
1410 1410
 		}
1411
-	    }
1411
+		}
1412 1412
 	}
1413 1413
 	if ($globalDaemon === false) {
1414
-	    if ($globalDebug) echo 'Check all...'."\n";
1415
-	    $SI->checkAll();
1414
+		if ($globalDebug) echo 'Check all...'."\n";
1415
+		$SI->checkAll();
1416
+	}
1416 1417
 	}
1417
-    }
1418 1418
 }
1419 1419
 
1420 1420
 ?>
Please login to merge, or discard this patch.