Completed
Push — master ( 7c25a0...e3e251 )
by Yannick
29:02
created
scripts/daemon-spotter.php 1 patch
Indentation   +958 added lines, -958 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 57
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 if (isset($options['idsource'])) $id_source = $options['idsource'];
86 86
 else $id_source = 1;
87 87
 if (isset($globalServer) && $globalServer) {
88
-    if ($globalDebug) echo "Using Server Mode\n";
89
-    $SI=new SpotterServer();
88
+	if ($globalDebug) echo "Using Server Mode\n";
89
+	$SI=new SpotterServer();
90 90
 /*
91 91
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
92 92
     $SI = new adsb2aprs();
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
 
97 97
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
98 98
 if (isset($globalMarine) && $globalMarine) {
99
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
100
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
99
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
100
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
101 101
 }
102 102
 
103 103
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
104 104
 if (isset($globalMarine) && $globalMarine) {
105
-    $AIS = new AIS();
106
-    $MI = new MarineImport($Connection->db);
105
+	$AIS = new AIS();
106
+	$MI = new MarineImport($Connection->db);
107 107
 }
108 108
 //$APRS=new APRS($Connection->db);
109 109
 $SBS=new SBS();
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
 //$servertz = system('date +%Z');
115 115
 // signal handler - playing nice with sockets and dump1090
116 116
 if (function_exists('pcntl_fork')) {
117
-    pcntl_signal(SIGINT,  function() {
118
-        global $sockets;
119
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
120
-        die("Bye!\n");
121
-    });
122
-    pcntl_signal_dispatch();
117
+	pcntl_signal(SIGINT,  function() {
118
+		global $sockets;
119
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
120
+		die("Bye!\n");
121
+	});
122
+	pcntl_signal_dispatch();
123 123
 }
124 124
 
125 125
 // let's try and connect
@@ -129,36 +129,36 @@  discard block
 block discarded – undo
129 129
 $reset = 0;
130 130
 
131 131
 function connect_all($hosts) {
132
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
133
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
134
-    $reset++;
135
-    if ($globalDebug) echo 'Connect to all...'."\n";
136
-    foreach ($hosts as $id => $value) {
132
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
133
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
134
+	$reset++;
135
+	if ($globalDebug) echo 'Connect to all...'."\n";
136
+	foreach ($hosts as $id => $value) {
137 137
 	$host = $value['host'];
138 138
 	$globalSources[$id]['last_exec'] = 0;
139 139
 	// Here we check type of source(s)
140 140
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
141
-            if (preg_match('/deltadb.txt$/i',$host)) {
142
-        	//$formats[$id] = 'deltadbtxt';
143
-        	$globalSources[$id]['format'] = 'deltadbtxt';
144
-        	//$last_exec['deltadbtxt'] = 0;
145
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
146
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
147
-        	//$formats[$id] = 'vatsimtxt';
148
-        	$globalSources[$id]['format'] = 'vatsimtxt';
149
-        	//$last_exec['vatsimtxt'] = 0;
150
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
151
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
152
-        	//$formats[$id] = 'aircraftlistjson';
153
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
154
-        	//$last_exec['aircraftlistjson'] = 0;
155
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
156
-    	    } else if (preg_match('/opensky/i',$host)) {
157
-        	//$formats[$id] = 'aircraftlistjson';
158
-        	$globalSources[$id]['format'] = 'opensky';
159
-        	//$last_exec['aircraftlistjson'] = 0;
160
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
161
-    	    /*
141
+			if (preg_match('/deltadb.txt$/i',$host)) {
142
+			//$formats[$id] = 'deltadbtxt';
143
+			$globalSources[$id]['format'] = 'deltadbtxt';
144
+			//$last_exec['deltadbtxt'] = 0;
145
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
146
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
147
+			//$formats[$id] = 'vatsimtxt';
148
+			$globalSources[$id]['format'] = 'vatsimtxt';
149
+			//$last_exec['vatsimtxt'] = 0;
150
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
151
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
152
+			//$formats[$id] = 'aircraftlistjson';
153
+			$globalSources[$id]['format'] = 'aircraftlistjson';
154
+			//$last_exec['aircraftlistjson'] = 0;
155
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
156
+			} else if (preg_match('/opensky/i',$host)) {
157
+			//$formats[$id] = 'aircraftlistjson';
158
+			$globalSources[$id]['format'] = 'opensky';
159
+			//$last_exec['aircraftlistjson'] = 0;
160
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
161
+			/*
162 162
     	    // Disabled for now, site change source format
163 163
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
164 164
         	//$formats[$id] = 'radarvirtueljson';
@@ -170,121 +170,121 @@  discard block
 block discarded – undo
170 170
         	    exit(0);
171 171
         	}
172 172
     	    */
173
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
174
-        	//$formats[$id] = 'planeupdatefaa';
175
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
176
-        	//$last_exec['planeupdatefaa'] = 0;
177
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php 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('/\/action.php\/acars\/data$/i',$host)) {
183
-        	//$formats[$id] = 'phpvmacars';
184
-        	$globalSources[$id]['format'] = 'phpvmacars';
185
-        	//$last_exec['phpvmacars'] = 0;
186
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
187
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
188
-        	//$formats[$id] = 'phpvmacars';
189
-        	$globalSources[$id]['format'] = 'vam';
190
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
191
-            } else if (preg_match('/whazzup/i',$host)) {
192
-        	//$formats[$id] = 'whazzup';
193
-        	$globalSources[$id]['format'] = 'whazzup';
194
-        	//$last_exec['whazzup'] = 0;
195
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
196
-            } else if (preg_match('/blitzortung/i',$host)) {
197
-        	$globalSources[$id]['format'] = 'blitzortung';
198
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
199
-            } else if (preg_match('/airwhere/i',$host)) {
200
-        	$globalSources[$id]['format'] = 'airwhere';
201
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
202
-            } else if (preg_match('/recentpireps/i',$host)) {
203
-        	//$formats[$id] = 'pirepsjson';
204
-        	$globalSources[$id]['format'] = 'pirepsjson';
205
-        	//$last_exec['pirepsjson'] = 0;
206
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
207
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
208
-        	//$formats[$id] = 'fr24json';
209
-        	$globalSources[$id]['format'] = 'fr24json';
210
-        	//$last_exec['fr24json'] = 0;
211
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
212
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
213
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
214
-        	    exit(0);
215
-        	}
216
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
217
-        	//$formats[$id] = 'fr24json';
218
-        	$globalSources[$id]['format'] = 'myshiptracking';
219
-        	//$last_exec['fr24json'] = 0;
220
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
221
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
222
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
223
-        	    exit(0);
224
-        	}
225
-            //} else if (preg_match('/10001/',$host)) {
226
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
227
-        	//$formats[$id] = 'tsv';
228
-        	$globalSources[$id]['format'] = 'tsv';
229
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
230
-            }
231
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
232
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
233
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
234
-    		    if ($idf !== false) {
235
-    			$httpfeeds[$id] = $idf;
236
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
237
-    		    }
238
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
239
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
240
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
241
-	    $hostport = explode(':',$host);
242
-	    if (isset($hostport[1])) {
173
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
174
+			//$formats[$id] = 'planeupdatefaa';
175
+			$globalSources[$id]['format'] = 'planeupdatefaa';
176
+			//$last_exec['planeupdatefaa'] = 0;
177
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php 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('/\/action.php\/acars\/data$/i',$host)) {
183
+			//$formats[$id] = 'phpvmacars';
184
+			$globalSources[$id]['format'] = 'phpvmacars';
185
+			//$last_exec['phpvmacars'] = 0;
186
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
187
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
188
+			//$formats[$id] = 'phpvmacars';
189
+			$globalSources[$id]['format'] = 'vam';
190
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
191
+			} else if (preg_match('/whazzup/i',$host)) {
192
+			//$formats[$id] = 'whazzup';
193
+			$globalSources[$id]['format'] = 'whazzup';
194
+			//$last_exec['whazzup'] = 0;
195
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
196
+			} else if (preg_match('/blitzortung/i',$host)) {
197
+			$globalSources[$id]['format'] = 'blitzortung';
198
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
199
+			} else if (preg_match('/airwhere/i',$host)) {
200
+			$globalSources[$id]['format'] = 'airwhere';
201
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
202
+			} else if (preg_match('/recentpireps/i',$host)) {
203
+			//$formats[$id] = 'pirepsjson';
204
+			$globalSources[$id]['format'] = 'pirepsjson';
205
+			//$last_exec['pirepsjson'] = 0;
206
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
207
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
208
+			//$formats[$id] = 'fr24json';
209
+			$globalSources[$id]['format'] = 'fr24json';
210
+			//$last_exec['fr24json'] = 0;
211
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
212
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
213
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
214
+				exit(0);
215
+			}
216
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
217
+			//$formats[$id] = 'fr24json';
218
+			$globalSources[$id]['format'] = 'myshiptracking';
219
+			//$last_exec['fr24json'] = 0;
220
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
221
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
222
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
223
+				exit(0);
224
+			}
225
+			//} else if (preg_match('/10001/',$host)) {
226
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
227
+			//$formats[$id] = 'tsv';
228
+			$globalSources[$id]['format'] = 'tsv';
229
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
230
+			}
231
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
232
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
233
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
234
+				if ($idf !== false) {
235
+				$httpfeeds[$id] = $idf;
236
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
237
+				}
238
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
239
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
240
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
241
+		$hostport = explode(':',$host);
242
+		if (isset($hostport[1])) {
243 243
 		$port = $hostport[1];
244 244
 		$hostn = $hostport[0];
245
-	    } else {
245
+		} else {
246 246
 		$port = $globalSources[$id]['port'];
247 247
 		$hostn = $globalSources[$id]['host'];
248
-	    }
249
-	    $Common = new Common();
250
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
251
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
252
-    	    } else {
253
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
254
-	    }
255
-	    if ($s) {
256
-    	        $sockets[$id] = $s;
257
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
258
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
248
+		}
249
+		$Common = new Common();
250
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
251
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
252
+			} else {
253
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
254
+		}
255
+		if ($s) {
256
+				$sockets[$id] = $s;
257
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
258
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
259 259
 			//$formats[$id] = 'aprs';
260 260
 			$globalSources[$id]['format'] = 'aprs';
261 261
 			//$aprs_connect = 0;
262 262
 			//$use_aprs = true;
263
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
263
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
264 264
 			$globalSources[$id]['format'] = 'vrstcp';
265
-    		    } elseif ($port == '10001') {
266
-        		//$formats[$id] = 'tsv';
267
-        		$globalSources[$id]['format'] = 'tsv';
268
-		    } elseif ($port == '30002') {
269
-        		//$formats[$id] = 'raw';
270
-        		$globalSources[$id]['format'] = 'raw';
271
-		    } elseif ($port == '5001') {
272
-        		//$formats[$id] = 'raw';
273
-        		$globalSources[$id]['format'] = 'flightgearmp';
274
-		    } elseif ($port == '30005') {
265
+				} elseif ($port == '10001') {
266
+				//$formats[$id] = 'tsv';
267
+				$globalSources[$id]['format'] = 'tsv';
268
+			} elseif ($port == '30002') {
269
+				//$formats[$id] = 'raw';
270
+				$globalSources[$id]['format'] = 'raw';
271
+			} elseif ($port == '5001') {
272
+				//$formats[$id] = 'raw';
273
+				$globalSources[$id]['format'] = 'flightgearmp';
274
+			} elseif ($port == '30005') {
275 275
 			// Not yet supported
276
-        		//$formats[$id] = 'beast';
277
-        		$globalSources[$id]['format'] = 'beast';
278
-		    //} else $formats[$id] = 'sbs';
279
-		    } else $globalSources[$id]['format'] = 'sbs';
280
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
276
+				//$formats[$id] = 'beast';
277
+				$globalSources[$id]['format'] = 'beast';
278
+			//} else $formats[$id] = 'sbs';
279
+			} else $globalSources[$id]['format'] = 'sbs';
280
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
281 281
 		}
