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