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