282 282
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
283
-            } else {
283
+			} else {
284 284
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
285
-    	    }
286
-        }
287
-    }
285
+			}
286
+		}
287
+	}
288 288
 }
289 289
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
290 290
 
@@ -307,9 +307,9 @@  discard block
 block discarded – undo
307 307
 //connect_all($globalSources);
308 308
 
309 309
 if (isset($globalProxy) && $globalProxy) {
310
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
310
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
311 311
 } else {
312
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
312
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
313 313
 }
314 314
 
315 315
 // APRS Configuration
@@ -318,21 +318,21 @@  discard block
 block discarded – undo
318 318
 	die;
319 319
 }
320 320
 foreach ($globalSources as $key => $source) {
321
-    if (!isset($source['format'])) {
322
-        $globalSources[$key]['format'] = 'auto';
323
-    }
324
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
325
-        unset($globalSources[$key]);
326
-    }
321
+	if (!isset($source['format'])) {
322
+		$globalSources[$key]['format'] = 'auto';
323
+	}
324
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
325
+		unset($globalSources[$key]);
326
+	}
327 327
 }
328 328
 connect_all($globalSources);
329 329
 foreach ($globalSources as $key => $source) {
330
-    if (isset($source['format']) && $source['format'] == 'aprs') {
330
+	if (isset($source['format']) && $source['format'] == 'aprs') {
331 331
 	$aprs_connect = 0;
332 332
 	$use_aprs = true;
333 333
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
334 334
 	break;
335
-    }
335
+	}
336 336
 }
337 337
 
338 338
 if ($use_aprs) {
@@ -373,126 +373,126 @@  discard block
 block discarded – undo
373 373
 
374 374
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
375 375
 while ($i > 0) {
376
-    if (!$globalDaemon) $i = $endtime-time();
377
-    // Delete old ATC
378
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
376
+	if (!$globalDaemon) $i = $endtime-time();
377
+	// Delete old ATC
378
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
379 379
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
380
-        $ATC->deleteOldATC();
381
-    }
380
+		$ATC->deleteOldATC();
381
+	}
382 382
     
383
-    if (count($last_exec) == count($globalSources)) {
383
+	if (count($last_exec) == count($globalSources)) {
384 384
 	$max = $globalMinFetch;
385 385
 	foreach ($last_exec as $last) {
386
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
386
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
387 387
 	}
388 388
 	if ($max != $globalMinFetch) {
389
-	    if ($globalDebug) echo 'Sleeping...'."\n";
390
-	    sleep($globalMinFetch-$max+2);
389
+		if ($globalDebug) echo 'Sleeping...'."\n";
390
+		sleep($globalMinFetch-$max+2);
391
+	}
391 392
 	}
392
-    }
393 393
 
394 394
     
