Completed
Push — master ( a5f6b5...8ae583 )
by Yannick
07:18
created
scripts/daemon-spotter.php 1 patch
Indentation   +691 added lines, -691 removed lines patch added patch discarded remove patch
@@ -19,44 +19,44 @@  discard block
 block discarded – undo
19 19
 // Check if schema is at latest version
20 20
 $Connection = new Connection();
21 21
 if ($Connection->latest() === false) {
22
-    echo "You MUST update to latest schema. Run install/index.php";
23
-    exit();
22
+	echo "You MUST update to latest schema. Run install/index.php";
23
+	exit();
24 24
 }
25 25
 
26 26
 
27 27
 // This is to be compatible with old version of settings.php
28 28
 if (!isset($globalSources)) {
29
-    if (isset($globalSBS1Hosts)) {
30
-        //$hosts = $globalSBS1Hosts;
31
-        foreach ($globalSBS1Hosts as $host) {
32
-	    $globalSources[] = array('host' => $host);
33
-    	}
34
-    } else {
35
-        if (!isset($globalSBS1Host)) {
36
-	    echo '$globalSources MUST be defined !';
37
-	    die;
29
+	if (isset($globalSBS1Hosts)) {
30
+		//$hosts = $globalSBS1Hosts;
31
+		foreach ($globalSBS1Hosts as $host) {
32
+		$globalSources[] = array('host' => $host);
33
+		}
34
+	} else {
35
+		if (!isset($globalSBS1Host)) {
36
+		echo '$globalSources MUST be defined !';
37
+		die;
38 38
 	}
39 39
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
40 40
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
41
-    }
41
+	}
42 42
 }
43 43
 
44 44
 $options = getopt('s::',array('source::','server','idsource::'));
45 45
 //if (isset($options['s'])) $hosts = array($options['s']);
46 46
 //elseif (isset($options['source'])) $hosts = array($options['source']);
47 47
 if (isset($options['s'])) {
48
-    $globalSources = array();
49
-    $globalSources[] = array('host' => $options['s']);
48
+	$globalSources = array();
49
+	$globalSources[] = array('host' => $options['s']);
50 50
 } elseif (isset($options['source'])) {
51
-    $globalSources = array();
52
-    $globalSources[] = array('host' => $options['source']);
51
+	$globalSources = array();
52
+	$globalSources[] = array('host' => $options['source']);
53 53
 }
54 54
 if (isset($options['server'])) $globalServer = TRUE;
55 55
 if (isset($options['idsource'])) $id_source = $options['idsource'];
56 56
 else $id_source = 1;
57 57
 if (isset($globalServer) && $globalServer) {
58
-    if ($globalDebug) echo "Using Server Mode\n";
59
-    $SI=new SpotterServer();
58
+	if ($globalDebug) echo "Using Server Mode\n";
59
+	$SI=new SpotterServer();
60 60
 } else $SI=new SpotterImport($Connection->db);
61 61
 //$APRS=new APRS($Connection->db);
62 62
 $SBS=new SBS();
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 //$servertz = system('date +%Z');
67 67
 // signal handler - playing nice with sockets and dump1090
68 68
 if (function_exists('pcntl_fork')) {
69
-    pcntl_signal(SIGINT,  function() {
70
-        global $sockets;
71
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
72
-        die("Bye!\n");
73
-    });
74
-    pcntl_signal_dispatch();
69
+	pcntl_signal(SIGINT,  function() {
70
+		global $sockets;
71
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
72
+		die("Bye!\n");
73
+	});
74
+	pcntl_signal_dispatch();
75 75
 }
76 76
 
77 77
 // let's try and connect
@@ -80,161 +80,161 @@  discard block
 block discarded – undo
80 80
 $aprs_full = false;
81 81
 
82 82
 function create_socket($host, $port, &$errno, &$errstr) {
83
-    $ip = gethostbyname($host);
84
-    $s = socket_create(AF_INET, SOCK_STREAM, 0);
85
-    $r = @socket_connect($s, $ip, $port);
86
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
87
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
88
-        return $s;
89
-    }
90
-    $errno = socket_last_error($s);
91
-    $errstr = socket_strerror($errno);
92
-    socket_close($s);
93
-    return false;
83
+	$ip = gethostbyname($host);
84
+	$s = socket_create(AF_INET, SOCK_STREAM, 0);
85
+	$r = @socket_connect($s, $ip, $port);
86
+	if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
87
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
88
+		return $s;
89
+	}
90
+	$errno = socket_last_error($s);
91
+	$errstr = socket_strerror($errno);
92
+	socket_close($s);
93
+	return false;
94 94
 }
95 95
 
96 96
 function create_socket_udp($host, $port, &$errno, &$errstr) {
97
-    echo "UDP !!";
98
-    $ip = gethostbyname($host);
99
-    $s = socket_create(AF_INET, SOCK_DGRAM, 0);
100
-    $r = @socket_bind($s, $ip, $port);
101
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
102
-        return $s;
103
-    }
104
-    $errno = socket_last_error($s);
105
-    $errstr = socket_strerror($errno);
106
-    socket_close($s);
107
-    return false;
97
+	echo "UDP !!";
98
+	$ip = gethostbyname($host);
99
+	$s = socket_create(AF_INET, SOCK_DGRAM, 0);
100
+	$r = @socket_bind($s, $ip, $port);
101
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
102
+		return $s;
103
+	}
104
+	$errno = socket_last_error($s);
105
+	$errstr = socket_strerror($errno);
106
+	socket_close($s);
107
+	return false;
108 108
 }
109 109
 
