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