395
-    //foreach ($formats as $id => $value) {
396
-    foreach ($globalSources as $id => $value) {
395
+	//foreach ($formats as $id => $value) {
396
+	foreach ($globalSources as $id => $value) {
397 397
 	date_default_timezone_set('UTC');
398 398
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
399 399
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
400 400
 	if ($value['format'] == 'deltadbtxt' && 
401
-	    (
401
+		(
402 402
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
403 403
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
404
-	    )
404
+		)
405 405
 	) {
406
-	    //$buffer = $Common->getData($hosts[$id]);
407
-	    $buffer = $Common->getData($value['host']);
408
-	    if ($buffer != '') $reset = 0;
409
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
410
-	    $buffer = explode('\n',$buffer);
411
-	    foreach ($buffer as $line) {
412
-    		if ($line != '' && count($line) > 7) {
413
-    		    $line = explode(',', $line);
414
-	            $data = array();
415
-	            $data['hex'] = $line[1]; // hex
416
-	            $data['ident'] = $line[2]; // ident
417
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
418
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
419
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
420
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
421
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
422
-	            $data['verticalrate'] = ''; // vertical rate
423
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
424
-	            $data['emergency'] = ''; // emergency
425
-		    $data['datetime'] = date('Y-m-d H:i:s');
426
-		    $data['format_source'] = 'deltadbtxt';
427
-    		    $data['id_source'] = $id_source;
428
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
429
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
430
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
431
-    		    $SI->add($data);
432
-		    unset($data);
433
-    		}
434
-    	    }
435
-    	    $last_exec[$id]['last'] = time();
406
+		//$buffer = $Common->getData($hosts[$id]);
407
+		$buffer = $Common->getData($value['host']);
408
+		if ($buffer != '') $reset = 0;
409
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
410
+		$buffer = explode('\n',$buffer);
411
+		foreach ($buffer as $line) {
412
+			if ($line != '' && count($line) > 7) {
413
+				$line = explode(',', $line);
414
+				$data = array();
415
+				$data['hex'] = $line[1]; // hex
416
+				$data['ident'] = $line[2]; // ident
417
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
418
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
419
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
420
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
421
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
422
+				$data['verticalrate'] = ''; // vertical rate
423
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
424
+				$data['emergency'] = ''; // emergency
425
+			$data['datetime'] = date('Y-m-d H:i:s');
426
+			$data['format_source'] = 'deltadbtxt';
427
+				$data['id_source'] = $id_source;
428
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
429
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
430
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
431
+				$SI->add($data);
432
+			unset($data);
433
+			}
434
+			}
435
+			$last_exec[$id]['last'] = time();
436 436
 	} elseif ($value['format'] == 'aisnmeatxt' && 
437
-	    (
437
+		(
438 438
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
439 439
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
440
-	    )
440
+		)
441 441
 	) {
442
-	    date_default_timezone_set('CET');
443
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
444
-	    date_default_timezone_set('UTC');
445
-	    if ($buffer != '') $reset = 0;
446
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
447
-	    $buffer = explode('\n',$buffer);
448
-	    foreach ($buffer as $line) {
442
+		date_default_timezone_set('CET');
443
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
444
+		date_default_timezone_set('UTC');
445
+		if ($buffer != '') $reset = 0;
446
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
447
+		$buffer = explode('\n',$buffer);
448
+		foreach ($buffer as $line) {
449 449
 		if ($line != '') {
450
-		    //echo "'".$line."'\n";
451
-		    $add = false;
452
-		    $ais_data = $AIS->parse_line(trim($line));
453
-		    $data = array();
454
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
455
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
456
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
457
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
458
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
459
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
460
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
461
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
462
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
463
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
464
-		    if (isset($ais_data['timestamp'])) {
450
+			//echo "'".$line."'\n";
451
+			$add = false;
452
+			$ais_data = $AIS->parse_line(trim($line));
453
+			$data = array();
454
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
455
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
456
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
457
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
458
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
459
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
460
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
461
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
462
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
463
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
464
+			if (isset($ais_data['timestamp'])) {
465 465
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
466 466
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
467
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
468
-			    $add = true;
467
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
468
+				$add = true;
469 469
 			}
470
-		    } else {
470
+			} else {
471 471
 			$data['datetime'] = date('Y-m-d H:i:s');
472 472
 			$add = true;
473
-		    }
474
-		    $data['format_source'] = 'aisnmeatxt';
475
-    		    $data['id_source'] = $id_source;
476
-		    //print_r($data);
477
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
478
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
479
-		    unset($data);
473
+			}
474
+			$data['format_source'] = 'aisnmeatxt';
475
+				$data['id_source'] = $id_source;
476
+			//print_r($data);
477
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
478
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
479
+			unset($data);
480 480
 		}
481
-    	    }
482
-    	    $last_exec[$id]['last'] = time();
481
+			}
482
+			$last_exec[$id]['last'] = time();
483 483
 	} elseif ($value['format'] == 'aisnmeahttp') {
484
-	    $arr = $httpfeeds;
485
-	    $w = $e = null;
484
+		$arr = $httpfeeds;
485
+		$w = $e = null;
486 486
 	    
487
-	    if (isset($arr[$id])) {
487
+		if (isset($arr[$id])) {
488 488
 		$nn = stream_select($arr,$w,$e,$timeout);
489 489
 		if ($nn > 0) {
490
-		    foreach ($httpfeeds as $feed) {
490
+			foreach ($httpfeeds as $feed) {
491 491
 			$buffer = stream_get_line($feed,2000,"\n");
492 492
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
493 493
 			$buffer = explode('\n',$buffer);
494 494
 			foreach ($buffer as $line) {
495
-			    if ($line != '') {
495
+				if ($line != '') {
496 496
 				$ais_data = $AIS->parse_line(trim($line));
497 497
 				$data = array();
498 498
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -510,111 +510,111 @@  discard block
 block discarded – undo
510 510
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
511 511
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
512 512
 				if (isset($ais_data['timestamp'])) {
513
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
513
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
514 514
 				} else {
515
-				    $data['datetime'] = date('Y-m-d H:i:s');
515
+					$data['datetime'] = date('Y-m-d H:i:s');
516 516
 				}
517 517
 				$data['format_source'] = 'aisnmeahttp';
518 518
 				$data['id_source'] = $id_source;
519 519
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
520 520
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
521 521
 				unset($data);
522
-			    }
522
+				}
523
+			}
523 524
 			}
524
-		    }
525 525
 		} else {
526
-		    $format = $value['format'];
527
-		    if (isset($tt[$format])) $tt[$format]++;
528
-		    else $tt[$format] = 0;
529
-		    if ($tt[$format] > 30) {
526
+			$format = $value['format'];
527
+			if (isset($tt[$format])) $tt[$format]++;
528
+			else $tt[$format] = 0;
529
+			if ($tt[$format] > 30) {
530 530
 			if ($globalDebug) echo 'Reconnect...'."\n";
531 531
 			sleep(2);
532 532
 			$sourceeen[] = $value;
533 533
 			connect_all($sourceeen);
534 534
 			$sourceeen = array();
535
-		    }
535
+			}
536
+		}
536 537
 		}
537
-	    }
538 538
 	} elseif ($value['format'] == 'myshiptracking' && 
539
-	    (
539
+		(
540 540
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
541 541
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
542
-	    )
542
+		)
543 543
 	) {
544
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
545
-	    if ($buffer != '') {
544
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
545
+		if ($buffer != '') {
546 546
 		//echo $buffer;
547 547
 		$all_data = json_decode($buffer,true);
548 548
 		//print_r($all_data);
549 549
 		if (isset($all_data[0]['DATA'])) {
550
-		    foreach ($all_data[0]['DATA'] as $line) {
550
+			foreach ($all_data[0]['DATA'] as $line) {
551 551
 			if ($line != '') {
552
-			    $data = array();
553
-			    $data['ident'] = $line['NAME'];
554
-			    $data['mmsi'] = $line['MMSI'];
555
-			    $data['speed'] = $line['SOG'];
556
-			    $data['heading'] = $line['COG'];
557
-			    $data['latitude'] = $line['LAT'];
558
-			    $data['longitude'] = $line['LNG'];
559
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
560
-			    $data['imo'] = $line['IMO'];
561
-			    //$data['arrival_code'] = $ais_data['destination'];
562
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
563
-			    $data['format_source'] = 'myshiptracking';
564
-			    $data['id_source'] = $id_source;
565
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
566
-			    $MI->add($data);
567
-			    unset($data);
552
+				$data = array();
553
+				$data['ident'] = $line['NAME'];
554
+				$data['mmsi'] = $line['MMSI'];
555
+				$data['speed'] = $line['SOG'];
556
+				$data['heading'] = $line['COG'];
557
+				$data['latitude'] = $line['LAT'];
558
+				$data['longitude'] = $line['LNG'];
559
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
560
+				$data['imo'] = $line['IMO'];
561
+				//$data['arrival_code'] = $ais_data['destination'];
562
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
563
+				$data['format_source'] = 'myshiptracking';
564
+				$data['id_source'] = $id_source;
565
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
566
+				$MI->add($data);
567
+				unset($data);
568
+			}
568 569
 			}
569
-		    }
570 570
 		}
571
-	    }
572
-	    $last_exec[$id]['last'] = time();
571
+		}
572
+		$last_exec[$id]['last'] = time();
573 573
 	} elseif ($value['format'] == 'boatbeaconapp' && 
574
-	    (
574
+		(
575 575
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
576 576
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
577
-	    )
577
+		)
578 578
 	) {
579
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
580
-	    if ($buffer != '') {
579
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
580
+		if ($buffer != '') {
581 581
 		$all_data = json_decode($buffer,true);
582 582
 		if (isset($all_data[0]['mmsi'])) {
583
-		    foreach ($all_data as $line) {
583
+			foreach ($all_data as $line) {
584 584
 			if ($line != '') {
585
-			    $data = array();
586
-			    $data['ident'] = $line['shipname'];
587
-			    $data['callsign'] = $line['callsign'];
588
-			    $data['mmsi'] = $line['mmsi'];
589
-			    $data['speed'] = $line['sog'];
590
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
591
-			    $data['latitude'] = $line['latitude'];
592
-			    $data['longitude'] = $line['longitude'];
593
-			    $data['type_id'] = $line['shiptype'];
594
-			    $data['arrival_code'] = $line['destination'];
595
-			    $data['datetime'] = $line['time'];
596
-			    $data['format_source'] = 'boatbeaconapp';
597
-			    $data['id_source'] = $id_source;
598
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
599
-			    $MI->add($data);
600
-			    unset($data);
585
+				$data = array();
586
+				$data['ident'] = $line['shipname'];
587
+				$data['callsign'] = $line['callsign'];
588
+				$data['mmsi'] = $line['mmsi'];
589
+				$data['speed'] = $line['sog'];
590
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
591
+				$data['latitude'] = $line['latitude'];
592
+				$data['longitude'] = $line['longitude'];
593
+				$data['type_id'] = $line['shiptype'];
594
+				$data['arrival_code'] = $line['destination'];
595
+				$data['datetime'] = $line['time'];
596
+				$data['format_source'] = 'boatbeaconapp';
597
+				$data['id_source'] = $id_source;
598
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
599
+				$MI->add($data);
600
+				unset($data);
601
+			}
601 602
 			}
602
-		    }
603 603
 		}
604 604
 		
605
-	    }
606
-    	    $last_exec[$id]['last'] = time();
605
+		}
606
+			$last_exec[$id]['last'] = time();
607 607
 	} elseif ($value['format'] == 'boatnerd' && 
608
-	    (
608
+		(
609 609
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
610 610
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
611
-	    )
611
+		)
612 612
 	) {
613
-	    $buffer = $Common->getData($value['host']);
614
-	    if ($buffer != '') {
613
+		$buffer = $Common->getData($value['host']);
614
+		if ($buffer != '') {
615 615
 		$all_data = json_decode($buffer,true);
616 616
 		if (isset($all_data['features'][0]['id'])) {
617
-		    foreach ($all_data['features'] as $line) {
617
+			foreach ($all_data['features'] as $line) {
618 618
 			$data = array();
619 619
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
620 620
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -633,78 +633,78 @@  discard block
 block discarded – undo
633 633
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
634 634
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
635 635
 			unset($data);
636
-		    }
636
+			}
637 637
 		}
638 638
 		
639
-	    }
640
-    	    $last_exec[$id]['last'] = time();
639
+		}
640
+			$last_exec[$id]['last'] = time();
641 641
 	} elseif ($value['format'] == 'shipplotter' && 
642
-	    (
642
+		(
643 643
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
644 644
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
645
-	    )
645
+		)
646 646
 	) {
647
-	    echo 'download...';
648
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
649
-	    echo 'done !'."\n";
650
-	    if ($buffer != '') $reset = 0;
651
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
652
-	    $buffer = explode('\n',$buffer);
653
-	    foreach ($buffer as $line) {
647
+		echo 'download...';
648
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
649
+		echo 'done !'."\n";
650
+		if ($buffer != '') $reset = 0;
651
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
652
+		$buffer = explode('\n',$buffer);
653
+		foreach ($buffer as $line) {
654 654
 		if ($line != '') {
655
-		    $data = array();
656
-		    $data['mmsi'] = (int)substr($line,0,9);
657
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
658
-		    //$data['status'] = substr($line,21,2);
659
-		    //$data['type'] = substr($line,24,3);
660
-		    $data['latitude'] = substr($line,29,9);
661
-		    $data['longitude'] = substr($line,41,9);
662
-		    $data['speed'] = round(substr($line,51,5));
663
-		    //$data['course'] = substr($line,57,5);
664
-		    $data['heading'] = round(substr($line,63,3));
665
-		    //$data['draft'] = substr($line,67,4);
666
-		    //$data['length'] = substr($line,72,3);
667
-		    //$data['beam'] = substr($line,76,2);
668
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
669
-		    //$data['callsign'] = trim(substr($line,100,7);
670
-		    //$data['dest'] = substr($line,108,20);
671
-		    //$data['etaDate'] = substr($line,129,5);
672
-		    //$data['etaTime'] = substr($line,135,5);
673
-		    $data['format_source'] = 'shipplotter';
674
-    		    $data['id_source'] = $id_source;
675
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
676
-		    //print_r($data);
677
-		    echo 'Add...'."\n";
678
-		    $MI->add($data);
679
-		    unset($data);
655
+			$data = array();
656
+			$data['mmsi'] = (int)substr($line,0,9);
657
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
658
+			//$data['status'] = substr($line,21,2);
659
+			//$data['type'] = substr($line,24,3);
660
+			$data['latitude'] = substr($line,29,9);
661
+			$data['longitude'] = substr($line,41,9);
662
+			$data['speed'] = round(substr($line,51,5));
663
+			//$data['course'] = substr($line,57,5);
664
+			$data['heading'] = round(substr($line,63,3));
665
+			//$data['draft'] = substr($line,67,4);
666
+			//$data['length'] = substr($line,72,3);
667
+			//$data['beam'] = substr($line,76,2);
668
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
669
+			//$data['callsign'] = trim(substr($line,100,7);
670
+			//$data['dest'] = substr($line,108,20);
671
+			//$data['etaDate'] = substr($line,129,5);
672
+			//$data['etaTime'] = substr($line,135,5);
673
+			$data['format_source'] = 'shipplotter';
674
+				$data['id_source'] = $id_source;
675
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
676
+			//print_r($data);
677
+			echo 'Add...'."\n";
678
+			$MI->add($data);
679
+			unset($data);
680 680
 		}
681
-    	    }
682
-    	    $last_exec[$id]['last'] = time();
681
+			}
682
+			$last_exec[$id]['last'] = time();
683 683
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
684 684
 	} elseif (
685
-	    (
685
+		(
686 686
 		$value['format'] == 'whazzup' && 
687 687
 		(
688
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
689
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
688
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
689
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
690 690
 		)
691
-	    ) || (
691
+		) || (
692 692
 		$value['format'] == 'vatsimtxt' && 
693 693
 		(
694
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
695
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
694
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
695
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
696
+		)
696 697
 		)
697
-	    )
698 698
 	) {
699
-	    //$buffer = $Common->getData($hosts[$id]);
700
-	    $buffer = $Common->getData($value['host']);
701
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
702
-	    $buffer = explode('\n',$buffer);
703
-	    $reset = 0;
704
-	    foreach ($buffer as $line) {
705
-    		if ($line != '') {
706
-    		    $line = explode(':', $line);
707
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
699
+		//$buffer = $Common->getData($hosts[$id]);
700
+		$buffer = $Common->getData($value['host']);
701
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
702
+		$buffer = explode('\n',$buffer);
703
+		$reset = 0;
704
+		foreach ($buffer as $line) {
705
+			if ($line != '') {
706
+				$line = explode(':', $line);
707
+				if (count($line) > 30 && $line[0] != 'callsign') {
708 708
 			$data = array();
709 709
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
710 710
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -717,37 +717,37 @@  discard block
 block discarded – undo
717 717
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
718 718
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
719 719
 			$data['latitude'] = $line[5]; // lat
720
-	        	$data['longitude'] = $line[6]; // long
721
-	        	$data['verticalrate'] = ''; // vertical rate
722
-	        	$data['squawk'] = ''; // squawk
723
-	        	$data['emergency'] = ''; // emergency
724
-	        	$data['waypoints'] = $line[30];
720
+				$data['longitude'] = $line[6]; // long
721
+				$data['verticalrate'] = ''; // vertical rate
722
+				$data['squawk'] = ''; // squawk
723
+				$data['emergency'] = ''; // emergency
724
+				$data['waypoints'] = $line[30];
725 725
 			$data['datetime'] = date('Y-m-d H:i:s');
726 726
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
727 727
 			//if (isset($line[37])) $data['last_update'] = $line[37];
728
-		        $data['departure_airport_icao'] = $line[11];
729
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
730
-		        $data['arrival_airport_icao'] = $line[13];
728
+				$data['departure_airport_icao'] = $line[11];
729
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
730
+				$data['arrival_airport_icao'] = $line[13];
731 731
 			$data['frequency'] = $line[4];
732 732
 			$data['type'] = $line[18];
733 733
 			$data['range'] = $line[19];
734 734
 			if (isset($line[35])) $data['info'] = $line[35];
735
-    			$data['id_source'] = $id_source;
736
-	    		//$data['arrival_airport_time'] = ;
737
-	    		if ($line[9] != '') {
738
-	    		    $aircraft_data = explode('/',$line[9]);
739
-	    		    if (isset($aircraft_data[1])) {
740
-	    			$data['aircraft_icao'] = $aircraft_data[1];
741
-	    		    }
742
-        		}
743
-	    		/*
735
+				$data['id_source'] = $id_source;
736
+				//$data['arrival_airport_time'] = ;
737
+				if ($line[9] != '') {
738
+					$aircraft_data = explode('/',$line[9]);
739
+					if (isset($aircraft_data[1])) {
740
+					$data['aircraft_icao'] = $aircraft_data[1];
741
+					}
742
+				}
743
+				/*
744 744
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
745 745
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
746 746
 	    		*/
747
-	    		$data['format_source'] = $value['format'];
747
+				$data['format_source'] = $value['format'];
748 748
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
749 749
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
750
-    			if ($line[3] == 'PILOT') $SI->add($data);
750
+				if ($line[3] == 'PILOT') $SI->add($data);
751 751
 			elseif ($line[3] == 'ATC') {
752 752
 				//print_r($data);
753 753
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -768,21 +768,21 @@  discard block
 block discarded – undo
768 768
 					else 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']);
769 769
 				}
770 770
 			}
771
-    			unset($data);
772
-    		    }
773
-    		}
774
-    	    }
775
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
776
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
777
-    	    $last_exec[$id]['last'] = time();
778
-    	} elseif ($value['format'] == 'airwhere' && 
779
-    	    (
780
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
781
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
782
-    	    )
783
-    	) {
784
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
785
-	    if ($buffer != '') {
771
+				unset($data);
772
+				}
773
+			}
774
+			}
775
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
776
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
777
+			$last_exec[$id]['last'] = time();
778
+		} elseif ($value['format'] == 'airwhere' && 
779
+			(
780
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
781
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
782
+			)
783
+		) {
784
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
785
+		if ($buffer != '') {
786 786
 		$all_data = simplexml_load_string($buffer);
787 787
 		foreach($all_data->children() as $childdata) {
788 788
 			$data = array();
@@ -804,10 +804,10 @@  discard block
 block discarded – undo
804 804
 			$SI->add($data);
805 805
 			unset($data);
806 806
 		}
807
-	    }
808
-	    $Source->deleteOldLocationByType('gs');
809
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
810
-	    if ($buffer != '') {
807
+		}
808
+		$Source->deleteOldLocationByType('gs');
809
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
810
+		if ($buffer != '') {
811 811
 		$all_data = simplexml_load_string($buffer);
812 812
 		foreach($all_data->children() as $childdata) {
813 813
 			$data = array();
@@ -825,8 +825,8 @@  discard block
 block discarded – undo
825 825
 			}
826 826
 			unset($data);
827 827
 		}
828
-	    }
829
-	    $last_exec[$id]['last'] = time();
828
+		}
829
+		$last_exec[$id]['last'] = time();
830 830
 	/*
831 831
 	} if ($value['format'] == 'aircraftlistjson') {
832 832
 	    print_r($globalSources);
@@ -834,17 +834,17 @@  discard block
 block discarded – undo
834 834
 	    echo $globalMinFetch;
835 835
 	*/