110 110
 function connect_all($hosts) {
111
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
112
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
113
-    if ($globalDebug) echo 'Connect to all...'."\n";
114
-    foreach ($hosts as $id => $value) {
111
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
112
+	global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
113
+	if ($globalDebug) echo 'Connect to all...'."\n";
114
+	foreach ($hosts as $id => $value) {
115 115
 	$host = $value['host'];
116 116
 	$globalSources[$id]['last_exec'] = 0;
117 117
 	// Here we check type of source(s)
118 118
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
119
-            if (preg_match('/deltadb.txt$/i',$host)) {
120
-        	//$formats[$id] = 'deltadbtxt';
121
-        	$globalSources[$id]['format'] = 'deltadbtxt';
122
-        	//$last_exec['deltadbtxt'] = 0;
123
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
124
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
125
-        	//$formats[$id] = 'vatsimtxt';
126
-        	$globalSources[$id]['format'] = 'vatsimtxt';
127
-        	//$last_exec['vatsimtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
129
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
130
-        	//$formats[$id] = 'aircraftlistjson';
131
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
132
-        	//$last_exec['aircraftlistjson'] = 0;
133
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
134
-    	    } else if (preg_match('/opensky/i',$host)) {
135
-        	//$formats[$id] = 'aircraftlistjson';
136
-        	$globalSources[$id]['format'] = 'opensky';
137
-        	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
139
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
140
-        	//$formats[$id] = 'radarvirtueljson';
141
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
142
-        	//$last_exec['radarvirtueljson'] = 0;
143
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
144
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
145
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
146
-        	    exit(0);
147
-        	}
148
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
149
-        	//$formats[$id] = 'planeupdatefaa';
150
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
151
-        	//$last_exec['planeupdatefaa'] = 0;
152
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
153
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
154
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
155
-        	    exit(0);
156
-        	}
157
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
158
-        	//$formats[$id] = 'phpvmacars';
159
-        	$globalSources[$id]['format'] = 'phpvmacars';
160
-        	//$last_exec['phpvmacars'] = 0;
161
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
162
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
163
-        	//$formats[$id] = 'phpvmacars';
164
-        	$globalSources[$id]['format'] = 'vam';
165
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
166
-            } else if (preg_match('/whazzup/i',$host)) {
167
-        	//$formats[$id] = 'whazzup';
168
-        	$globalSources[$id]['format'] = 'whazzup';
169
-        	//$last_exec['whazzup'] = 0;
170
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
171
-            } else if (preg_match('/recentpireps/i',$host)) {
172
-        	//$formats[$id] = 'pirepsjson';
173
-        	$globalSources[$id]['format'] = 'pirepsjson';
174
-        	//$last_exec['pirepsjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
176
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
177
-        	//$formats[$id] = 'fr24json';
178
-        	$globalSources[$id]['format'] = 'fr24json';
179
-        	//$last_exec['fr24json'] = 0;
180
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
181
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
182
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
183
-        	    exit(0);
184
-        	}
185
-            //} else if (preg_match('/10001/',$host)) {
186
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
187
-        	//$formats[$id] = 'tsv';
188
-        	$globalSources[$id]['format'] = 'tsv';
189
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
190
-            }
191
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
192
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
193
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
194
-	    $hostport = explode(':',$host);
195
-	    if (isset($hostport[1])) {
119
+			if (preg_match('/deltadb.txt$/i',$host)) {
120
+			//$formats[$id] = 'deltadbtxt';
121
+			$globalSources[$id]['format'] = 'deltadbtxt';
122
+			//$last_exec['deltadbtxt'] = 0;
123
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
124
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
125
+			//$formats[$id] = 'vatsimtxt';
126
+			$globalSources[$id]['format'] = 'vatsimtxt';
127
+			//$last_exec['vatsimtxt'] = 0;
128
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
129
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
130
+			//$formats[$id] = 'aircraftlistjson';
131
+			$globalSources[$id]['format'] = 'aircraftlistjson';
132
+			//$last_exec['aircraftlistjson'] = 0;
133
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
134
+			} else if (preg_match('/opensky/i',$host)) {
135
+			//$formats[$id] = 'aircraftlistjson';
136
+			$globalSources[$id]['format'] = 'opensky';
137
+			//$last_exec['aircraftlistjson'] = 0;
138
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
139
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
140
+			//$formats[$id] = 'radarvirtueljson';
141
+			$globalSources[$id]['format'] = 'radarvirtueljson';
142
+			//$last_exec['radarvirtueljson'] = 0;
143
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
144
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
145
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
146
+				exit(0);
147
+			}
148
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
149
+			//$formats[$id] = 'planeupdatefaa';
150
+			$globalSources[$id]['format'] = 'planeupdatefaa';
151
+			//$last_exec['planeupdatefaa'] = 0;
152
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
153
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
154
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
155
+				exit(0);
156
+			}
157
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
158
+			//$formats[$id] = 'phpvmacars';
159
+			$globalSources[$id]['format'] = 'phpvmacars';
160
+			//$last_exec['phpvmacars'] = 0;
161
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
162
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
163
+			//$formats[$id] = 'phpvmacars';
164
+			$globalSources[$id]['format'] = 'vam';
165
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
166
+			} else if (preg_match('/whazzup/i',$host)) {
167
+			//$formats[$id] = 'whazzup';
168
+			$globalSources[$id]['format'] = 'whazzup';
169
+			//$last_exec['whazzup'] = 0;
170
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
171
+			} else if (preg_match('/recentpireps/i',$host)) {
172
+			//$formats[$id] = 'pirepsjson';
173
+			$globalSources[$id]['format'] = 'pirepsjson';
174
+			//$last_exec['pirepsjson'] = 0;
175
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
176
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
177
+			//$formats[$id] = 'fr24json';
178
+			$globalSources[$id]['format'] = 'fr24json';
179
+			//$last_exec['fr24json'] = 0;
180
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
181
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
182
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
183
+				exit(0);
184
+			}
185
+			//} else if (preg_match('/10001/',$host)) {
186
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
187
+			//$formats[$id] = 'tsv';
188
+			$globalSources[$id]['format'] = 'tsv';
189
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
190
+			}
191
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
192
+			if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
193
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
194
+		$hostport = explode(':',$host);
195
+		if (isset($hostport[1])) {
196 196
 		$port = $hostport[1];
197 197
 		$hostn = $hostport[0];
198
-	    } else {
198
+		} else {
199 199
 		$port = $globalSources[$id]['port'];
200 200
 		$hostn = $globalSources[$id]['host'];
201
-	    }
202
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
203
-        	$s = create_socket($hostn,$port, $errno, $errstr);
204
-    	    } else {
205
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
206
-	    }
207
-	    if ($s) {
208
-    	        $sockets[$id] = $s;
209
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
210
-		    if (preg_match('/aprs/',$hostn)) {
201
+		}
202
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
203
+			$s = create_socket($hostn,$port, $errno, $errstr);
204
+			} else {
205
+			$s = create_socket_udp($hostn,$port, $errno, $errstr);
206
+		}
207
+		if ($s) {
208
+				$sockets[$id] = $s;
209
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
210
+			if (preg_match('/aprs/',$hostn)) {
211 211
 			//$formats[$id] = 'aprs';
212 212
 			$globalSources[$id]['format'] = 'aprs';
213 213
 			//$aprs_connect = 0;
214 214
 			//$use_aprs = true;
215
-    		    } elseif ($port == '10001') {
216
-        		//$formats[$id] = 'tsv';
217
-        		$globalSources[$id]['format'] = 'tsv';
218
-		    } elseif ($port == '30002') {
219
-        		//$formats[$id] = 'raw';
220
-        		$globalSources[$id]['format'] = 'raw';
221
-		    } elseif ($port == '5001') {
222
-        		//$formats[$id] = 'raw';
223
-        		$globalSources[$id]['format'] = 'flightgearmp';
224
-		    } elseif ($port == '30005') {
215
+				} elseif ($port == '10001') {
216
+				//$formats[$id] = 'tsv';
217
+				$globalSources[$id]['format'] = 'tsv';
218
+			} elseif ($port == '30002') {
219
+				//$formats[$id] = 'raw';
220
+				$globalSources[$id]['format'] = 'raw';
221
+			} elseif ($port == '5001') {
222
+				//$formats[$id] = 'raw';
223
+				$globalSources[$id]['format'] = 'flightgearmp';
224
+			} elseif ($port == '30005') {
225 225
 			// Not yet supported
226
-        		//$formats[$id] = 'beast';
227
-        		$globalSources[$id]['format'] = 'beast';
228
-		    //} else $formats[$id] = 'sbs';
229
-		    } else $globalSources[$id]['format'] = 'sbs';
230
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
226
+				//$formats[$id] = 'beast';
227
+				$globalSources[$id]['format'] = 'beast';
228
+			//} else $formats[$id] = 'sbs';
229
+			} else $globalSources[$id]['format'] = 'sbs';
230
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
231 231
 		}
232 232
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
233
-            } else {
233
+			} else {
234 234
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
235
-    	    }
236
-        }
237
-    }
235
+			}
236
+		}
237
+	}
238 238
 }
239 239
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
240 240
 
@@ -261,18 +261,18 @@  discard block
 block discarded – undo
261 261
 	die;
262 262
 }
263 263
 foreach ($globalSources as $key => $source) {
264
-    if (!isset($source['format'])) {
265
-        $globalSources[$key]['format'] = 'auto';
266
-    }
264
+	if (!isset($source['format'])) {
265
+		$globalSources[$key]['format'] = 'auto';
266
+	}
267 267
 }
268 268
 connect_all($globalSources);
269 269
 foreach ($globalSources as $key => $source) {
270
-    if (isset($source['format']) && $source['format'] == 'aprs') {
270
+	if (isset($source['format']) && $source['format'] == 'aprs') {
271 271
 	$aprs_connect = 0;
272 272
 	$use_aprs = true;
273 273
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
274 274
 	break;
275
-    }
275
+	}
276 276
 }
277 277
 
278 278
 if ($use_aprs) {
@@ -312,67 +312,67 @@  discard block
 block discarded – undo
312 312
 
313 313
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
314 314
 while ($i > 0) {
315
-    if (!$globalDaemon) $i = $endtime-time();
316
-    // Delete old ATC
317
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
315
+	if (!$globalDaemon) $i = $endtime-time();
316
+	// Delete old ATC
317
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
318 318
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
319
-        $ATC->deleteOldATC();
320
-    }
319
+		$ATC->deleteOldATC();
320
+	}
321 321
     
