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