836 836
 	} elseif ($value['format'] == 'aircraftlistjson' && 
837
-	    (
837
+		(
838 838
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
839 839
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
840
-	    )
840
+		)
841 841
 	) {
842
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
843
-	    if ($buffer != '') {
844
-	        $all_data = json_decode($buffer,true);
842
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
843
+		if ($buffer != '') {
844
+			$all_data = json_decode($buffer,true);
845 845
 		if (isset($all_data['acList'])) {
846
-		    $reset = 0;
847
-		    foreach ($all_data['acList'] as $line) {
846
+			$reset = 0;
847
+			foreach ($all_data['acList'] as $line) {
848 848
 			$data = array();
849 849
 			$data['hex'] = $line['Icao']; // hex
850 850
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -867,10 +867,10 @@  discard block
 block discarded – undo
867 867
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
868 868
 			if (isset($data['latitude'])) $SI->add($data);
869 869
 			unset($data);
870
-		    }
870
+			}
871 871
 		} elseif (is_array($all_data)) {
872
-		    $reset = 0;
873
-		    foreach ($all_data as $line) {
872
+			$reset = 0;
873
+			foreach ($all_data as $line) {
874 874
 			$data = array();
875 875
 			$data['hex'] = $line['hex']; // hex
876 876
 			$data['ident'] = $line['flight']; // ident
@@ -890,218 +890,218 @@  discard block
 block discarded – undo
890 890
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
891 891
 			$SI->add($data);
892 892
 			unset($data);
893
-		    }
893
+			}
894 894
 		}
895
-	    } elseif ($globalDebug) echo 'No data'."\n";
896
-    	    //$last_exec['aircraftlistjson'] = time();
897
-    	    $last_exec[$id]['last'] = time();
898
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
899
-    	} elseif ($value['format'] == 'planeupdatefaa' && 
900
-    	    (
901
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
902
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
903
-    	    )
904
-    	) {
905
-	    $buffer = $Common->getData($value['host']);
906
-	    $all_data = json_decode($buffer,true);
907
-	    if (isset($all_data['planes'])) {
895
+		} elseif ($globalDebug) echo 'No data'."\n";
896
+			//$last_exec['aircraftlistjson'] = time();
897
+			$last_exec[$id]['last'] = time();
898
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
899
+		} elseif ($value['format'] == 'planeupdatefaa' && 
900
+			(
901
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
902
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
903
+			)
904
+		) {
905
+		$buffer = $Common->getData($value['host']);
906
+		$all_data = json_decode($buffer,true);
907
+		if (isset($all_data['planes'])) {
908 908
 		$reset = 0;
909 909
 		foreach ($all_data['planes'] as $key => $line) {
910
-		    $data = array();
911
-		    $data['hex'] = $key; // hex
912
-		    $data['ident'] = $line[3]; // ident
913
-		    $data['altitude'] = $line[6]; // altitude
914
-		    $data['speed'] = $line[8]; // speed
915
-		    $data['heading'] = $line[7]; // heading
916
-		    $data['latitude'] = $line[4]; // lat
917
-		    $data['longitude'] = $line[5]; // long
918
-		    //$data['verticalrate'] = $line[]; // verticale rate
919
-		    $data['squawk'] = $line[10]; // squawk
920
-		    $data['emergency'] = ''; // emergency
921
-		    $data['registration'] = $line[2];
922
-		    $data['aircraft_icao'] = $line[0];
923
-		    $deparr = explode('-',$line[1]);
924
-		    if (count($deparr) == 2) {
910
+			$data = array();
911
+			$data['hex'] = $key; // hex
912
+			$data['ident'] = $line[3]; // ident
913
+			$data['altitude'] = $line[6]; // altitude
914
+			$data['speed'] = $line[8]; // speed
915
+			$data['heading'] = $line[7]; // heading
916
+			$data['latitude'] = $line[4]; // lat
917
+			$data['longitude'] = $line[5]; // long
918
+			//$data['verticalrate'] = $line[]; // verticale rate
919
+			$data['squawk'] = $line[10]; // squawk
920
+			$data['emergency'] = ''; // emergency
921
+			$data['registration'] = $line[2];
922
+			$data['aircraft_icao'] = $line[0];
923
+			$deparr = explode('-',$line[1]);
924
+			if (count($deparr) == 2) {
925 925
 			$data['departure_airport_icao'] = $deparr[0];
926 926
 			$data['arrival_airport_icao'] = $deparr[1];
927
-		    }
928
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
929
-	    	    $data['format_source'] = 'planeupdatefaa';
930
-    		    $data['id_source'] = $id_source;
931
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
932
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
933
-		    $SI->add($data);
934
-		    unset($data);
927
+			}
928
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
929
+				$data['format_source'] = 'planeupdatefaa';
930
+				$data['id_source'] = $id_source;
931
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
932
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
933
+			$SI->add($data);
934
+			unset($data);
935
+		}
935 936
 		}
936
-	    }
937
-	    //$last_exec['planeupdatefaa'] = time();
938
-	    $last_exec[$id]['last'] = time();
937
+		//$last_exec['planeupdatefaa'] = time();
938
+		$last_exec[$id]['last'] = time();
939 939
 	} elseif ($value['format'] == 'opensky' && 
940
-	    (
940
+		(
941 941
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
942 942
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
943
-	    )
943
+		)
944 944
 	) {
945
-	    $buffer = $Common->getData($value['host']);
946
-	    $all_data = json_decode($buffer,true);
947
-	    if (isset($all_data['states'])) {
945
+		$buffer = $Common->getData($value['host']);
946
+		$all_data = json_decode($buffer,true);
947
+		if (isset($all_data['states'])) {
948 948
 		$reset = 0;
949 949
 		foreach ($all_data['states'] as $key => $line) {
950
-		    $data = array();
951
-		    $data['hex'] = $line[0]; // hex
952
-		    $data['ident'] = trim($line[1]); // ident
953
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
954
-		    $data['speed'] = round($line[9]*1.94384); // speed
955
-		    $data['heading'] = round($line[10]); // heading
956
-		    $data['latitude'] = $line[6]; // lat
957
-		    $data['longitude'] = $line[5]; // long
958
-		    $data['verticalrate'] = $line[11]; // verticale rate
959
-		    //$data['squawk'] = $line[10]; // squawk
960
-		    //$data['emergency'] = ''; // emergency
961
-		    //$data['registration'] = $line[2];
962
-		    //$data['aircraft_icao'] = $line[0];
963
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
964
-		    $data['format_source'] = 'opensky';
965
-		    $data['id_source'] = $id_source;
966
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
967
-		    $SI->add($data);
968
-		    unset($data);
950
+			$data = array();
951
+			$data['hex'] = $line[0]; // hex
952
+			$data['ident'] = trim($line[1]); // ident
953
+			$data['altitude'] = round($line[7]*3.28084); // altitude
954
+			$data['speed'] = round($line[9]*1.94384); // speed
955
+			$data['heading'] = round($line[10]); // heading
956
+			$data['latitude'] = $line[6]; // lat
957
+			$data['longitude'] = $line[5]; // long
958
+			$data['verticalrate'] = $line[11]; // verticale rate
959
+			//$data['squawk'] = $line[10]; // squawk
960
+			//$data['emergency'] = ''; // emergency
961
+			//$data['registration'] = $line[2];
962
+			//$data['aircraft_icao'] = $line[0];
963
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
964
+			$data['format_source'] = 'opensky';
965
+			$data['id_source'] = $id_source;
966
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
967
+			$SI->add($data);
968
+			unset($data);
969 969
 		}
970
-	    }
971
-	    //$last_exec['planeupdatefaa'] = time();
972
-	    $last_exec[$id]['last'] = time();
970
+		}
971
+		//$last_exec['planeupdatefaa'] = time();
972
+		$last_exec[$id]['last'] = time();
973 973
 	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
974 974
 	} elseif ($value['format'] == 'fr24json' && 
975
-	    (
975
+		(
976 976
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
977 977
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
978
-	    )
978
+		)
979 979
 	) {
980
-	    //$buffer = $Common->getData($hosts[$id]);
981
-	    $buffer = $Common->getData($value['host']);
982
-	    $all_data = json_decode($buffer,true);
983
-	    if (!empty($all_data)) $reset = 0;
984
-	    foreach ($all_data as $key => $line) {
980
+		//$buffer = $Common->getData($hosts[$id]);
981
+		$buffer = $Common->getData($value['host']);
982
+		$all_data = json_decode($buffer,true);
983
+		if (!empty($all_data)) $reset = 0;
984
+		foreach ($all_data as $key => $line) {
985 985
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
986
-		    $data = array();
987
-		    $data['hex'] = $line[0];
988
-		    $data['ident'] = $line[16]; //$line[13]
989
-	    	    $data['altitude'] = $line[4]; // altitude
990
-	    	    $data['speed'] = $line[5]; // speed
991
-	    	    $data['heading'] = $line[3]; // heading
992
-	    	    $data['latitude'] = $line[1]; // lat
993
-	    	    $data['longitude'] = $line[2]; // long
994
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
995
-	    	    $data['squawk'] = $line[6]; // squawk
996
-	    	    $data['aircraft_icao'] = $line[8];
997
-	    	    $data['registration'] = $line[9];
998
-		    $data['departure_airport_iata'] = $line[11];
999
-		    $data['arrival_airport_iata'] = $line[12];
1000
-	    	    $data['emergency'] = ''; // emergency
1001
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1002
-	    	    $data['format_source'] = 'fr24json';
1003
-    		    $data['id_source'] = $id_source;
1004
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1005
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1006
-		    $SI->add($data);
1007
-		    unset($data);
986
+			$data = array();
987
+			$data['hex'] = $line[0];
988
+			$data['ident'] = $line[16]; //$line[13]
989
+				$data['altitude'] = $line[4]; // altitude
990
+				$data['speed'] = $line[5]; // speed
991
+				$data['heading'] = $line[3]; // heading
992
+				$data['latitude'] = $line[1]; // lat
993
+				$data['longitude'] = $line[2]; // long
994
+				$data['verticalrate'] = $line[15]; // verticale rate
995
+				$data['squawk'] = $line[6]; // squawk
996
+				$data['aircraft_icao'] = $line[8];
997
+				$data['registration'] = $line[9];
998
+			$data['departure_airport_iata'] = $line[11];
999
+			$data['arrival_airport_iata'] = $line[12];
1000
+				$data['emergency'] = ''; // emergency
1001
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1002
+				$data['format_source'] = 'fr24json';
1003
+				$data['id_source'] = $id_source;
1004
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1005
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1006
+			$SI->add($data);
1007
+			unset($data);
1008 1008
 		}
1009
-	    }
1010
-	    //$last_exec['fr24json'] = time();
1011
-	    $last_exec[$id]['last'] = time();
1009
+		}
1010
+		//$last_exec['fr24json'] = time();
1011
+		$last_exec[$id]['last'] = time();
1012 1012
 	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1013 1013
 	} elseif ($value['format'] == 'radarvirtueljson' && 
1014
-	    (
1014
+		(
1015 1015
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1016 1016
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1017
-	    )
1017
+		)
1018 1018
 	) {
1019
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1020
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1021
-	    //echo $buffer;
1022
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1023
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1024
-	    $all_data = json_decode($buffer,true);
1025
-	    if (json_last_error() != JSON_ERROR_NONE) {
1019
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1020
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1021
+		//echo $buffer;
1022
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1023
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1024
+		$all_data = json_decode($buffer,true);
1025
+		if (json_last_error() != JSON_ERROR_NONE) {
1026 1026
 		die(json_last_error_msg());
1027
-	    }
1028
-	    if (isset($all_data['mrkrs'])) {
1027
+		}
1028
+		if (isset($all_data['mrkrs'])) {
1029 1029
 		$reset = 0;
1030 1030
 		foreach ($all_data['mrkrs'] as $key => $line) {
1031
-		    if (isset($line['inf'])) {
1031
+			if (isset($line['inf'])) {
1032 1032
 			$data = array();
1033 1033
 			$data['hex'] = $line['inf']['ia'];
1034 1034
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1035
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1036
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1037
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1038
-	    		$data['latitude'] = $line['pt'][0]; // lat
1039
-	    		$data['longitude'] = $line['pt'][1]; // long
1040
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1041
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1042
-	    		//$data['aircraft_icao'] = $line[8];
1043
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1035
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1036
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1037
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1038
+				$data['latitude'] = $line['pt'][0]; // lat
1039
+				$data['longitude'] = $line['pt'][1]; // long
1040
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1041
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1042
+				//$data['aircraft_icao'] = $line[8];
1043
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1044 1044
 			//$data['departure_airport_iata'] = $line[11];
1045 1045
 			//$data['arrival_airport_iata'] = $line[12];
1046
-	    		//$data['emergency'] = ''; // emergency
1046
+				//$data['emergency'] = ''; // emergency
1047 1047
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1048
-	    		$data['format_source'] = 'radarvirtueljson';
1049
-    			$data['id_source'] = $id_source;
1048
+				$data['format_source'] = 'radarvirtueljson';
1049
+				$data['id_source'] = $id_source;
1050 1050
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1051 1051
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1052 1052
 			$SI->add($data);
1053 1053
 			unset($data);
1054
-		    }
1054
+			}
1055
+		}
1055 1056
 		}
1056
-	    }
1057
-	    //$last_exec['radarvirtueljson'] = time();
1058
-	    $last_exec[$id]['last'] = time();
1057
+		//$last_exec['radarvirtueljson'] = time();
1058
+		$last_exec[$id]['last'] = time();
1059 1059
 	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1060 1060
 	} elseif ($value['format'] == 'pirepsjson' && 
1061
-	    (
1061
+		(
1062 1062
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1063 1063
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1064
-	    )
1064
+		)
1065 1065
 	) {
1066
-	    //$buffer = $Common->getData($hosts[$id]);
1067
-	    $buffer = $Common->getData($value['host'].'?'.time());
1068
-	    $all_data = json_decode(utf8_encode($buffer),true);
1066
+		//$buffer = $Common->getData($hosts[$id]);
1067
+		$buffer = $Common->getData($value['host'].'?'.time());
1068
+		$all_data = json_decode(utf8_encode($buffer),true);
1069 1069
 	    
1070
-	    if (isset($all_data['pireps'])) {
1070
+		if (isset($all_data['pireps'])) {
1071 1071
 		$reset = 0;
1072
-	        foreach ($all_data['pireps'] as $line) {
1073
-		    $data = array();
1074
-		    $data['id'] = $line['id'];
1075
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1076
-		    $data['ident'] = $line['callsign']; // ident
1077
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1078
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1079
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1080
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1081
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1082
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1083
-		    $data['latitude'] = $line['lat']; // lat
1084
-		    $data['longitude'] = $line['lon']; // long
1085
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1086
-		    //$data['squawk'] = $line['squawk']; // squawk
1087
-		    //$data['emergency'] = ''; // emergency
1088
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1089
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1090
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1091
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1092
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1093
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1094
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1095
-		    else $data['info'] = '';
1096
-		    $data['format_source'] = 'pireps';
1097
-    		    $data['id_source'] = $id_source;
1098
-		    $data['datetime'] = date('Y-m-d H:i:s');
1099
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1100
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1101
-		    if ($line['icon'] == 'plane') {
1072
+			foreach ($all_data['pireps'] as $line) {
1073
+			$data = array();
1074
+			$data['id'] = $line['id'];
1075
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1076
+			$data['ident'] = $line['callsign']; // ident
1077
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1078
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1079
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1080
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1081
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1082
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1083
+			$data['latitude'] = $line['lat']; // lat
1084
+			$data['longitude'] = $line['lon']; // long
1085
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1086
+			//$data['squawk'] = $line['squawk']; // squawk
1087
+			//$data['emergency'] = ''; // emergency
1088
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1089
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1090
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1091
+			//$data['arrival_airport_time'] = $line['arrtime'];
1092
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1093
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1094
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1095
+			else $data['info'] = '';
1096
+			$data['format_source'] = 'pireps';
1097
+				$data['id_source'] = $id_source;
1098
+			$data['datetime'] = date('Y-m-d H:i:s');
1099
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1100
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1101
+			if ($line['icon'] == 'plane') {
1102 1102
 			$SI->add($data);
1103
-		    //    print_r($data);
1104
-    		    } elseif ($line['icon'] == 'ct') {
1103
+			//    print_r($data);
1104
+				} elseif ($line['icon'] == 'ct') {
1105 1105
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1106 1106
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1107 1107
 			$typec = substr($data['ident'],-3);
@@ -1116,148 +1116,148 @@  discard block
 block discarded – undo
1116 1116
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1117 1117
 			else $data['type'] = 'Observer';
1118 1118
 			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']);
1119
-		    }
1120
-		    unset($data);
1119
+			}
1120
+			unset($data);
1121
+		}
1121 1122
 		}
1122
-	    }
1123
-	    //$last_exec['pirepsjson'] = time();
1124
-	    $last_exec[$id]['last'] = time();
1123
+		//$last_exec['pirepsjson'] = time();
1124
+		$last_exec[$id]['last'] = time();
1125 1125
 	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1126 1126
 	} elseif ($value['format'] == 'phpvmacars' && 
1127
-	    (
1127
+		(
1128 1128
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1129 1129
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1130
-	    )
1130
+		)
1131 1131
 	) {
1132
-	    //$buffer = $Common->getData($hosts[$id]);
1133
-	    if ($globalDebug) echo 'Get Data...'."\n";
1134
-	    $buffer = $Common->getData($value['host']);
1135
-	    $all_data = json_decode($buffer,true);
1136
-	    if ($buffer != '' && is_array($all_data)) {
1132
+		//$buffer = $Common->getData($hosts[$id]);
1133
+		if ($globalDebug) echo 'Get Data...'."\n";
1134
+		$buffer = $Common->getData($value['host']);
1135
+		$all_data = json_decode($buffer,true);
1136
+		if ($buffer != '' && is_array($all_data)) {
1137 1137
 		$reset = 0;
1138 1138
 		foreach ($all_data as $line) {
1139
-	    	    $data = array();
1140
-	    	    //$data['id'] = $line['id']; // id not usable
1141
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1142
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1143
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1144
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1145
-	    	    $data['ident'] = $line['flightnum']; // ident
1146
-	    	    $data['altitude'] = $line['alt']; // altitude
1147
-	    	    $data['speed'] = $line['gs']; // speed
1148
-	    	    $data['heading'] = $line['heading']; // heading
1149
-	    	    $data['latitude'] = $line['lat']; // lat
1150
-	    	    $data['longitude'] = $line['lng']; // long
1151
-	    	    $data['verticalrate'] = ''; // verticale rate
1152
-	    	    $data['squawk'] = ''; // squawk
1153
-	    	    $data['emergency'] = ''; // emergency
1154
-	    	    //$data['datetime'] = $line['lastupdate'];
1155
-	    	    //$data['last_update'] = $line['lastupdate'];
1156
-	    	    if (isset($value['timezone'])) {
1157
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1158
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1159
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1160
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1161
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1162
-	    	    $data['departure_airport_time'] = $line['deptime'];
1163
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1164
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1165
-    		    $data['registration'] = $line['aircraft'];
1166
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1167
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1168
-		    if (isset($line['aircraftname'])) {
1139
+				$data = array();
1140
+				//$data['id'] = $line['id']; // id not usable
1141
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1142
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1143
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1144
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1145
+				$data['ident'] = $line['flightnum']; // ident
1146
+				$data['altitude'] = $line['alt']; // altitude
1147
+				$data['speed'] = $line['gs']; // speed
1148
+				$data['heading'] = $line['heading']; // heading
1149
+				$data['latitude'] = $line['lat']; // lat
1150
+				$data['longitude'] = $line['lng']; // long
1151
+				$data['verticalrate'] = ''; // verticale rate
1152
+				$data['squawk'] = ''; // squawk
1153
+				$data['emergency'] = ''; // emergency
1154
+				//$data['datetime'] = $line['lastupdate'];
1155
+				//$data['last_update'] = $line['lastupdate'];
1156
+				if (isset($value['timezone'])) {
1157
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1158
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1159
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1160
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1161
+				$data['departure_airport_icao'] = $line['depicao'];
1162
+				$data['departure_airport_time'] = $line['deptime'];
1163
+				$data['arrival_airport_icao'] = $line['arricao'];
1164
+				$data['arrival_airport_time'] = $line['arrtime'];
1165
+				$data['registration'] = $line['aircraft'];
1166
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1167
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1168
+			if (isset($line['aircraftname'])) {
1169 1169
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1170 1170
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1171
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1172
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1173
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1174
-	    		else {
1175
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1176
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1177
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1178
-	    		}
1179
-	    	    }
1180
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1181
-    		    $data['id_source'] = $id_source;
1182
-	    	    $data['format_source'] = 'phpvmacars';
1183
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1184
-		    $SI->add($data);
1185
-		    unset($data);
1171
+				$aircraft_data = explode('-',$line['aircraftname']);
1172
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1173
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1174
+				else {
1175
+					$aircraft_data = explode(' ',$line['aircraftname']);
1176
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1177
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1178
+				}
1179
+				}
1180
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1181
+				$data['id_source'] = $id_source;
1182
+				$data['format_source'] = 'phpvmacars';
1183
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1184
+			$SI->add($data);
1185
+			unset($data);
1186 1186
 		}
1187 1187
 		if ($globalDebug) echo 'No more data...'."\n";
1188 1188
 		unset($buffer);
1189 1189
 		unset($all_data);
1190
-	    }
1191
-	    //$last_exec['phpvmacars'] = time();
1192
-	    $last_exec[$id]['last'] = time();
1190
+		}
1191
+		//$last_exec['phpvmacars'] = time();
1192
+		$last_exec[$id]['last'] = time();
1193 1193
 	} elseif ($value['format'] == 'vam' && 
1194
-	    (
1194
+		(
1195 1195
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1196 1196
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1197
-	    )
1197
+		)
1198 1198
 	) {
1199
-	    //$buffer = $Common->getData($hosts[$id]);
1200
-	    if ($globalDebug) echo 'Get Data...'."\n";
1201
-	    $buffer = $Common->getData($value['host']);
1202
-	    $all_data = json_decode($buffer,true);
1203
-	    if ($buffer != '' && is_array($all_data)) {
1199
+		//$buffer = $Common->getData($hosts[$id]);
1200
+		if ($globalDebug) echo 'Get Data...'."\n";
1201
+		$buffer = $Common->getData($value['host']);
1202
+		$all_data = json_decode($buffer,true);
1203
+		if ($buffer != '' && is_array($all_data)) {
1204 1204
 		$reset = 0;
1205 1205
 		foreach ($all_data as $line) {
1206
-	    	    $data = array();
1207
-	    	    //$data['id'] = $line['id']; // id not usable
1208
-	    	    $data['id'] = trim($line['flight_id']);
1209
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1210
-	    	    $data['pilot_name'] = $line['pilot_name'];
1211
-	    	    $data['pilot_id'] = $line['pilot_id'];
1212
-	    	    $data['ident'] = trim($line['callsign']); // ident
1213
-	    	    $data['altitude'] = $line['altitude']; // altitude
1214
-	    	    $data['speed'] = $line['gs']; // speed
1215
-	    	    $data['heading'] = $line['heading']; // heading
1216
-	    	    $data['latitude'] = $line['latitude']; // lat
1217
-	    	    $data['longitude'] = $line['longitude']; // long
1218
-	    	    $data['verticalrate'] = ''; // verticale rate
1219
-	    	    $data['squawk'] = ''; // squawk
1220
-	    	    $data['emergency'] = ''; // emergency
1221
-	    	    //$data['datetime'] = $line['lastupdate'];
1222
-	    	    $data['last_update'] = $line['last_update'];
1223
-		    $data['datetime'] = date('Y-m-d H:i:s');
1224
-	    	    $data['departure_airport_icao'] = $line['departure'];
1225
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1226
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1227
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1228
-    		    //$data['registration'] = $line['aircraft'];
1229
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1230
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1231
-    		    $data['id_source'] = $id_source;
1232
-	    	    $data['format_source'] = 'vam';
1233
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1234
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1235
-		    $SI->add($data);
1236
-		    unset($data);
1206
+				$data = array();
1207
+				//$data['id'] = $line['id']; // id not usable
1208
+				$data['id'] = trim($line['flight_id']);
1209
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1210
+				$data['pilot_name'] = $line['pilot_name'];
1211
+				$data['pilot_id'] = $line['pilot_id'];
1212
+				$data['ident'] = trim($line['callsign']); // ident
1213
+				$data['altitude'] = $line['altitude']; // altitude
1214
+				$data['speed'] = $line['gs']; // speed
1215
+				$data['heading'] = $line['heading']; // heading
1216
+				$data['latitude'] = $line['latitude']; // lat
1217
+				$data['longitude'] = $line['longitude']; // long
1218
+				$data['verticalrate'] = ''; // verticale rate
1219
+				$data['squawk'] = ''; // squawk
1220
+				$data['emergency'] = ''; // emergency
1221
+				//$data['datetime'] = $line['lastupdate'];
1222
+				$data['last_update'] = $line['last_update'];
1223
+			$data['datetime'] = date('Y-m-d H:i:s');
1224
+				$data['departure_airport_icao'] = $line['departure'];
1225
+				//$data['departure_airport_time'] = $line['departure_time'];
1226
+				$data['arrival_airport_icao'] = $line['arrival'];
1227
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1228
+				//$data['registration'] = $line['aircraft'];
1229
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1230
+				$data['aircraft_icao'] = $line['plane_type'];
1231
+				$data['id_source'] = $id_source;
1232
+				$data['format_source'] = 'vam';
1233
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1234
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1235
+			$SI->add($data);
1236
+			unset($data);
1237 1237
 		}
1238 1238
 		if ($globalDebug) echo 'No more data...'."\n";
1239 1239
 		unset($buffer);
1240 1240
 		unset($all_data);
1241
-	    }
1242
-	    //$last_exec['phpvmacars'] = time();
1243
-	    $last_exec[$id]['last'] = time();
1241
+		}
1242
+		//$last_exec['phpvmacars'] = time();
1243
+		$last_exec[$id]['last'] = time();
1244 1244
 	} elseif ($value['format'] == 'blitzortung' && 
1245
-	    (
1245
+		(
1246 1246
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1247 1247
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1248
-	    )
1248
+		)
1249 1249
 	) {
1250
-	    //$buffer = $Common->getData($hosts[$id]);
1251
-	    if ($globalDebug) echo 'Get Data...'."\n";
1252
-	    $buffer = $Common->getData($value['host']);
1253
-	    $all_data = json_decode($buffer,true);
1254
-	    if ($buffer != '') {
1250
+		//$buffer = $Common->getData($hosts[$id]);
1251
+		if ($globalDebug) echo 'Get Data...'."\n";
1252
+		$buffer = $Common->getData($value['host']);
1253
+		$all_data = json_decode($buffer,true);
1254
+		if ($buffer != '') {
1255 1255
 		$Source->deleteLocationBySource('blitzortung');
1256 1256
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1257 1257
 		$buffer = explode('\n',$buffer);
1258 1258
 		foreach ($buffer as $buffer_line) {
1259
-		    $line = json_decode($buffer_line,true);
1260
-		    if (isset($line['time'])) {
1259
+			$line = json_decode($buffer_line,true);
1260
+			if (isset($line['time'])) {
1261 1261
 			$data = array();
1262 1262
 			$data['altitude'] = $line['alt']; // altitude
1263 1263
 			$data['latitude'] = $line['lat']; // lat
@@ -1269,94 +1269,94 @@  discard block
 block discarded – undo
1269 1269
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1270 1270
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1271 1271
 			unset($data);
1272
-		    }
1272
+			}
1273 1273
 		}
1274 1274
 		if ($globalDebug) echo 'No more data...'."\n";
1275 1275
 		unset($buffer);
1276
-	    }
1277
-	    $last_exec[$id]['last'] = time();
1276
+		}
1277
+		$last_exec[$id]['last'] = time();
1278 1278
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1279 1279
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1280
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1281
-    	    //$last_exec[$id]['last'] = time();
1280
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1281
+			//$last_exec[$id]['last'] = time();
1282 1282
 
1283
-	    //$read = array( $sockets[$id] );
1284
-	    $read = $sockets;
1285
-	    $write = NULL;
1286
-	    $e = NULL;
1287
-	    $n = socket_select($read, $write, $e, $timeout);
1288
-	    if ($e != NULL) var_dump($e);
1289
-	    if ($n > 0) {
1283
+		//$read = array( $sockets[$id] );
1284
+		$read = $sockets;
1285
+		$write = NULL;
1286
+		$e = NULL;
1287
+		$n = socket_select($read, $write, $e, $timeout);
1288
+		if ($e != NULL) var_dump($e);
1289
+		if ($n > 0) {
1290 1290
 		$reset = 0;
1291 1291
 		foreach ($read as $nb => $r) {
1292
-		    //$value = $formats[$nb];
1293
-		    $format = $globalSources[$nb]['format'];
1294
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1292
+			//$value = $formats[$nb];
1293
+			$format = $globalSources[$nb]['format'];
1294
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1295 1295
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1296
-		    } elseif ($format == 'vrstcp') {
1296
+			} elseif ($format == 'vrstcp') {
1297 1297
 			$buffer = @socket_read($r, 6000);
1298
-		    } else {
1298
+			} else {
1299 1299
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1300
-		    }
1301
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1302
-		    //echo $buffer."\n";
1303
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1304
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1305
-		    $error = false;
1306
-		    //$SI::del();
1307
-		    if ($format == 'vrstcp') {
1300
+			}
1301
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1302
+			//echo $buffer."\n";
1303
+			// lets play nice and handle signals such as ctrl-c/kill properly
1304
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1305
+			$error = false;
1306
+			//$SI::del();
1307
+			if ($format == 'vrstcp') {
1308 1308
 			$buffer = explode('},{',$buffer);
1309
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1310
-		    // SBS format is CSV format
1311
-		    if ($buffer !== FALSE && $buffer != '') {
1309
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1310
+			// SBS format is CSV format
1311
+			if ($buffer !== FALSE && $buffer != '') {
1312 1312
 			$tt[$format] = 0;
1313 1313
 			if ($format == 'acarssbs3') {
1314
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1315
-			    $ACARS->add(trim($buffer));
1316
-			    $ACARS->deleteLiveAcarsData();
1314
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1315
+				$ACARS->add(trim($buffer));
1316
+				$ACARS->deleteLiveAcarsData();
1317 1317
 			} elseif ($format == 'raw') {
1318
-			    // AVR format
1319
-			    $data = $SBS->parse($buffer);
1320
-			    if (is_array($data)) {
1318
+				// AVR format
1319
+				$data = $SBS->parse($buffer);
1320
+				if (is_array($data)) {
1321 1321
 				$data['datetime'] = date('Y-m-d H:i:s');
1322 1322
 				$data['format_source'] = 'raw';
1323 1323
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1324 1324
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1325 1325
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1326 1326
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1327
-			    }
1327
+				}
1328 1328
 			} elseif ($format == 'ais') {
1329
-			    $ais_data = $AIS->parse_line(trim($buffer));
1330
-			    $data = array();
1331
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1332
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1333
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1334
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1335
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1336
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1337
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1338
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1339
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1340
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1341
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1342
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1343
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1344
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1345
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1346
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1329
+				$ais_data = $AIS->parse_line(trim($buffer));
1330
+				$data = array();
1331
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1332
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1333
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1334
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1335
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1336
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1337
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1338
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1339
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1340
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1341
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1342
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1343
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1344
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1345
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1346
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1347 1347
 
1348
-			    if (isset($ais_data['timestamp'])) {
1348
+				if (isset($ais_data['timestamp'])) {
1349 1349
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1350
-			    } else {
1350
+				} else {
1351 1351
 				$data['datetime'] = date('Y-m-d H:i:s');
1352
-			    }
1353
-			    $data['format_source'] = 'aisnmea';
1354
-    			    $data['id_source'] = $id_source;
1355
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1356
-			    unset($data);
1357
-                        } elseif ($format == 'flightgearsp') {
1358
-                    	    //echo $buffer."\n";
1359
-                    	    if (strlen($buffer) > 5) {
1352
+				}
1353
+				$data['format_source'] = 'aisnmea';
1354
+					$data['id_source'] = $id_source;
1355
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1356
+				unset($data);
1357
+						} elseif ($format == 'flightgearsp') {
1358
+							//echo $buffer."\n";
1359
+							if (strlen($buffer) > 5) {
1360 1360
 				$line = explode(',',$buffer);
1361 1361
 				$data = array();
1362 1362
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1373,38 +1373,38 @@  discard block
 block discarded – undo
1373 1373
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1374 1374
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1375 1375
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1376
-			    }
1377
-                        } elseif ($format == 'acars') {
1378
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1379
-			    $ACARS->add(trim($buffer));
1380
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1381
-			    $ACARS->deleteLiveAcarsData();
1376
+				}
1377
+						} elseif ($format == 'acars') {
1378
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1379
+				$ACARS->add(trim($buffer));
1380
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1381
+				$ACARS->deleteLiveAcarsData();
1382 1382
 			} elseif ($format == 'flightgearmp') {
1383
-			    if (substr($buffer,0,1) != '#') {
1383
+				if (substr($buffer,0,1) != '#') {
1384 1384
 				$data = array();
1385 1385
 				//echo $buffer."\n";
1386 1386
 				$line = explode(' ',$buffer);
1387 1387
 				if (count($line) == 11) {
1388
-				    $userserver = explode('@',$line[0]);
1389
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1390
-				    $data['ident'] = $userserver[0];
1391
-				    $data['registration'] = $userserver[0];
1392
-				    $data['latitude'] = $line[4];
1393
-				    $data['longitude'] = $line[5];
1394
-				    $data['altitude'] = $line[6];
1395
-				    $data['datetime'] = date('Y-m-d H:i:s');
1396
-				    $aircraft_type = $line[10];
1397
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1398
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1399
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1400
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1388
+					$userserver = explode('@',$line[0]);
1389
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1390
+					$data['ident'] = $userserver[0];
1391
+					$data['registration'] = $userserver[0];
1392
+					$data['latitude'] = $line[4];
1393
+					$data['longitude'] = $line[5];
1394
+					$data['altitude'] = $line[6];
1395
+					$data['datetime'] = date('Y-m-d H:i:s');
1396
+					$aircraft_type = $line[10];
1397
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1398
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1399
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1400
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1401
+				}
1401 1402
 				}
1402
-			    }
1403 1403
 			} elseif ($format == 'beast') {
1404
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1405
-			    die;
1404
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1405
+				die;
1406 1406
 			} elseif ($format == 'vrstcp') {
1407
-			    foreach($buffer as $all_data) {
1407
+				foreach($buffer as $all_data) {
1408 1408
 				$line = json_decode('{'.$all_data.'}',true);
1409 1409
 				$data = array();
1410 1410
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1424,151 +1424,151 @@  discard block
 block discarded – undo
1424 1424
 				*/
1425 1425
 				$data['datetime'] = date('Y-m-d H:i:s');
1426 1426
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1427
-		    		$data['format_source'] = 'vrstcp';
1427
+					$data['format_source'] = 'vrstcp';
1428 1428
 				$data['id_source'] = $id_source;
1429 1429
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1430 1430
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1431 1431
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1432 1432
 				unset($data);
1433
-			    }
1433
+				}
1434 1434
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1435
-			    $line = explode("\t", $buffer);
1436
-			    for($k = 0; $k < count($line); $k=$k+2) {
1435
+				$line = explode("\t", $buffer);
1436
+				for($k = 0; $k < count($line); $k=$k+2) {
1437 1437
 				$key = $line[$k];
1438
-			        $lined[$key] = $line[$k+1];
1439
-			    }
1440
-    			    if (count($lined) > 3) {
1441
-    				$data['hex'] = $lined['hexid'];
1442
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1443
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1444
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1445
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1446
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1447
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1448
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1449
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1450
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1451
-    				$data['id_source'] = $id_source;
1452
-    				$data['format_source'] = 'tsv';
1453
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1454
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1438
+					$lined[$key] = $line[$k+1];
1439
+				}
1440
+					if (count($lined) > 3) {
1441
+					$data['hex'] = $lined['hexid'];
1442
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1443
+					$data['datetime'] = date('Y-m-d H:i:s');;
1444
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1445
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1446
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1447
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1448
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1449
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1450
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1451
+					$data['id_source'] = $id_source;
1452
+					$data['format_source'] = 'tsv';
1453
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1454
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1455 1455
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1456
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1457
-    				unset($lined);
1458
-    				unset($data);
1459
-    			    } else $error = true;
1456
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1457
+					unset($lined);
1458
+					unset($data);
1459
+					} else $error = true;
1460 1460
 			} elseif ($format == 'aprs' && $use_aprs) {
1461
-			    if ($aprs_connect == 0) {
1461
+				if ($aprs_connect == 0) {
1462 1462
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1463 1463
 				$aprs_connect = 1;
1464
-			    }
1464
+				}
1465 1465
 			    
1466
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1466
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1467 1467
 				$aprs_last_tx = time();
1468 1468
 				$data_aprs = "# Keep alive";
1469 1469
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1470
-			    }
1470
+				}
1471 1471
 			    
1472
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1473
-			    //echo 'APRS data : '.$buffer."\n";
1474
-			    $buffer = str_replace('APRS <- ','',$buffer);
1475
-			    $buffer = str_replace('APRS -> ','',$buffer);
1476
-			    //echo $buffer."\n";
1477
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1472
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1473
+				//echo 'APRS data : '.$buffer."\n";
1474
+				$buffer = str_replace('APRS <- ','',$buffer);
1475
+				$buffer = str_replace('APRS -> ','',$buffer);
1476
+				//echo $buffer."\n";
1477
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1478 1478
 				$line = $APRS->parse($buffer);
1479 1479
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1480 1480
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1481
-				    $aprs_last_tx = time();
1482
-				    $data = array();
1483
-				    //print_r($line);
1484
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1485
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1486
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1487
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1488
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1489
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1490
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1491
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1492
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1493
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1494
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1495
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1496
-				    $data['latitude'] = $line['latitude'];
1497
-				    $data['longitude'] = $line['longitude'];
1498
-				    //$data['verticalrate'] = $line[16];
1499
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1500
-				    //else $data['speed'] = 0;
1501
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1502
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1503
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1504
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1481
+					$aprs_last_tx = time();
1482
+					$data = array();
1483
+					//print_r($line);
1484
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1485
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1486
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1487
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1488
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1489
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1490
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1491
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1492
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1493
+					else $data['datetime'] = date('Y-m-d H:i:s');
1494
+					//$data['datetime'] = date('Y-m-d H:i:s');
1495
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1496
+					$data['latitude'] = $line['latitude'];
1497
+					$data['longitude'] = $line['longitude'];
1498
+					//$data['verticalrate'] = $line[16];
1499
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1500
+					//else $data['speed'] = 0;
1501
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1502
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1503
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1504
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1505 1505
 				    
1506
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1507
-				    //else echo 'No heading...'."\n";
1508
-				    //else $data['heading'] = 0;
1509
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1510
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1511
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1512
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1513
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1514
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1515
-    				    $data['id_source'] = $id_source;
1516
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1517
-				    else $data['format_source'] = 'aprs';
1518
-				    $data['source_name'] = $line['source'];
1519
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1520
-				    else $data['source_type'] = 'flarm';
1521
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1522
-				    $currentdate = date('Y-m-d H:i:s');
1523
-				    $aprsdate = strtotime($data['datetime']);
1524
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1525
-				    // Accept data if time <= system time + 20s
1526
-				    //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'])))) {
1527
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1506
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1507
+					//else echo 'No heading...'."\n";
1508
+					//else $data['heading'] = 0;
1509
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1510
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1511
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1512
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1513
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1514
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1515
+						$data['id_source'] = $id_source;
1516
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1517
+					else $data['format_source'] = 'aprs';
1518
+					$data['source_name'] = $line['source'];
1519
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1520
+					else $data['source_type'] = 'flarm';
1521
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1522
+					$currentdate = date('Y-m-d H:i:s');
1523
+					$aprsdate = strtotime($data['datetime']);
1524
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1525
+					// Accept data if time <= system time + 20s
1526
+					//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'])))) {
1527
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1528 1528
 					$send = $SI->add($data);
1529
-				    } elseif ($data['source_type'] == 'ais') {
1529
+					} elseif ($data['source_type'] == 'ais') {
1530 1530
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1531
-				    } elseif (isset($line['stealth'])) {
1531
+					} elseif (isset($line['stealth'])) {
1532 1532
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1533 1533
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1534
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1535
-					    //$line['symbol'] == 'Balloon' ||
1536
-					    $line['symbol'] == 'Glider' || 
1537
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1538
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1539
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1540
-					    $send = $SI->add($data);
1541
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1542
-					    $line['symbol'] == 'Yacht (Sail)' || 
1543
-					    $line['symbol'] == 'Ship (Power Boat)')) {
1544
-					    $send = $MI->add($data);
1545
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1546
-					    $line['symbol'] == 'Car' || 
1547
-					    $line['symbol'] == 'Ambulance' || 
1548
-					    $line['symbol'] == 'Van' || 
1549
-					    $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1550
-					    $line['symbol'] == 'Motorcycle' || 
1551
-					    $line['symbol'] == 'Tractor' || 
1552
-					    $line['symbol'] == 'Police' || 
1553
-					    $line['symbol'] == 'Bike' || 
1554
-					    $line['symbol'] == 'Jogger' || 
1555
-					    $line['symbol'] == 'Horse' || 
1556
-					    $line['symbol'] == 'Bus' || 
1557
-					    $line['symbol'] == 'Jeep' || 
1558
-					    $line['symbol'] == 'Recreational Vehicle' || 
1559
-					    $line['symbol'] == 'Yacht (Sail)' || 
1560
-					    $line['symbol'] == 'Ship (Power Boat)' || 
1561
-					    $line['symbol'] == 'Firetruck' || 
1562
-					    $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1563
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1564
-					    $line['symbol'] == 'SUV' ||
1565
-					    $line['symbol'] == 'Snowmobile' ||
1566
-					    $line['symbol'] == 'Mobile Satellite Station')) {
1567
-				    //} 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') {
1534
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1535
+						//$line['symbol'] == 'Balloon' ||
1536
+						$line['symbol'] == 'Glider' || 
1537
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1538
+						if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1539
+						if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1540
+						$send = $SI->add($data);
1541
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1542
+						$line['symbol'] == 'Yacht (Sail)' || 
1543
+						$line['symbol'] == 'Ship (Power Boat)')) {
1544
+						$send = $MI->add($data);
1545
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1546
+						$line['symbol'] == 'Car' || 
1547
+						$line['symbol'] == 'Ambulance' || 
1548
+						$line['symbol'] == 'Van' || 
1549
+						$line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1550
+						$line['symbol'] == 'Motorcycle' || 
1551
+						$line['symbol'] == 'Tractor' || 
1552
+						$line['symbol'] == 'Police' || 
1553
+						$line['symbol'] == 'Bike' || 
1554
+						$line['symbol'] == 'Jogger' || 
1555
+						$line['symbol'] == 'Horse' || 
1556
+						$line['symbol'] == 'Bus' || 
1557
+						$line['symbol'] == 'Jeep' || 
1558
+						$line['symbol'] == 'Recreational Vehicle' || 
1559
+						$line['symbol'] == 'Yacht (Sail)' || 
1560
+						$line['symbol'] == 'Ship (Power Boat)' || 
1561
+						$line['symbol'] == 'Firetruck' || 
1562
+						$line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1563
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1564
+						$line['symbol'] == 'SUV' ||
1565
+						$line['symbol'] == 'Snowmobile' ||
1566
+						$line['symbol'] == 'Mobile Satellite Station')) {
1567
+					//} 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') {
1568 1568
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $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') {
1569 1569
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1570 1570
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1571
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1571
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1572 1572
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1573 1573
 					$Source->deleteOldLocationByType('gs');
1574 1574
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1576,7 +1576,7 @@  discard block
 block discarded – undo
1576 1576
 					} else {
1577 1577
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1578 1578
 					}
1579
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1579
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1580 1580
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1581 1581
 					if ($globalDebug) echo '# Weather Station added'."\n";
1582 1582
 					$Source->deleteOldLocationByType('wx');
@@ -1586,7 +1586,7 @@  discard block
 block discarded – undo
1586 1586
 					} else {
1587 1587
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1588 1588
 					}
1589
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1589
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1590 1590
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1591 1591
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1592 1592
 					$Source->deleteOldLocationByType('lightning');
@@ -1595,11 +1595,11 @@  discard block
 block discarded – undo
1595 1595
 					} else {
1596 1596
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1597 1597
 					}
1598
-				    } elseif ($globalDebug) {
1599
-				    	echo '/!\ Not added: '.$buffer."\n";
1600
-				    	print_r($line);
1601
-				    }
1602
-				    unset($data);
1598
+					} elseif ($globalDebug) {
1599
+						echo '/!\ Not added: '.$buffer."\n";
1600
+						print_r($line);
1601
+					}
1602
+					unset($data);
1603 1603
 				}