322
-    if (count($last_exec) > 0) {
322
+	if (count($last_exec) > 0) {
323 323
 	$max = $globalMinFetch;
324 324
 	foreach ($last_exec as $last) {
325
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
325
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
326 326
 	}
327 327
 	if ($max != $globalMinFetch) {
328
-	    if ($globalDebug) echo 'Sleeping...'."\n";
329
-	    sleep($globalMinFetch-$max+2);
328
+		if ($globalDebug) echo 'Sleeping...'."\n";
329
+		sleep($globalMinFetch-$max+2);
330
+	}
330 331
 	}
331
-    }
332 332
 
333 333
     
334
-    //foreach ($formats as $id => $value) {
335
-    foreach ($globalSources as $id => $value) {
334
+	//foreach ($formats as $id => $value) {
335
+	foreach ($globalSources as $id => $value) {
336 336
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
337 337
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
338
-	    //$buffer = $Common->getData($hosts[$id]);
339
-	    $buffer = $Common->getData($value['host']);
340
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
341
-	    $buffer = explode('\n',$buffer);
342
-	    foreach ($buffer as $line) {
343
-    		if ($line != '') {
344
-    		    $line = explode(',', $line);
345
-	            $data = array();
346
-	            $data['hex'] = $line[1]; // hex
347
-	            $data['ident'] = $line[2]; // ident
348
-	            $data['altitude'] = $line[3]; // altitude
349
-	            $data['speed'] = $line[4]; // speed
350
-	            $data['heading'] = $line[5]; // heading
351
-	            $data['latitude'] = $line[6]; // lat
352
-	            $data['longitude'] = $line[7]; // long
353
-	            $data['verticalrate'] = ''; // vertical rate
354
-	            $data['squawk'] = ''; // squawk
355
-	            $data['emergency'] = ''; // emergency
356
-		    $data['datetime'] = date('Y-m-d H:i:s');
357
-		    $data['format_source'] = 'deltadbtxt';
358
-    		    $data['id_source'] = $id_source;
359
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
360
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
361
-    		    $SI->add($data);
362
-		    unset($data);
363
-    		}
364
-    	    }
365
-    	    $last_exec[$id]['last'] = time();
338
+		//$buffer = $Common->getData($hosts[$id]);
339
+		$buffer = $Common->getData($value['host']);
340
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
341
+		$buffer = explode('\n',$buffer);
342
+		foreach ($buffer as $line) {
343
+			if ($line != '') {
344
+				$line = explode(',', $line);
345
+				$data = array();
346
+				$data['hex'] = $line[1]; // hex
347
+				$data['ident'] = $line[2]; // ident
348
+				$data['altitude'] = $line[3]; // altitude
349
+				$data['speed'] = $line[4]; // speed
350
+				$data['heading'] = $line[5]; // heading
351
+				$data['latitude'] = $line[6]; // lat
352
+				$data['longitude'] = $line[7]; // long
353
+				$data['verticalrate'] = ''; // vertical rate
354
+				$data['squawk'] = ''; // squawk
355
+				$data['emergency'] = ''; // emergency
356
+			$data['datetime'] = date('Y-m-d H:i:s');
357
+			$data['format_source'] = 'deltadbtxt';
358
+				$data['id_source'] = $id_source;
359
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
360
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
361
+				$SI->add($data);
362
+			unset($data);
363
+			}
364
+			}
365
+			$last_exec[$id]['last'] = time();
366 366
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
367 367
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value[' last_exec'] > $globalMinFetch))) {
368
-	    //$buffer = $Common->getData($hosts[$id]);
369
-	    $buffer = $Common->getData($value['host']);
370
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
371
-	    $buffer = explode('\n',$buffer);
372
-	    foreach ($buffer as $line) {
373
-    		if ($line != '') {
374
-    		    $line = explode(':', $line);
375
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
368
+		//$buffer = $Common->getData($hosts[$id]);
369
+		$buffer = $Common->getData($value['host']);
370
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
371
+		$buffer = explode('\n',$buffer);
372
+		foreach ($buffer as $line) {
373
+			if ($line != '') {
374
+				$line = explode(':', $line);
375
+				if (count($line) > 30 && $line[0] != 'callsign') {
376 376
 			$data = array();
377 377
 			$data['id'] = $line[1].'-'.$line[0];
378 378
 			$data['pilot_id'] = $line[1];
@@ -384,36 +384,36 @@  discard block
 block discarded – undo
384 384
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
385 385
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
386 386
 			$data['latitude'] = $line[5]; // lat
387
-	        	$data['longitude'] = $line[6]; // long
388
-	        	$data['verticalrate'] = ''; // vertical rate
389
-	        	$data['squawk'] = ''; // squawk
390
-	        	$data['emergency'] = ''; // emergency
391
-	        	$data['waypoints'] = $line[30];
387
+				$data['longitude'] = $line[6]; // long
388
+				$data['verticalrate'] = ''; // vertical rate
389
+				$data['squawk'] = ''; // squawk
390
+				$data['emergency'] = ''; // emergency
391
+				$data['waypoints'] = $line[30];
392 392
 			$data['datetime'] = date('Y-m-d H:i:s');
393 393
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
394 394
 			if (isset($line[37])) $data['last_update'] = $line[37];
395
-		        $data['departure_airport_icao'] = $line[11];
396
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
397
-		        $data['arrival_airport_icao'] = $line[13];
395
+				$data['departure_airport_icao'] = $line[11];
396
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
397
+				$data['arrival_airport_icao'] = $line[13];
398 398
 			$data['frequency'] = $line[4];
399 399
 			$data['type'] = $line[18];
400 400
 			$data['range'] = $line[19];
401 401
 			if (isset($line[35])) $data['info'] = $line[35];
402
-    			$data['id_source'] = $id_source;
403
-	    		//$data['arrival_airport_time'] = ;
404
-	    		if ($line[9] != '') {
405
-	    		    $aircraft_data = explode('/',$line[9]);
406
-	    		    if (isset($aircraft_data[1])) {
407
-	    			$data['aircraft_icao'] = $aircraft_data[1];
408
-	    		    }
409
-        		}
410
-	    		/*
402
+				$data['id_source'] = $id_source;
403
+				//$data['arrival_airport_time'] = ;
404
+				if ($line[9] != '') {
405
+					$aircraft_data = explode('/',$line[9]);
406
+					if (isset($aircraft_data[1])) {
407
+					$data['aircraft_icao'] = $aircraft_data[1];
408
+					}
409
+				}
410
+				/*
411 411
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
412 412
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
413 413
 	    		*/
414
-	    		$data['format_source'] = $value['format'];
414
+				$data['format_source'] = $value['format'];
415 415
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
416
-    			if ($line[3] == 'PILOT') $SI->add($data);
416
+				if ($line[3] == 'PILOT') $SI->add($data);
417 417
 			elseif ($line[3] == 'ATC') {
418 418
 				//print_r($data);
419 419
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -431,240 +431,240 @@  discard block
 block discarded – undo
431 431
 				
432 432
 				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']);
433 433
 			}
434
-    			unset($data);
435
-    		    }
436
-    		}
437
-    	    }
438
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
439
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
440
-    	    $last_exec[$id]['last'] = time();
441
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
442
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
443
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
444
-	    if ($buffer != '') {
445
-	    $all_data = json_decode($buffer,true);
446
-	    if (isset($all_data['acList'])) {
434
+				unset($data);
435
+				}
436
+			}
437
+			}
438
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
439
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
440
+			$last_exec[$id]['last'] = time();
441
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
442
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
443
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
444
+		if ($buffer != '') {
445
+		$all_data = json_decode($buffer,true);
446
+		if (isset($all_data['acList'])) {
447 447
 		foreach ($all_data['acList'] as $line) {
448
-		    $data = array();
449
-		    $data['hex'] = $line['Icao']; // hex
450
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
451
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
452
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
453
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
454
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
455
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
456
-		    //$data['verticalrate'] = $line['']; // verticale rate
457
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
458
-		    $data['emergency'] = ''; // emergency
459
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
460
-		    /*
448
+			$data = array();
449
+			$data['hex'] = $line['Icao']; // hex
450
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
451
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
452
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
453
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
454
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
455
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
456
+			//$data['verticalrate'] = $line['']; // verticale rate
457
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
458
+			$data['emergency'] = ''; // emergency
459
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
460
+			/*
461 461
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
462 462
 		    else $data['datetime'] = date('Y-m-d H:i:s');
463 463
 		    */
464
-		    $data['datetime'] = date('Y-m-d H:i:s');
465
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
466
-	    	    $data['format_source'] = 'aircraftlistjson';
467
-		    $data['id_source'] = $id_source;
468
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
469
-		    if (isset($data['datetime'])) $SI->add($data);
470
-		    unset($data);
464
+			$data['datetime'] = date('Y-m-d H:i:s');
465
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
466
+				$data['format_source'] = 'aircraftlistjson';
467
+			$data['id_source'] = $id_source;
468
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
469
+			if (isset($data['datetime'])) $SI->add($data);
470
+			unset($data);
471 471
 		}
472
-	    } else {
472
+		} else {
473 473
 		foreach ($all_data as $line) {
474
-		    $data = array();
475
-		    $data['hex'] = $line['hex']; // hex
476
-		    $data['ident'] = $line['flight']; // ident
477
-		    $data['altitude'] = $line['altitude']; // altitude
478
-		    $data['speed'] = $line['speed']; // speed
479
-		    $data['heading'] = $line['track']; // heading
480
-		    $data['latitude'] = $line['lat']; // lat
481
-		    $data['longitude'] = $line['lon']; // long
482
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
483
-		    $data['squawk'] = $line['squawk']; // squawk
484
-		    $data['emergency'] = ''; // emergency
485
-		    $data['datetime'] = date('Y-m-d H:i:s');
486
-	    	    $data['format_source'] = 'aircraftlistjson';
487
-    		    $data['id_source'] = $id_source;
488
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
489
-		    $SI->add($data);
490
-		    unset($data);
474
+			$data = array();
475
+			$data['hex'] = $line['hex']; // hex
476
+			$data['ident'] = $line['flight']; // ident
477
+			$data['altitude'] = $line['altitude']; // altitude
478
+			$data['speed'] = $line['speed']; // speed
479
+			$data['heading'] = $line['track']; // heading
480
+			$data['latitude'] = $line['lat']; // lat
481
+			$data['longitude'] = $line['lon']; // long
482
+			$data['verticalrate'] = $line['vrt']; // verticale rate
483
+			$data['squawk'] = $line['squawk']; // squawk
484
+			$data['emergency'] = ''; // emergency
485
+			$data['datetime'] = date('Y-m-d H:i:s');
486
+				$data['format_source'] = 'aircraftlistjson';
487
+				$data['id_source'] = $id_source;
488
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
489
+			$SI->add($data);
490
+			unset($data);
491
+		}
492
+		}
491 493
 		}
492
-	    }
493
-	    }
494
-    	    //$last_exec['aircraftlistjson'] = time();
495
-    	    $last_exec[$id]['last'] = time();
496
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
497
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
498
-	    $buffer = $Common->getData($value['host']);
499
-	    $all_data = json_decode($buffer,true);
500
-	    if (isset($all_data['planes'])) {
494
+			//$last_exec['aircraftlistjson'] = time();
495
+			$last_exec[$id]['last'] = time();
496
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
497
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
498
+		$buffer = $Common->getData($value['host']);
499
+		$all_data = json_decode($buffer,true);
500
+		if (isset($all_data['planes'])) {
501 501
 		foreach ($all_data['planes'] as $key => $line) {
502
-		    $data = array();
503
-		    $data['hex'] = $key; // hex
504
-		    $data['ident'] = $line[3]; // ident
505
-		    $data['altitude'] = $line[6]; // altitude
506
-		    $data['speed'] = $line[8]; // speed
507
-		    $data['heading'] = $line[7]; // heading
508
-		    $data['latitude'] = $line[4]; // lat
509
-		    $data['longitude'] = $line[5]; // long
510
-		    //$data['verticalrate'] = $line[]; // verticale rate
511
-		    $data['squawk'] = $line[10]; // squawk
512
-		    $data['emergency'] = ''; // emergency
513
-		    $data['registration'] = $line[2];
514
-		    $data['aircraft_icao'] = $line[0];
515
-		    $deparr = explode('-',$line[1]);
516
-		    if (count($deparr) == 2) {
502
+			$data = array();
503
+			$data['hex'] = $key; // hex
504
+			$data['ident'] = $line[3]; // ident
505
+			$data['altitude'] = $line[6]; // altitude
506
+			$data['speed'] = $line[8]; // speed
507
+			$data['heading'] = $line[7]; // heading
508
+			$data['latitude'] = $line[4]; // lat
509
+			$data['longitude'] = $line[5]; // long
510
+			//$data['verticalrate'] = $line[]; // verticale rate
511
+			$data['squawk'] = $line[10]; // squawk
512
+			$data['emergency'] = ''; // emergency
513
+			$data['registration'] = $line[2];
514
+			$data['aircraft_icao'] = $line[0];
515
+			$deparr = explode('-',$line[1]);
516
+			if (count($deparr) == 2) {
517 517
 			$data['departure_airport_icao'] = $deparr[0];
518 518
 			$data['arrival_airport_icao'] = $deparr[1];
519
-		    }
520
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
521
-	    	    $data['format_source'] = 'planeupdatefaa';
522
-    		    $data['id_source'] = $id_source;
523
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
524
-		    $SI->add($data);
525
-		    unset($data);
519
+			}
520
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
521
+				$data['format_source'] = 'planeupdatefaa';
522
+				$data['id_source'] = $id_source;
523
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
524
+			$SI->add($data);
525
+			unset($data);
526 526
 		}
527
-	    }
528
-    	    //$last_exec['planeupdatefaa'] = time();
529
-    	    $last_exec[$id]['last'] = time();
530
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
531
-	    $buffer = $Common->getData($value['host']);
532
-	    $all_data = json_decode($buffer,true);
533
-	    if (isset($all_data['states'])) {
527
+		}
528
+			//$last_exec['planeupdatefaa'] = time();
529
+			$last_exec[$id]['last'] = time();
530
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
531
+		$buffer = $Common->getData($value['host']);
532
+		$all_data = json_decode($buffer,true);
533
+		if (isset($all_data['states'])) {
534 534
 		foreach ($all_data['states'] as $key => $line) {
535
-		    $data = array();
536
-		    $data['hex'] = $line[0]; // hex
537
-		    $data['ident'] = trim($line[1]); // ident
538
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
539
-		    $data['speed'] = round($line[9]*1.94384); // speed
540
-		    $data['heading'] = round($line[10]); // heading
541
-		    $data['latitude'] = $line[5]; // lat
542
-		    $data['longitude'] = $line[6]; // long
543
-		    $data['verticalrate'] = $line[11]; // verticale rate
544
-		    //$data['squawk'] = $line[10]; // squawk
545
-		    //$data['emergency'] = ''; // emergency
546
-		    //$data['registration'] = $line[2];
547
-		    //$data['aircraft_icao'] = $line[0];
548
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
549
-	    	    $data['format_source'] = 'opensky';
550
-    		    $data['id_source'] = $id_source;
551
-		    $SI->add($data);
552
-		    unset($data);
535
+			$data = array();
536
+			$data['hex'] = $line[0]; // hex
537
+			$data['ident'] = trim($line[1]); // ident
538
+			$data['altitude'] = round($line[7]*3.28084); // altitude
539
+			$data['speed'] = round($line[9]*1.94384); // speed
540
+			$data['heading'] = round($line[10]); // heading
541
+			$data['latitude'] = $line[5]; // lat
542
+			$data['longitude'] = $line[6]; // long
543
+			$data['verticalrate'] = $line[11]; // verticale rate
544
+			//$data['squawk'] = $line[10]; // squawk
545
+			//$data['emergency'] = ''; // emergency
546
+			//$data['registration'] = $line[2];
547
+			//$data['aircraft_icao'] = $line[0];
548
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
549
+				$data['format_source'] = 'opensky';
550
+				$data['id_source'] = $id_source;
551
+			$SI->add($data);
552
+			unset($data);
553 553
 		}
554
-	    }
555
-    	    //$last_exec['planeupdatefaa'] = time();
556
-    	    $last_exec[$id]['last'] = time();
557
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
558
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
559
-	    //$buffer = $Common->getData($hosts[$id]);
560
-	    $buffer = $Common->getData($value['host']);
561
-	    $all_data = json_decode($buffer,true);
562
-	    foreach ($all_data as $key => $line) {
554
+		}
555
+			//$last_exec['planeupdatefaa'] = time();
556
+			$last_exec[$id]['last'] = time();
557
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
558
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
559
+		//$buffer = $Common->getData($hosts[$id]);
560
+		$buffer = $Common->getData($value['host']);
561
+		$all_data = json_decode($buffer,true);
562
+		foreach ($all_data as $key => $line) {
563 563
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
564
-		    $data = array();
565
-		    $data['hex'] = $line[0];
566
-		    $data['ident'] = $line[16]; //$line[13]
567
-	    	    $data['altitude'] = $line[4]; // altitude
568
-	    	    $data['speed'] = $line[5]; // speed
569
-	    	    $data['heading'] = $line[3]; // heading
570
-	    	    $data['latitude'] = $line[1]; // lat
571
-	    	    $data['longitude'] = $line[2]; // long
572
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
573
-	    	    $data['squawk'] = $line[6]; // squawk
574
-	    	    $data['aircraft_icao'] = $line[8];
575
-	    	    $data['registration'] = $line[9];
576
-		    $data['departure_airport_iata'] = $line[11];
577
-		    $data['arrival_airport_iata'] = $line[12];
578
-	    	    $data['emergency'] = ''; // emergency
579
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
580
-	    	    $data['format_source'] = 'fr24json';
581
-    		    $data['id_source'] = $id_source;
582
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
583
-		    $SI->add($data);
584
-		    unset($data);
564
+			$data = array();
565
+			$data['hex'] = $line[0];
566
+			$data['ident'] = $line[16]; //$line[13]
567
+				$data['altitude'] = $line[4]; // altitude
568
+				$data['speed'] = $line[5]; // speed
569
+				$data['heading'] = $line[3]; // heading
570
+				$data['latitude'] = $line[1]; // lat
571
+				$data['longitude'] = $line[2]; // long
572
+				$data['verticalrate'] = $line[15]; // verticale rate
573
+				$data['squawk'] = $line[6]; // squawk
574
+				$data['aircraft_icao'] = $line[8];
575
+				$data['registration'] = $line[9];
576
+			$data['departure_airport_iata'] = $line[11];
577
+			$data['arrival_airport_iata'] = $line[12];
578
+				$data['emergency'] = ''; // emergency
579
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
580
+				$data['format_source'] = 'fr24json';
581
+				$data['id_source'] = $id_source;
582
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
583
+			$SI->add($data);
584
+			unset($data);
585 585
 		}
586
-	    }
587
-    	    //$last_exec['fr24json'] = time();
588
-    	    $last_exec[$id]['last'] = time();
589
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
590
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
591
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
592
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
593
-	    //echo $buffer;
594
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
595
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
596
-	    $all_data = json_decode($buffer,true);
597
-	    if (json_last_error() != JSON_ERROR_NONE) {
586
+		}
587
+			//$last_exec['fr24json'] = time();
588
+			$last_exec[$id]['last'] = time();
589
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
590
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
591
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
592
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
593
+		//echo $buffer;
594
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
595
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
596
+		$all_data = json_decode($buffer,true);
597
+		if (json_last_error() != JSON_ERROR_NONE) {
598 598
 		die(json_last_error_msg());
599
-	    }
600
-	    if (isset($all_data['mrkrs'])) {
599
+		}
600
+		if (isset($all_data['mrkrs'])) {
601 601
 		foreach ($all_data['mrkrs'] as $key => $line) {
602
-		    if (isset($line['inf'])) {
602
+			if (isset($line['inf'])) {
603 603
 			$data = array();
604 604
 			$data['hex'] = $line['inf']['ia'];
605 605
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
606
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
607
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
608
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
609
-	    		$data['latitude'] = $line['pt'][0]; // lat
610
-	    		$data['longitude'] = $line['pt'][1]; // long
611
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
612
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
613
-	    		//$data['aircraft_icao'] = $line[8];
614
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
606
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
607
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
608
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
609
+				$data['latitude'] = $line['pt'][0]; // lat
610
+				$data['longitude'] = $line['pt'][1]; // long
611
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
612
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
613
+				//$data['aircraft_icao'] = $line[8];
614
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
615 615
 			//$data['departure_airport_iata'] = $line[11];
616 616
 			//$data['arrival_airport_iata'] = $line[12];
617
-	    		//$data['emergency'] = ''; // emergency
617
+				//$data['emergency'] = ''; // emergency
618 618
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
619
-	    		$data['format_source'] = 'radarvirtueljson';
620
-    			$data['id_source'] = $id_source;
619
+				$data['format_source'] = 'radarvirtueljson';
620
+				$data['id_source'] = $id_source;
621 621
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
622 622
 			$SI->add($data);
623 623
 			unset($data);
624
-		    }
624
+			}
625 625
 		}
626
-	    }
627
-    	    //$last_exec['radarvirtueljson'] = time();
628
-    	    $last_exec[$id]['last'] = time();
629
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
630
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
631
-	    //$buffer = $Common->getData($hosts[$id]);
632
-	    $buffer = $Common->getData($value['host'].'?'.time());
633
-	    $all_data = json_decode(utf8_encode($buffer),true);
626
+		}
627
+			//$last_exec['radarvirtueljson'] = time();
628
+			$last_exec[$id]['last'] = time();
629
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
630
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
631
+		//$buffer = $Common->getData($hosts[$id]);
632
+		$buffer = $Common->getData($value['host'].'?'.time());
633
+		$all_data = json_decode(utf8_encode($buffer),true);
634 634
 	    