1604 1604
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1605 1605
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1618,12 +1618,12 @@  discard block
 block discarded – undo
1618 1618
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1619 1619
 					$globalSources[$nb]['last_weather_clean'] = time();
1620 1620
 				}
1621
-			    }
1621
+				}
1622 1622
 			} else {
1623
-			    $line = explode(',', $buffer);
1624
-    			    if (count($line) > 20) {
1625
-    			    	$data['hex'] = $line[4];
1626
-    				/*
1623
+				$line = explode(',', $buffer);
1624
+					if (count($line) > 20) {
1625
+						$data['hex'] = $line[4];
1626
+					/*
1627 1627
     				$data['datetime'] = $line[6].' '.$line[7];
1628 1628
     					date_default_timezone_set($globalTimezone);
1629 1629
     					$datetime = new DateTime($data['datetime']);
@@ -1631,30 +1631,30 @@  discard block
 block discarded – undo
1631 1631
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1632 1632
     					date_default_timezone_set('UTC');
1633 1633
     				*/
1634
-    				// Force datetime to current UTC datetime
1635
-    				date_default_timezone_set('UTC');
1636
-    				$data['datetime'] = date('Y-m-d H:i:s');
1637
-    				$data['ident'] = trim($line[10]);
1638
-    				$data['latitude'] = $line[14];
1639
-    				$data['longitude'] = $line[15];
1640
-    				$data['verticalrate'] = $line[16];
1641
-    				$data['emergency'] = $line[20];
1642
-    				$data['speed'] = $line[12];
1643
-    				$data['squawk'] = $line[17];
1644
-    				$data['altitude'] = $line[11];
1645
-    				$data['heading'] = $line[13];
1646
-    				$data['ground'] = $line[21];
1647
-    				$data['emergency'] = $line[19];
1648
-    				$data['format_source'] = 'sbs';
1634
+					// Force datetime to current UTC datetime
1635
+					date_default_timezone_set('UTC');
1636
+					$data['datetime'] = date('Y-m-d H:i:s');
1637
+					$data['ident'] = trim($line[10]);
1638
+					$data['latitude'] = $line[14];
1639
+					$data['longitude'] = $line[15];
1640
+					$data['verticalrate'] = $line[16];
1641
+					$data['emergency'] = $line[20];
1642
+					$data['speed'] = $line[12];
1643
+					$data['squawk'] = $line[17];
1644
+					$data['altitude'] = $line[11];
1645
+					$data['heading'] = $line[13];
1646
+					$data['ground'] = $line[21];
1647
+					$data['emergency'] = $line[19];
1648
+					$data['format_source'] = 'sbs';
1649 1649
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1650
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1650
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1651 1651
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1652
-    				$data['id_source'] = $id_source;
1653
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1654
-    				else $error = true;
1655
-    				unset($data);
1656
-    			    } else $error = true;
1657
-			    if ($error) {
1652
+					$data['id_source'] = $id_source;
1653
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1654
+					else $error = true;
1655
+					unset($data);
1656
+					} else $error = true;
1657
+				if ($error) {
1658 1658
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1659 1659
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1660 1660
 				} else {
@@ -1670,13 +1670,13 @@  discard block
 block discarded – undo
1670 1670
 					connect_all($sourceer);
1671 1671
 					$sourceer = array();
1672 1672
 				}
1673
-			    }
1673
+				}
1674 1674
 			}