635
-	    if (isset($all_data['pireps'])) {
636
-	        foreach ($all_data['pireps'] as $line) {
637
-		    $data = array();
638
-		    $data['id'] = $line['id'];
639
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
640
-		    $data['ident'] = $line['callsign']; // ident
641
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
642
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
643
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
644
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
645
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
646
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
647
-		    $data['latitude'] = $line['lat']; // lat
648
-		    $data['longitude'] = $line['lon']; // long
649
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
650
-		    //$data['squawk'] = $line['squawk']; // squawk
651
-		    //$data['emergency'] = ''; // emergency
652
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
653
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
654
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
655
-		    //$data['arrival_airport_time'] = $line['arrtime'];
656
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
657
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
658
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
659
-		    else $data['info'] = '';
660
-		    $data['format_source'] = 'pireps';
661
-    		    $data['id_source'] = $id_source;
662
-		    $data['datetime'] = date('Y-m-d H:i:s');
663
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
664
-		    if ($line['icon'] == 'plane') {
635
+		if (isset($all_data['pireps'])) {
636
+			foreach ($all_data['pireps'] as $line) {
637
+			$data = array();
638
+			$data['id'] = $line['id'];
639
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
640
+			$data['ident'] = $line['callsign']; // ident
641
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
642
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
643
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
644
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
645
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
646
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
647
+			$data['latitude'] = $line['lat']; // lat
648
+			$data['longitude'] = $line['lon']; // long
649
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
650
+			//$data['squawk'] = $line['squawk']; // squawk
651
+			//$data['emergency'] = ''; // emergency
652
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
653
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
654
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
655
+			//$data['arrival_airport_time'] = $line['arrtime'];
656
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
657
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
658
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
659
+			else $data['info'] = '';
660
+			$data['format_source'] = 'pireps';
661
+				$data['id_source'] = $id_source;
662
+			$data['datetime'] = date('Y-m-d H:i:s');
663
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
664
+			if ($line['icon'] == 'plane') {
665 665
 			$SI->add($data);
666
-		    //    print_r($data);
667
-    		    } elseif ($line['icon'] == 'ct') {
666
+			//    print_r($data);
667
+				} elseif ($line['icon'] == 'ct') {
668 668
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
669 669
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
670 670
 			$typec = substr($data['ident'],-3);
@@ -679,158 +679,158 @@  discard block
 block discarded – undo
679 679
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
680 680
 			else $data['type'] = 'Observer';
681 681
 			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']);
682
-		    }
683
-		    unset($data);
682
+			}
683
+			unset($data);
684 684
 		}
685
-	    }
686
-    	    //$last_exec['pirepsjson'] = time();
687
-    	    $last_exec[$id]['last'] = time();
688
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
689
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
690
-	    //$buffer = $Common->getData($hosts[$id]);
691
-	    if ($globalDebug) echo 'Get Data...'."\n";
692
-	    $buffer = $Common->getData($value['host']);
693
-	    $all_data = json_decode($buffer,true);
694
-	    if ($buffer != '' && is_array($all_data)) {
685
+		}
686
+			//$last_exec['pirepsjson'] = time();
687
+			$last_exec[$id]['last'] = time();
688
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
689
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
690
+		//$buffer = $Common->getData($hosts[$id]);
691
+		if ($globalDebug) echo 'Get Data...'."\n";
692
+		$buffer = $Common->getData($value['host']);
693
+		$all_data = json_decode($buffer,true);
694
+		if ($buffer != '' && is_array($all_data)) {
695 695
 		foreach ($all_data as $line) {
696
-	    	    $data = array();
697
-	    	    //$data['id'] = $line['id']; // id not usable
698
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
699
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
700
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
701
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
702
-	    	    $data['ident'] = $line['flightnum']; // ident
703
-	    	    $data['altitude'] = $line['alt']; // altitude
704
-	    	    $data['speed'] = $line['gs']; // speed
705
-	    	    $data['heading'] = $line['heading']; // heading
706
-	    	    $data['latitude'] = $line['lat']; // lat
707
-	    	    $data['longitude'] = $line['lng']; // long
708
-	    	    $data['verticalrate'] = ''; // verticale rate
709
-	    	    $data['squawk'] = ''; // squawk
710
-	    	    $data['emergency'] = ''; // emergency
711
-	    	    //$data['datetime'] = $line['lastupdate'];
712
-	    	    $data['last_update'] = $line['lastupdate'];
713
-		    $data['datetime'] = date('Y-m-d H:i:s');
714
-	    	    $data['departure_airport_icao'] = $line['depicao'];
715
-	    	    $data['departure_airport_time'] = $line['deptime'];
716
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
717
-    		    $data['arrival_airport_time'] = $line['arrtime'];
718
-    		    $data['registration'] = $line['aircraft'];
719
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
720
-		    if (isset($line['aircraftname'])) {
696
+				$data = array();
697
+				//$data['id'] = $line['id']; // id not usable
698
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
699
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
700
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
701
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
702
+				$data['ident'] = $line['flightnum']; // ident
703
+				$data['altitude'] = $line['alt']; // altitude
704
+				$data['speed'] = $line['gs']; // speed
705
+				$data['heading'] = $line['heading']; // heading
706
+				$data['latitude'] = $line['lat']; // lat
707
+				$data['longitude'] = $line['lng']; // long
708
+				$data['verticalrate'] = ''; // verticale rate
709
+				$data['squawk'] = ''; // squawk
710
+				$data['emergency'] = ''; // emergency
711
+				//$data['datetime'] = $line['lastupdate'];
712
+				$data['last_update'] = $line['lastupdate'];
713
+			$data['datetime'] = date('Y-m-d H:i:s');
714
+				$data['departure_airport_icao'] = $line['depicao'];
715
+				$data['departure_airport_time'] = $line['deptime'];
716
+				$data['arrival_airport_icao'] = $line['arricao'];
717
+				$data['arrival_airport_time'] = $line['arrtime'];
718
+				$data['registration'] = $line['aircraft'];
719
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
720
+			if (isset($line['aircraftname'])) {
721 721
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
722 722
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
723
-	    		$aircraft_data = explode('-',$line['aircraftname']);
724
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
725
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
726
-	    		else {
727
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
728
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
729
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
730
-	    		}
731
-	    	    }
732
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
733
-    		    $data['id_source'] = $id_source;
734
-	    	    $data['format_source'] = 'phpvmacars';
735
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
736
-		    $SI->add($data);
737
-		    unset($data);
723
+				$aircraft_data = explode('-',$line['aircraftname']);
724
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
725
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
726
+				else {
727
+					$aircraft_data = explode(' ',$line['aircraftname']);
728
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
729
+					else $data['aircraft_icao'] = $line['aircraftname'];
730
+				}
731
+				}
732
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
733
+				$data['id_source'] = $id_source;
734
+				$data['format_source'] = 'phpvmacars';
735
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
736
+			$SI->add($data);
737
+			unset($data);
738 738
 		}
739 739
 		if ($globalDebug) echo 'No more data...'."\n";
740 740
 		unset($buffer);
741 741
 		unset($all_data);
742
-	    }
743
-    	    //$last_exec['phpvmacars'] = time();
744
-    	    $last_exec[$id]['last'] = time();
745
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
746
-	    //$buffer = $Common->getData($hosts[$id]);
747
-	    if ($globalDebug) echo 'Get Data...'."\n";
748
-	    $buffer = $Common->getData($value['host']);
749
-	    $all_data = json_decode($buffer,true);
750
-	    if ($buffer != '' && is_array($all_data)) {
742
+		}
743
+			//$last_exec['phpvmacars'] = time();
744
+			$last_exec[$id]['last'] = time();
745
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
746
+		//$buffer = $Common->getData($hosts[$id]);
747
+		if ($globalDebug) echo 'Get Data...'."\n";
748
+		$buffer = $Common->getData($value['host']);
749
+		$all_data = json_decode($buffer,true);
750
+		if ($buffer != '' && is_array($all_data)) {
751 751
 		foreach ($all_data as $line) {
752
-	    	    $data = array();
753
-	    	    //$data['id'] = $line['id']; // id not usable
754
-	    	    $data['id'] = trim($line['flight_id']);
755
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
756
-	    	    $data['pilot_name'] = $line['pilot_name'];
757
-	    	    $data['pilot_id'] = $line['pilot_id'];
758
-	    	    $data['ident'] = trim($line['callsign']); // ident
759
-	    	    $data['altitude'] = $line['altitude']; // altitude
760
-	    	    $data['speed'] = $line['gs']; // speed
761
-	    	    $data['heading'] = $line['heading']; // heading
762
-	    	    $data['latitude'] = $line['latitude']; // lat
763
-	    	    $data['longitude'] = $line['longitude']; // long
764
-	    	    $data['verticalrate'] = ''; // verticale rate
765
-	    	    $data['squawk'] = ''; // squawk
766
-	    	    $data['emergency'] = ''; // emergency
767
-	    	    //$data['datetime'] = $line['lastupdate'];
768
-	    	    $data['last_update'] = $line['last_update'];
769
-		    $data['datetime'] = date('Y-m-d H:i:s');
770
-	    	    $data['departure_airport_icao'] = $line['departure'];
771
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
772
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
773
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
774
-    		    //$data['registration'] = $line['aircraft'];
775
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
776
-	    	    $data['aircraft_icao'] = $line['plane_type'];
777
-    		    $data['id_source'] = $id_source;
778
-	    	    $data['format_source'] = 'vam';
779
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
780
-		    $SI->add($data);
781
-		    unset($data);
752
+				$data = array();
753
+				//$data['id'] = $line['id']; // id not usable
754
+				$data['id'] = trim($line['flight_id']);
755
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
756
+				$data['pilot_name'] = $line['pilot_name'];
757
+				$data['pilot_id'] = $line['pilot_id'];
758
+				$data['ident'] = trim($line['callsign']); // ident
759
+				$data['altitude'] = $line['altitude']; // altitude
760
+				$data['speed'] = $line['gs']; // speed
761
+				$data['heading'] = $line['heading']; // heading
762
+				$data['latitude'] = $line['latitude']; // lat
763
+				$data['longitude'] = $line['longitude']; // long
764
+				$data['verticalrate'] = ''; // verticale rate
765
+				$data['squawk'] = ''; // squawk
766
+				$data['emergency'] = ''; // emergency
767
+				//$data['datetime'] = $line['lastupdate'];
768
+				$data['last_update'] = $line['last_update'];
769
+			$data['datetime'] = date('Y-m-d H:i:s');
770
+				$data['departure_airport_icao'] = $line['departure'];
771
+				//$data['departure_airport_time'] = $line['departure_time'];
772
+				$data['arrival_airport_icao'] = $line['arrival'];
773
+				//$data['arrival_airport_time'] = $line['arrival_time'];
774
+				//$data['registration'] = $line['aircraft'];
775
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
776
+				$data['aircraft_icao'] = $line['plane_type'];
777
+				$data['id_source'] = $id_source;
778
+				$data['format_source'] = 'vam';
779
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
780
+			$SI->add($data);
781
+			unset($data);
782 782
 		}
783 783
 		if ($globalDebug) echo 'No more data...'."\n";
784 784
 		unset($buffer);
785 785
 		unset($all_data);
786
-	    }
787
-    	    //$last_exec['phpvmacars'] = time();
788
-    	    $last_exec[$id]['last'] = time();
786
+		}
787
+			//$last_exec['phpvmacars'] = time();
788
+			$last_exec[$id]['last'] = time();
789 789
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
790 790
 	} 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') {