1675 1675
 			// Sleep for xxx microseconds
1676 1676
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1677
-		    } else {
1677
+			} else {
1678 1678
 			if ($format == 'flightgearmp') {
1679
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1679
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1680 1680
 				//@socket_close($r);
1681 1681
 				sleep($globalMinFetch);
1682 1682
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1685,9 +1685,9 @@  discard block
 block discarded – undo
1685 1685
 				break;
1686 1686
 				
1687 1687
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1688
-			    if (isset($tt[$format])) $tt[$format]++;
1689
-			    else $tt[$format] = 0;
1690
-			    if ($tt[$format] > 30) {
1688
+				if (isset($tt[$format])) $tt[$format]++;
1689
+				else $tt[$format] = 0;
1690
+				if ($tt[$format] > 30) {
1691 1691
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1692 1692
 				//@socket_close($r);
1693 1693
 				sleep(2);
@@ -1698,23 +1698,23 @@  discard block
 block discarded – undo
1698 1698
 				//connect_all($globalSources);
1699 1699
 				$tt[$format]=0;
1700 1700
 				break;
1701
-			    }
1701
+				}
1702
+			}
1702 1703
 			}
1703
-		    }
1704 1704
 		}
1705
-	    } else {
1705
+		} else {
1706 1706
 		$error = socket_strerror(socket_last_error());
1707 1707
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1708 1708
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1709 1709
 			if (isset($globalDebug)) echo "Restarting...\n";
1710 1710
 			// Restart the script if possible
1711 1711
 			if (is_array($sockets)) {
1712
-			    if ($globalDebug) echo "Shutdown all sockets...";
1712
+				if ($globalDebug) echo "Shutdown all sockets...";
1713 1713
 			    
1714
-			    foreach ($sockets as $sock) {
1714
+				foreach ($sockets as $sock) {
1715 1715
 				@socket_shutdown($sock,2);
1716 1716
 				@socket_close($sock);
1717
-			    }
1717
+				}
1718 1718
 			    
1719 1719
 			}
1720 1720
 			if ($globalDebug) echo "Waiting...";
@@ -1729,15 +1729,15 @@  discard block
 block discarded – undo
1729 1729
 			if ($globalDebug) echo "Restart all connections...";
1730 1730
 			connect_all($globalSources);
1731 1731
 		}
1732
-	    }
1732
+		}
1733 1733
 	}
1734 1734
 	if ($globalDaemon === false) {
1735
-	    if ($globalDebug) echo 'Check all...'."\n";
1736
-	    if (isset($SI)) $SI->checkAll();
1737
-	    if (isset($TI)) $TI->checkAll();
1738
-	    if (isset($MI)) $MI->checkAll();
1735
+		if ($globalDebug) echo 'Check all...'."\n";
1736
+		if (isset($SI)) $SI->checkAll();
1737
+		if (isset($TI)) $TI->checkAll();
1738
+		if (isset($MI)) $MI->checkAll();
1739
+	}
1739 1740
 	}
1740
-    }
1741 1741
 }
1742 1742
 
1743 1743
 ?>
Please login to merge, or discard this patch.