791
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
792
-    	    //$last_exec[$id]['last'] = time();
791
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
792
+			//$last_exec[$id]['last'] = time();
793 793
 
794
-	    //$read = array( $sockets[$id] );
795
-	    $read = $sockets;
796
-	    $write = NULL;
797
-	    $e = NULL;
798
-	    $n = socket_select($read, $write, $e, $timeout);
799
-	    if ($e != NULL) var_dump($e);
800
-	    if ($n > 0) {
794
+		//$read = array( $sockets[$id] );
795
+		$read = $sockets;
796
+		$write = NULL;
797
+		$e = NULL;
798
+		$n = socket_select($read, $write, $e, $timeout);
799
+		if ($e != NULL) var_dump($e);
800
+		if ($n > 0) {
801 801
 		foreach ($read as $nb => $r) {
802
-		    //$value = $formats[$nb];
803
-		    $format = $globalSources[$nb]['format'];
804
-        	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv') {
805
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
806
-        	    } else {
807
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
808
-	    	    }
809
-        	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
810
-        	    //echo $buffer."\n";
811
-		    // lets play nice and handle signals such as ctrl-c/kill properly
812
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
813
-		    $error = false;
814
-		    //$SI::del();
815
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
816
-		    // SBS format is CSV format
817
-		    if ($buffer != '') {
802
+			//$value = $formats[$nb];
803
+			$format = $globalSources[$nb]['format'];
804
+				if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv') {
805
+				$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
806
+				} else {
807
+					$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
808
+				}
809
+				//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
810
+				//echo $buffer."\n";
811
+			// lets play nice and handle signals such as ctrl-c/kill properly
812
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
813
+			$error = false;
814
+			//$SI::del();
815
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
816
+			// SBS format is CSV format
817
+			if ($buffer != '') {
818 818
 			$tt[$format] = 0;
819 819
 			if ($format == 'acarssbs3') {
820
-			    echo $buffer."\n";
820
+				echo $buffer."\n";
821 821
 			} elseif ($format == 'raw') {
822
-			    // AVR format
823
-			    $data = $SBS->parse($buffer);
824
-			    if (is_array($data)) {
822
+				// AVR format
823
+				$data = $SBS->parse($buffer);
824
+				if (is_array($data)) {
825 825
 				$data['datetime'] = date('Y-m-d H:i:s');
826 826
 				$data['format_source'] = 'raw';
827 827
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
828
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
829
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
830
-                            }
831
-                        } elseif ($format == 'flightgearsp') {
832
-                    	    //echo $buffer."\n";
833
-                    	    if (strlen($buffer) > 5) {
828
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
829
+								if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
830
+							}
831
+						} elseif ($format == 'flightgearsp') {
832
+							//echo $buffer."\n";
833
+							if (strlen($buffer) > 5) {
834 834
 				$line = explode(',',$buffer);
835 835
 				$data = array();
836 836
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -846,114 +846,114 @@  discard block
 block discarded – undo
846 846
 				$data['format_source'] = 'flightgearsp';
847 847
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
848 848
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
849
-			    }
850
-                        } elseif ($format == 'acars') {
851
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
852
-			    $ACARS->add(trim($buffer));
853
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
854
-			    $ACARS->deleteLiveAcarsData();
849
+				}
850
+						} elseif ($format == 'acars') {
851
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
852
+				$ACARS->add(trim($buffer));
853
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
854
+				$ACARS->deleteLiveAcarsData();
855 855
 			} elseif ($format == 'flightgearmp') {
856
-			    if (substr($buffer,0,1) != '#') {
856
+				if (substr($buffer,0,1) != '#') {
857 857
 				$data = array();
858 858
 				//echo $buffer."\n";
859 859
 				$line = explode(' ',$buffer);
860 860
 				if (count($line) == 11) {
861
-				    $userserver = explode('@',$line[0]);
862
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
863
-				    $data['ident'] = $userserver[0];
864
-				    $data['registration'] = $userserver[0];
865
-				    $data['latitude'] = $line[4];
866
-				    $data['longitude'] = $line[5];
867
-				    $data['altitude'] = $line[6];
868
-				    $data['datetime'] = date('Y-m-d H:i:s');
869
-				    $aircraft_type = $line[10];
870
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
871
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
872
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
861
+					$userserver = explode('@',$line[0]);
862
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
863
+					$data['ident'] = $userserver[0];
864
+					$data['registration'] = $userserver[0];
865
+					$data['latitude'] = $line[4];
866
+					$data['longitude'] = $line[5];
867
+					$data['altitude'] = $line[6];
868
+					$data['datetime'] = date('Y-m-d H:i:s');
869
+					$aircraft_type = $line[10];
870
+					$aircraft_type = preg_split(':/:',$aircraft_type);
871
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
872
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
873
+				}
873 874
 				}
874
-			    }
875 875
 			} elseif ($format == 'beast') {
876
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
877
-			    die;
876
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
877
+				die;
878 878
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
879
-			    $line = explode("\t", $buffer);
880
-			    for($k = 0; $k < count($line); $k=$k+2) {
879
+				$line = explode("\t", $buffer);
880
+				for($k = 0; $k < count($line); $k=$k+2) {
881 881
 				$key = $line[$k];
882
-			        $lined[$key] = $line[$k+1];
883
-			    }
884
-    			    if (count($lined) > 3) {
885
-    				$data['hex'] = $lined['hexid'];
886
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
887
-    				$data['datetime'] = date('Y-m-d H:i:s');;
888
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
889
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
890
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
891
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
892
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
893
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
894
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
895
-    				$data['id_source'] = $id_source;
896
-    				$data['format_source'] = 'tsv';
897
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
898
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
899
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
900
-    				unset($lined);
901
-    				unset($data);
902
-    			    } else $error = true;
882
+					$lined[$key] = $line[$k+1];
883
+				}
884
+					if (count($lined) > 3) {
885
+					$data['hex'] = $lined['hexid'];
886
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
887
+					$data['datetime'] = date('Y-m-d H:i:s');;
888
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
889
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
890
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
891
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
892
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
893
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
894
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
895
+					$data['id_source'] = $id_source;
896
+					$data['format_source'] = 'tsv';
897
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
898
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
899
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
900
+					unset($lined);
901
+					unset($data);
902
+					} else $error = true;
903 903
 			} elseif ($format == 'aprs' && $use_aprs) {
904
-			    if ($aprs_connect == 0) {
904
+				if ($aprs_connect == 0) {
905 905
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
906 906
 				$aprs_connect = 1;
907
-			    }
908
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
907
+				}
908
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
909 909
 				$aprs_last_tx = time();
910 910
 				$data_aprs = "# Keep alive";
911 911
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
912
-			    }
913
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
914
-			    $buffer = str_replace('APRS <- ','',$buffer);
915
-			    $buffer = str_replace('APRS -> ','',$buffer);
916
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
912
+				}
913
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
914
+				$buffer = str_replace('APRS <- ','',$buffer);
915
+				$buffer = str_replace('APRS -> ','',$buffer);
916
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
917 917
 				$line = $APRS->parse($buffer);
918 918
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
919
-				    $data = array();
920
-				    //print_r($line);
921
-				    $data['hex'] = $line['address'];
922
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
923
-				    //$data['datetime'] = date('Y-m-d H:i:s');
924
-				    $data['ident'] = $line['ident'];
925
-				    $data['latitude'] = $line['latitude'];
926
-				    $data['longitude'] = $line['longitude'];
927
-				    //$data['verticalrate'] = $line[16];
928
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
929
-				    else $data['speed'] = 0;
930
-				    $data['altitude'] = $line['altitude'];
931
-				    if (isset($line['course'])) $data['heading'] = $line['course'];
932
-				    //else $data['heading'] = 0;
933
-				    $data['aircraft_type'] = $line['stealth'];
934
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
935
-    				    $data['id_source'] = $id_source;
936
-				    $data['format_source'] = 'aprs';
937
-				    $data['source_name'] = $line['source'];
938
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
939
-				    $currentdate = date('Y-m-d H:i:s');
940
-				    $aprsdate = strtotime($data['datetime']);
941
-				    // Accept data if time <= system time + 20s
942
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
943
-				    else {
919
+					$data = array();
920
+					//print_r($line);
921
+					$data['hex'] = $line['address'];
922
+					$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
923
+					//$data['datetime'] = date('Y-m-d H:i:s');
924
+					$data['ident'] = $line['ident'];
925
+					$data['latitude'] = $line['latitude'];
926
+					$data['longitude'] = $line['longitude'];
927
+					//$data['verticalrate'] = $line[16];
928
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
929
+					else $data['speed'] = 0;
930
+					$data['altitude'] = $line['altitude'];
931
+					if (isset($line['course'])) $data['heading'] = $line['course'];
932
+					//else $data['heading'] = 0;
933
+					$data['aircraft_type'] = $line['stealth'];
934
+					if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
935
+						$data['id_source'] = $id_source;
936
+					$data['format_source'] = 'aprs';
937
+					$data['source_name'] = $line['source'];
938
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
939
+					$currentdate = date('Y-m-d H:i:s');
940
+					$aprsdate = strtotime($data['datetime']);
941
+					// Accept data if time <= system time + 20s
942
+					if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
943
+					else {
944 944
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
945 945
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
946
-				    }
947
-				    unset($data);
946
+					}
947
+					unset($data);
948 948
 				} 
949 949
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
950 950
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
951
-			    }
951
+				}
952 952
 			} else {
953
-			    $line = explode(',', $buffer);
954
-    			    if (count($line) > 20) {
955
-    			    	$data['hex'] = $line[4];
956
-    				/*
953
+				$line = explode(',', $buffer);
954
+					if (count($line) > 20) {
955
+						$data['hex'] = $line[4];
956
+					/*
957 957
     				$data['datetime'] = $line[6].' '.$line[7];
958 958
     					date_default_timezone_set($globalTimezone);
959 959
     					$datetime = new DateTime($data['datetime']);
@@ -961,28 +961,28 @@  discard block
 block discarded – undo
961 961
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
962 962
     					date_default_timezone_set('UTC');
963 963
     				*/
964
-    				// Force datetime to current UTC datetime
965
-    				$data['datetime'] = date('Y-m-d H:i:s');
966
-    				$data['ident'] = trim($line[10]);
967
-    				$data['latitude'] = $line[14];
968
-    				$data['longitude'] = $line[15];
969
-    				$data['verticalrate'] = $line[16];
970
-    				$data['emergency'] = $line[20];
971
-    				$data['speed'] = $line[12];
972
-    				$data['squawk'] = $line[17];
973
-    				$data['altitude'] = $line[11];
974
-    				$data['heading'] = $line[13];
975
-    				$data['ground'] = $line[21];
976
-    				$data['emergency'] = $line[19];
977
-    				$data['format_source'] = 'sbs';
964
+					// Force datetime to current UTC datetime
965
+					$data['datetime'] = date('Y-m-d H:i:s');
966
+					$data['ident'] = trim($line[10]);
967
+					$data['latitude'] = $line[14];
968
+					$data['longitude'] = $line[15];
969
+					$data['verticalrate'] = $line[16];
970
+					$data['emergency'] = $line[20];
971
+					$data['speed'] = $line[12];
972
+					$data['squawk'] = $line[17];
973
+					$data['altitude'] = $line[11];
974
+					$data['heading'] = $line[13];
975
+					$data['ground'] = $line[21];
976
+					$data['emergency'] = $line[19];
977
+					$data['format_source'] = 'sbs';
978 978
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
979
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
980
-    				$data['id_source'] = $id_source;
981
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
982
-    				else $error = true;
983
-    				unset($data);
984
-    			    } else $error = true;
985
-			    if ($error) {
979
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
980
+					$data['id_source'] = $id_source;
981
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
982
+					else $error = true;
983
+					unset($data);
984
+					} else $error = true;
985
+				if ($error) {
986 986
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
987 987
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
988 988
 				} else {
@@ -998,13 +998,13 @@  discard block
 block discarded – undo
998 998
 					connect_all($sourceer);
999 999
 					$sourceer = array();
1000 1000
 				}
1001
-			    }
1001
+				}
1002 1002
 			}
1003 1003
 			// Sleep for xxx microseconds
1004 1004
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1005
-		    } else {
1005
+			} else {
1006 1006
 			if ($format == 'flightgearmp') {
1007
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1007
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1008 1008
 				//@socket_close($r);
1009 1009
 				sleep($globalMinFetch);
1010 1010
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1013,9 +1013,9 @@  discard block
 block discarded – undo
1013 1013
 				break;
1014 1014
 				
1015 1015
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1016
-			    if (isset($tt[$format])) $tt[$format]++;
1017
-			    else $tt[$format] = 0;
1018
-			    if ($tt[$format] > 30) {
1016
+				if (isset($tt[$format])) $tt[$format]++;
1017
+				else $tt[$format] = 0;
1018
+				if ($tt[$format] > 30) {
1019 1019
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1020 1020
 				//@socket_close($r);
1021 1021
 				sleep(2);
@@ -1026,40 +1026,40 @@  discard block
 block discarded – undo
1026 1026
 				//connect_all($globalSources);
1027 1027
 				$tt[$format]=0;
1028 1028
 				break;
1029
-			    }
1029
+				}
1030
+			}
1030 1031
 			}
1031
-		    }
1032 1032
 		}
1033
-	    } else {
1033
+		} else {
1034 1034
 		$error = socket_strerror(socket_last_error());
1035 1035
 		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1036 1036
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) || time() - $time >= $timeout) {
1037 1037
 			if (isset($globalDebug)) echo "Restarting...\n";
1038 1038
 			// Restart the script if possible
1039 1039
 			if (is_array($sockets)) {
1040
-			    if ($globalDebug) echo "Shutdown all sockets...";
1040
+				if ($globalDebug) echo "Shutdown all sockets...";
1041 1041
 			    
1042
-			    foreach ($sockets as $sock) {
1042
+				foreach ($sockets as $sock) {
1043 1043
 				@socket_shutdown($sock,2);
1044 1044
 				@socket_close($sock);
1045
-			    }
1045
+				}
1046 1046
 			    
1047 1047
 			}
1048
-			    if ($globalDebug) echo "Restart all connections...";
1049
-			    sleep(2);
1050
-			    $time = time();
1051
-			    //connect_all($hosts);
1052
-			    $aprs_connect = 0;
1053
-			    connect_all($globalSources);
1048
+				if ($globalDebug) echo "Restart all connections...";
1049
+				sleep(2);
1050
+				$time = time();
1051
+				//connect_all($hosts);
1052
+				$aprs_connect = 0;
1053
+				connect_all($globalSources);
1054 1054
 
1055 1055
 		}
1056
-	    }
1056
+		}
1057 1057
 	}
1058 1058
 	if ($globalDaemon === false) {
1059
-	    if ($globalDebug) echo 'Check all...'."\n";
1060
-	    $SI->checkAll();
1059
+		if ($globalDebug) echo 'Check all...'."\n";
1060
+		$SI->checkAll();
1061
+	}
1061 1062
 	}
1062
-    }
1063 1063
 }
1064 1064
 
1065 1065
 ?>
Please login to merge, or discard this patch.