Completed
Push — master ( cef8a5...e336e8 )
by Yannick
70:10 queued 43:44
created
scripts/daemon-spotter.php 1 patch
Indentation   +1059 added lines, -1059 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','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
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;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 if (isset($options['idsource'])) $id_source = $options['idsource'];
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
106
+	if ($globalDebug) echo "Using Server Mode\n";
107
+	$SI=new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
117
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
117
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 119
 }
120 120
 
121 121
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
122 122
 if (isset($globalMarine) && $globalMarine) {
123
-    $AIS = new AIS();
124
-    $MI = new MarineImport($Connection->db);
123
+	$AIS = new AIS();
124
+	$MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127 127
 $SBS=new SBS();
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
138
-        global $sockets;
139
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
-        die("Bye!\n");
141
-    });
142
-    pcntl_signal_dispatch();
137
+	pcntl_signal(SIGINT,  function() {
138
+		global $sockets;
139
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
+		die("Bye!\n");
141
+	});
142
+	pcntl_signal_dispatch();
143 143
 }
144 144
 
145 145
 // let's try and connect
@@ -149,41 +149,41 @@  discard block
 block discarded – undo
149 149
 $reset = 0;
150 150
 
151 151
 function connect_all($hosts) {
152
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
-    $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
156
-    foreach ($hosts as $id => $value) {
152
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
+	$reset++;
155
+	if ($globalDebug) echo 'Connect to all...'."\n";
156
+	foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160 160
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
162
-        	//$formats[$id] = 'deltadbtxt';
163
-        	$globalSources[$id]['format'] = 'deltadbtxt';
164
-        	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
-        	//$formats[$id] = 'vatsimtxt';
168
-        	$globalSources[$id]['format'] = 'vatsimtxt';
169
-        	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172
-        	//$formats[$id] = 'aircraftlistjson';
173
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
174
-        	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
177
-        	//$formats[$id] = 'aircraftjson';
178
-        	$globalSources[$id]['format'] = 'aircraftjson';
179
-        	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
181
-    	    } else if (preg_match('/opensky/i',$host)) {
182
-        	//$formats[$id] = 'aircraftlistjson';
183
-        	$globalSources[$id]['format'] = 'opensky';
184
-        	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
186
-    	    /*
161
+			if (preg_match('/deltadb.txt$/i',$host)) {
162
+			//$formats[$id] = 'deltadbtxt';
163
+			$globalSources[$id]['format'] = 'deltadbtxt';
164
+			//$last_exec['deltadbtxt'] = 0;
165
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
+			//$formats[$id] = 'vatsimtxt';
168
+			$globalSources[$id]['format'] = 'vatsimtxt';
169
+			//$last_exec['vatsimtxt'] = 0;
170
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
172
+			//$formats[$id] = 'aircraftlistjson';
173
+			$globalSources[$id]['format'] = 'aircraftlistjson';
174
+			//$last_exec['aircraftlistjson'] = 0;
175
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
+			} else if (preg_match('/aircraft.json$/i',$host)) {
177
+			//$formats[$id] = 'aircraftjson';
178
+			$globalSources[$id]['format'] = 'aircraftjson';
179
+			//$last_exec['aircraftlistjson'] = 0;
180
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
181
+			} else if (preg_match('/opensky/i',$host)) {
182
+			//$formats[$id] = 'aircraftlistjson';
183
+			$globalSources[$id]['format'] = 'opensky';
184
+			//$last_exec['aircraftlistjson'] = 0;
185
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
186
+			/*
187 187
     	    // Disabled for now, site change source format
188 188
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
189 189
         	//$formats[$id] = 'radarvirtueljson';
@@ -195,127 +195,127 @@  discard block
 block discarded – undo
195 195
         	    exit(0);
196 196
         	}
197 197
     	    */
198
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
199
-        	//$formats[$id] = 'planeupdatefaa';
200
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
201
-        	//$last_exec['planeupdatefaa'] = 0;
202
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
203
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
204
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
205
-        	    exit(0);
206
-        	}
207
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
208
-        	//$formats[$id] = 'phpvmacars';
209
-        	$globalSources[$id]['format'] = 'phpvmacars';
210
-        	//$last_exec['phpvmacars'] = 0;
211
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
212
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
213
-        	//$formats[$id] = 'phpvmacars';
214
-        	$globalSources[$id]['format'] = 'vaos';
215
-        	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
217
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
218
-        	//$formats[$id] = 'phpvmacars';
219
-        	$globalSources[$id]['format'] = 'vam';
220
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
221
-            } else if (preg_match('/whazzup/i',$host)) {
222
-        	//$formats[$id] = 'whazzup';
223
-        	$globalSources[$id]['format'] = 'whazzup';
224
-        	//$last_exec['whazzup'] = 0;
225
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
226
-            } else if (preg_match('/blitzortung/i',$host)) {
227
-        	$globalSources[$id]['format'] = 'blitzortung';
228
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
229
-            } else if (preg_match('/airwhere/i',$host)) {
230
-        	$globalSources[$id]['format'] = 'airwhere';
231
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
232
-            } else if (preg_match('/recentpireps/i',$host)) {
233
-        	//$formats[$id] = 'pirepsjson';
234
-        	$globalSources[$id]['format'] = 'pirepsjson';
235
-        	//$last_exec['pirepsjson'] = 0;
236
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
237
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
238
-        	//$formats[$id] = 'fr24json';
239
-        	$globalSources[$id]['format'] = 'fr24json';
240
-        	//$last_exec['fr24json'] = 0;
241
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
242
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
243
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
244
-        	    exit(0);
245
-        	}
246
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
247
-        	//$formats[$id] = 'fr24json';
248
-        	$globalSources[$id]['format'] = 'myshiptracking';
249
-        	//$last_exec['fr24json'] = 0;
250
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
251
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
252
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
253
-        	    exit(0);
254
-        	}
255
-            //} else if (preg_match('/10001/',$host)) {
256
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
257
-        	//$formats[$id] = 'tsv';
258
-        	$globalSources[$id]['format'] = 'tsv';
259
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
260
-            }
261
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
262
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
263
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
264
-    		    if ($idf !== false) {
265
-    			$httpfeeds[$id] = $idf;
266
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
267
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
268
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
269
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
270
-	    $hostport = explode(':',$host);
271
-	    if (isset($hostport[1])) {
198
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
199
+			//$formats[$id] = 'planeupdatefaa';
200
+			$globalSources[$id]['format'] = 'planeupdatefaa';
201
+			//$last_exec['planeupdatefaa'] = 0;
202
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
203
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
204
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
205
+				exit(0);
206
+			}
207
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
208
+			//$formats[$id] = 'phpvmacars';
209
+			$globalSources[$id]['format'] = 'phpvmacars';
210
+			//$last_exec['phpvmacars'] = 0;
211
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
212
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
213
+			//$formats[$id] = 'phpvmacars';
214
+			$globalSources[$id]['format'] = 'vaos';
215
+			//$last_exec['phpvmacars'] = 0;
216
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
217
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
218
+			//$formats[$id] = 'phpvmacars';
219
+			$globalSources[$id]['format'] = 'vam';
220
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
221
+			} else if (preg_match('/whazzup/i',$host)) {
222
+			//$formats[$id] = 'whazzup';
223
+			$globalSources[$id]['format'] = 'whazzup';
224
+			//$last_exec['whazzup'] = 0;
225
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
226
+			} else if (preg_match('/blitzortung/i',$host)) {
227
+			$globalSources[$id]['format'] = 'blitzortung';
228
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
229
+			} else if (preg_match('/airwhere/i',$host)) {
230
+			$globalSources[$id]['format'] = 'airwhere';
231
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
232
+			} else if (preg_match('/recentpireps/i',$host)) {
233
+			//$formats[$id] = 'pirepsjson';
234
+			$globalSources[$id]['format'] = 'pirepsjson';
235
+			//$last_exec['pirepsjson'] = 0;
236
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
237
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
238
+			//$formats[$id] = 'fr24json';
239
+			$globalSources[$id]['format'] = 'fr24json';
240
+			//$last_exec['fr24json'] = 0;
241
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
242
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
243
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
244
+				exit(0);
245
+			}
246
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
247
+			//$formats[$id] = 'fr24json';
248
+			$globalSources[$id]['format'] = 'myshiptracking';
249
+			//$last_exec['fr24json'] = 0;
250
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
251
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
252
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
253
+				exit(0);
254
+			}
255
+			//} else if (preg_match('/10001/',$host)) {
256
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
257
+			//$formats[$id] = 'tsv';
258
+			$globalSources[$id]['format'] = 'tsv';
259
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
260
+			}
261
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
262
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
263
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
264
+				if ($idf !== false) {
265
+				$httpfeeds[$id] = $idf;
266
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
267
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
268
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
269
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
270
+		$hostport = explode(':',$host);
271
+		if (isset($hostport[1])) {
272 272
 		$port = $hostport[1];
273 273
 		$hostn = $hostport[0];
274
-	    } else {
274
+		} else {
275 275
 		$port = $globalSources[$id]['port'];
276 276
 		$hostn = $globalSources[$id]['host'];
277
-	    }
278
-	    $Common = new Common();
279
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
280
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
281
-    	    } else {
282
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
283
-	    }
284
-	    if ($s) {
285
-    	        $sockets[$id] = $s;
286
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
287
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
277
+		}
278
+		$Common = new Common();
279
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
280
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
281
+			} else {
282
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
283
+		}
284
+		if ($s) {
285
+				$sockets[$id] = $s;
286
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
287
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
288 288
 			//$formats[$id] = 'aprs';
289 289
 			$globalSources[$id]['format'] = 'aprs';
290 290
 			//$aprs_connect = 0;
291 291
 			//$use_aprs = true;
292
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
292
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
293 293
 			$globalSources[$id]['format'] = 'vrstcp';
294
-    		    } elseif ($port == '10001') {
295
-        		//$formats[$id] = 'tsv';
296
-        		$globalSources[$id]['format'] = 'tsv';
297
-		    } elseif ($port == '30002') {
298
-        		//$formats[$id] = 'raw';
299
-        		$globalSources[$id]['format'] = 'raw';
300
-		    } elseif ($port == '5001') {
301
-        		//$formats[$id] = 'raw';
302
-        		$globalSources[$id]['format'] = 'flightgearmp';
303
-		    } elseif ($port == '30005') {
294
+				} elseif ($port == '10001') {
295
+				//$formats[$id] = 'tsv';
296
+				$globalSources[$id]['format'] = 'tsv';
297
+			} elseif ($port == '30002') {
298
+				//$formats[$id] = 'raw';
299
+				$globalSources[$id]['format'] = 'raw';
300
+			} elseif ($port == '5001') {
301
+				//$formats[$id] = 'raw';
302
+				$globalSources[$id]['format'] = 'flightgearmp';
303
+			} elseif ($port == '30005') {
304 304
 			// Not yet supported
305
-        		//$formats[$id] = 'beast';
306
-        		$globalSources[$id]['format'] = 'beast';
307
-		    //} else $formats[$id] = 'sbs';
308
-		    } else $globalSources[$id]['format'] = 'sbs';
309
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
305
+				//$formats[$id] = 'beast';
306
+				$globalSources[$id]['format'] = 'beast';
307
+			//} else $formats[$id] = 'sbs';
308
+			} else $globalSources[$id]['format'] = 'sbs';
309
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
310 310
 		}
311 311
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
312
-            } else {
312
+			} else {
313 313
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
314 314
 		sleep(10);
315 315
 		$this->connect_all($hosts);
316
-    	    }
317
-        }
318
-    }
316
+			}
317
+		}
318
+	}
319 319
 }
320 320
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
321 321
 
@@ -338,9 +338,9 @@  discard block
 block discarded – undo
338 338
 //connect_all($globalSources);
339 339
 
340 340
 if (isset($globalProxy) && $globalProxy) {
341
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
341
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
342 342
 } else {
343
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
343
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
344 344
 }
345 345
 
346 346
 // APRS Configuration
@@ -349,21 +349,21 @@  discard block
 block discarded – undo
349 349
 	die;
350 350
 }
351 351
 foreach ($globalSources as $key => $source) {
352
-    if (!isset($source['format'])) {
353
-        $globalSources[$key]['format'] = 'auto';
354
-    }
355
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
356
-        unset($globalSources[$key]);
357
-    }
352
+	if (!isset($source['format'])) {
353
+		$globalSources[$key]['format'] = 'auto';
354
+	}
355
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
356
+		unset($globalSources[$key]);
357
+	}
358 358
 }
359 359
 connect_all($globalSources);
360 360
 foreach ($globalSources as $key => $source) {
361
-    if (isset($source['format']) && $source['format'] == 'aprs') {
361
+	if (isset($source['format']) && $source['format'] == 'aprs') {
362 362
 	$aprs_connect = 0;
363 363
 	$use_aprs = true;
364 364
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
365 365
 	break;
366
-    }
366
+	}
367 367
 }
368 368
 
369 369
 if ($use_aprs) {
@@ -404,133 +404,133 @@  discard block
 block discarded – undo
404 404
 
405 405
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
406 406
 while ($i > 0) {
407
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
407
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
408 408
 
409
-    if (!$globalDaemon) $i = $endtime-time();
410
-    // Delete old ATC
411
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
409
+	if (!$globalDaemon) $i = $endtime-time();
410
+	// Delete old ATC
411
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
412 412
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
413
-        $ATC->deleteOldATC();
414
-    }
413
+		$ATC->deleteOldATC();
414
+	}
415 415
     
416
-    if (count($last_exec) == count($globalSources)) {
416
+	if (count($last_exec) == count($globalSources)) {
417 417
 	$max = $globalMinFetch;
418 418
 	foreach ($last_exec as $last) {
419
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
419
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
420 420
 	}
421 421
 	if ($max < $globalMinFetch) {
422
-	    if ($globalDebug) echo 'Sleeping...'."\n";
423
-	    sleep($globalMinFetch-$max+2);
422
+		if ($globalDebug) echo 'Sleeping...'."\n";
423
+		sleep($globalMinFetch-$max+2);
424
+	}
424 425
 	}
425
-    }
426 426
 
427 427
     
428
-    //foreach ($formats as $id => $value) {
429
-    foreach ($globalSources as $id => $value) {
428
+	//foreach ($formats as $id => $value) {
429
+	foreach ($globalSources as $id => $value) {
430 430
 	date_default_timezone_set('UTC');
431 431
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
432 432
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
433 433
 	if ($value['format'] === 'deltadbtxt' && 
434
-	    (
434
+		(
435 435
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
436 436
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
437
-	    )
437
+		)
438 438
 	) {
439
-	    //$buffer = $Common->getData($hosts[$id]);
440
-	    $buffer = $Common->getData($value['host']);
441
-	    if ($buffer != '') $reset = 0;
442
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
443
-	    $buffer = explode('\n',$buffer);
444
-	    foreach ($buffer as $line) {
445
-    		if ($line != '' && count($line) > 7) {
446
-    		    $line = explode(',', $line);
447
-	            $data = array();
448
-	            $data['hex'] = $line[1]; // hex
449
-	            $data['ident'] = $line[2]; // ident
450
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
451
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
452
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
453
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
454
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
455
-	            $data['verticalrate'] = ''; // vertical rate
456
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
457
-	            $data['emergency'] = ''; // emergency
458
-		    $data['datetime'] = date('Y-m-d H:i:s');
459
-		    $data['format_source'] = 'deltadbtxt';
460
-    		    $data['id_source'] = $id_source;
461
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
462
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
463
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
464
-    		    $SI->add($data);
465
-		    unset($data);
466
-    		}
467
-    	    }
468
-    	    $last_exec[$id]['last'] = time();
439
+		//$buffer = $Common->getData($hosts[$id]);
440
+		$buffer = $Common->getData($value['host']);
441
+		if ($buffer != '') $reset = 0;
442
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
443
+		$buffer = explode('\n',$buffer);
444
+		foreach ($buffer as $line) {
445
+			if ($line != '' && count($line) > 7) {
446
+				$line = explode(',', $line);
447
+				$data = array();
448
+				$data['hex'] = $line[1]; // hex
449
+				$data['ident'] = $line[2]; // ident
450
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
451
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
452
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
453
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
454
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
455
+				$data['verticalrate'] = ''; // vertical rate
456
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
457
+				$data['emergency'] = ''; // emergency
458
+			$data['datetime'] = date('Y-m-d H:i:s');
459
+			$data['format_source'] = 'deltadbtxt';
460
+				$data['id_source'] = $id_source;
461
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
462
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
463
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
464
+				$SI->add($data);
465
+			unset($data);
466
+			}
467
+			}
468
+			$last_exec[$id]['last'] = time();
469 469
 	} elseif ($value['format'] === 'aisnmeatxt' && 
470
-	    (
470
+		(
471 471
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
472 472
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
473
-	    )
473
+		)
474 474
 	) {
475
-	    date_default_timezone_set('CET');
476
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
477
-	    date_default_timezone_set('UTC');
478
-	    if ($buffer != '') $reset = 0;
479
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
480
-	    $buffer = explode('\n',$buffer);
481
-	    foreach ($buffer as $line) {
475
+		date_default_timezone_set('CET');
476
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
477
+		date_default_timezone_set('UTC');
478
+		if ($buffer != '') $reset = 0;
479
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
480
+		$buffer = explode('\n',$buffer);
481
+		foreach ($buffer as $line) {
482 482
 		if ($line != '') {
483
-		    //echo "'".$line."'\n";
484
-		    $add = false;
485
-		    $ais_data = $AIS->parse_line(trim($line));
486
-		    $data = array();
487
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
488
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
489
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
490
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
491
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
492
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
493
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
494
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
495
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
496
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
497
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
498
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
499
-		    if (isset($ais_data['timestamp'])) {
483
+			//echo "'".$line."'\n";
484
+			$add = false;
485
+			$ais_data = $AIS->parse_line(trim($line));
486
+			$data = array();
487
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
488
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
489
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
490
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
491
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
492
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
493
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
494
+			if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
495
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
496
+			if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
497
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
498
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
499
+			if (isset($ais_data['timestamp'])) {
500 500
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
501 501
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
502
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
503
-			    $add = true;
502
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
503
+				$add = true;
504 504
 			}
505
-		    } else {
505
+			} else {
506 506
 			$data['datetime'] = date('Y-m-d H:i:s');
507 507
 			$add = true;
508
-		    }
509
-		    $data['format_source'] = 'aisnmeatxt';
510
-    		    $data['id_source'] = $id_source;
511
-		    //print_r($data);
512
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
513
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
514
-		    unset($data);
508
+			}
509
+			$data['format_source'] = 'aisnmeatxt';
510
+				$data['id_source'] = $id_source;
511
+			//print_r($data);
512
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
513
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
514
+			unset($data);
515 515
 		}
516
-    	    }
517
-    	    $last_exec[$id]['last'] = time();
516
+			}
517
+			$last_exec[$id]['last'] = time();
518 518
 	} elseif ($value['format'] === 'aisnmeahttp') {
519
-	    $arr = $httpfeeds;
520
-	    $w = $e = null;
519
+		$arr = $httpfeeds;
520
+		$w = $e = null;
521 521
 	    
522
-	    if (isset($arr[$id])) {
522
+		if (isset($arr[$id])) {
523 523
 		$nn = stream_select($arr,$w,$e,$timeout);
524 524
 		if ($nn > 0) {
525
-		    foreach ($httpfeeds as $feed) {
525
+			foreach ($httpfeeds as $feed) {
526 526
 			$buffer = stream_get_line($feed,2000,"\n");
527 527
 			if ($buffer === FALSE) {
528
-			    connect_all($globalSources);
528
+				connect_all($globalSources);
529 529
 			}
530 530
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
531 531
 			$buffer = explode('\n',$buffer);
532 532
 			foreach ($buffer as $line) {
533
-			    if ($line != '') {
533
+				if ($line != '') {
534 534
 				$ais_data = $AIS->parse_line(trim($line));
535 535
 				$data = array();
536 536
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -548,117 +548,117 @@  discard block
 block discarded – undo
548 548
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
549 549
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
550 550
 				if (isset($ais_data['timestamp'])) {
551
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
551
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
552 552
 				} else {
553
-				    $data['datetime'] = date('Y-m-d H:i:s');
553
+					$data['datetime'] = date('Y-m-d H:i:s');
554 554
 				}
555 555
 				$data['format_source'] = 'aisnmeahttp';
556 556
 				$data['id_source'] = $id_source;
557 557
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
558 558
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
559 559
 				unset($data);
560
-			    }
560
+				}
561
+			}
561 562
 			}
562
-		    }
563 563
 		} else {
564
-		    $format = $value['format'];
565
-		    if (isset($tt[$format])) $tt[$format]++;
566
-		    else $tt[$format] = 0;
567
-		    if ($tt[$format] > 30) {
564
+			$format = $value['format'];
565
+			if (isset($tt[$format])) $tt[$format]++;
566
+			else $tt[$format] = 0;
567
+			if ($tt[$format] > 30) {
568 568
 			if ($globalDebug) echo 'Reconnect...'."\n";
569 569
 			sleep(2);
570 570
 			//$sourceeen[] = $value;
571 571
 			//connect_all($sourceeen);
572 572
 			//$sourceeen = array();
573 573
 			connect_all($globalSources);
574
-		    }
574
+			}
575
+		}
575 576
 		}
576
-	    }
577 577
 	} elseif ($value['format'] === 'myshiptracking' && 
578
-	    (
578
+		(
579 579
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
580 580
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
581
-	    )
581
+		)
582 582
 	) {
583
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
584
-	    if ($buffer != '') {
583
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
584
+		if ($buffer != '') {
585 585
 		//echo $buffer;
586 586
 		$all_data = json_decode($buffer,true);
587 587
 		//print_r($all_data);
588 588
 		if (isset($all_data[0]['DATA'])) {
589
-		    foreach ($all_data[0]['DATA'] as $line) {
589
+			foreach ($all_data[0]['DATA'] as $line) {
590 590
 			if ($line != '') {
591
-			    $data = array();
592
-			    $data['ident'] = $line['NAME'];
593
-			    $data['mmsi'] = $line['MMSI'];
594
-			    if (strlen($data['mmsi']) > 9) {
591
+				$data = array();
592
+				$data['ident'] = $line['NAME'];
593
+				$data['mmsi'] = $line['MMSI'];
594
+				if (strlen($data['mmsi']) > 9) {
595 595
 				$data['mmsi'] = substr($data['mmsi'],-9);
596
-			    }
597
-			    $data['speed'] = $line['SOG'];
598
-			    $data['heading'] = $line['COG'];
599
-			    $data['latitude'] = $line['LAT'];
600
-			    $data['longitude'] = $line['LNG'];
601
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
602
-			    //$data['type_id'] = $line['TYPE'];
603
-			    $data['imo'] = $line['IMO'];
604
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
605
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
606
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
607
-			    $data['format_source'] = 'myshiptracking';
608
-			    $data['id_source'] = $id_source;
609
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
610
-			    $MI->add($data);
611
-			    unset($data);
596
+				}
597
+				$data['speed'] = $line['SOG'];
598
+				$data['heading'] = $line['COG'];
599
+				$data['latitude'] = $line['LAT'];
600
+				$data['longitude'] = $line['LNG'];
601
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
602
+				//$data['type_id'] = $line['TYPE'];
603
+				$data['imo'] = $line['IMO'];
604
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
605
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
606
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
607
+				$data['format_source'] = 'myshiptracking';
608
+				$data['id_source'] = $id_source;
609
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
610
+				$MI->add($data);
611
+				unset($data);
612 612
 			}
613
-		    }
613
+			}
614
+		}
614 615
 		}
615
-	    }
616
-	    $last_exec[$id]['last'] = time();
616
+		$last_exec[$id]['last'] = time();
617 617
 	} elseif ($value['format'] === 'boatbeaconapp' && 
618
-	    (
618
+		(
619 619
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
620 620
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
621
-	    )
621
+		)
622 622
 	) {
623
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
624
-	    if ($buffer != '') {
623
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
624
+		if ($buffer != '') {
625 625
 		$all_data = json_decode($buffer,true);
626 626
 		if (isset($all_data[0]['mmsi'])) {
627
-		    foreach ($all_data as $line) {
627
+			foreach ($all_data as $line) {
628 628
 			if ($line != '') {
629
-			    $data = array();
630
-			    $data['ident'] = $line['shipname'];
631
-			    $data['callsign'] = $line['callsign'];
632
-			    $data['mmsi'] = substr($line['mmsi'],-9);
633
-			    $data['speed'] = $line['sog'];
634
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
635
-			    $data['latitude'] = $line['latitude'];
636
-			    $data['longitude'] = $line['longitude'];
637
-			    $data['type_id'] = $line['shiptype'];
638
-			    $data['arrival_code'] = $line['destination'];
639
-			    $data['datetime'] = $line['time'];
640
-			    $data['format_source'] = 'boatbeaconapp';
641
-			    $data['id_source'] = $id_source;
642
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
643
-			    $MI->add($data);
644
-			    unset($data);
629
+				$data = array();
630
+				$data['ident'] = $line['shipname'];
631
+				$data['callsign'] = $line['callsign'];
632
+				$data['mmsi'] = substr($line['mmsi'],-9);
633
+				$data['speed'] = $line['sog'];
634
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
635
+				$data['latitude'] = $line['latitude'];
636
+				$data['longitude'] = $line['longitude'];
637
+				$data['type_id'] = $line['shiptype'];
638
+				$data['arrival_code'] = $line['destination'];
639
+				$data['datetime'] = $line['time'];
640
+				$data['format_source'] = 'boatbeaconapp';
641
+				$data['id_source'] = $id_source;
642
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
643
+				$MI->add($data);
644
+				unset($data);
645
+			}
645 646
 			}
646
-		    }
647 647
 		}
648 648
 		
649
-	    }
650
-    	    $last_exec[$id]['last'] = time();
649
+		}
650
+			$last_exec[$id]['last'] = time();
651 651
 	} elseif ($value['format'] === 'boatnerd' && 
652
-	    (
652
+		(
653 653
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
654 654
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
655
-	    )
655
+		)
656 656
 	) {
657
-	    $buffer = $Common->getData($value['host']);
658
-	    if ($buffer != '') {
657
+		$buffer = $Common->getData($value['host']);
658
+		if ($buffer != '') {
659 659
 		$all_data = json_decode($buffer,true);
660 660
 		if (isset($all_data['features'][0]['id'])) {
661
-		    foreach ($all_data['features'] as $line) {
661
+			foreach ($all_data['features'] as $line) {
662 662
 			print_r($line);
663 663
 			$data = array();
664 664
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -678,80 +678,80 @@  discard block
 block discarded – undo
678 678
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
679 679
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
680 680
 			unset($data);
681
-		    }
681
+			}
682 682
 		}
683 683
 		
684
-	    }
685
-    	    $last_exec[$id]['last'] = time();
684
+		}
685
+			$last_exec[$id]['last'] = time();
686 686
 	} elseif ($value['format'] === 'shipplotter' && 
687
-	    (
687
+		(
688 688
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
689 689
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
690
-	    )
690
+		)
691 691
 	) {
692
-	    echo 'download...';
693
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
694
-	    echo 'done !'."\n";
695
-	    // FIXME: Need more work
696
-	    if ($buffer != '') $reset = 0;
697
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
698
-	    $buffer = explode('\n',$buffer);
699
-	    foreach ($buffer as $line) {
692
+		echo 'download...';
693
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
694
+		echo 'done !'."\n";
695
+		// FIXME: Need more work
696
+		if ($buffer != '') $reset = 0;
697
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
698
+		$buffer = explode('\n',$buffer);
699
+		foreach ($buffer as $line) {
700 700
 		if ($line != '') {
701
-		    $data = array();
702
-		    echo $line."\n";
703
-		    $data['mmsi'] = (int)substr($line,0,9);
704
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
705
-		    $data['status_id'] = substr($line,21,2);
706
-		    $data['type_id'] = substr($line,24,3);
707
-		    $data['latitude'] = substr($line,29,9);
708
-		    $data['longitude'] = substr($line,41,9);
709
-		    $data['speed'] = round(substr($line,51,5));
710
-		    //$data['course'] = substr($line,57,5);
711
-		    $data['heading'] = round(substr($line,63,3));
712
-		    //$data['draft'] = substr($line,67,4);
713
-		    //$data['length'] = substr($line,72,3);
714
-		    //$data['beam'] = substr($line,76,2);
715
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
716
-		    //$data['callsign'] = trim(substr($line,100,7);
717
-		    $data['arrival_code'] = substr($line,108,20);
718
-		    //$data['etaDate'] = substr($line,129,5);
719
-		    //$data['etaTime'] = substr($line,135,5);
720
-		    $data['format_source'] = 'shipplotter';
721
-    		    $data['id_source'] = $id_source;
722
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
723
-		    //print_r($data);
724
-		    echo 'Add...'."\n";
725
-		    $MI->add($data);
726
-		    unset($data);
701
+			$data = array();
702
+			echo $line."\n";
703
+			$data['mmsi'] = (int)substr($line,0,9);
704
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
705
+			$data['status_id'] = substr($line,21,2);
706
+			$data['type_id'] = substr($line,24,3);
707
+			$data['latitude'] = substr($line,29,9);
708
+			$data['longitude'] = substr($line,41,9);
709
+			$data['speed'] = round(substr($line,51,5));
710
+			//$data['course'] = substr($line,57,5);
711
+			$data['heading'] = round(substr($line,63,3));
712
+			//$data['draft'] = substr($line,67,4);
713
+			//$data['length'] = substr($line,72,3);
714
+			//$data['beam'] = substr($line,76,2);
715
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
716
+			//$data['callsign'] = trim(substr($line,100,7);
717
+			$data['arrival_code'] = substr($line,108,20);
718
+			//$data['etaDate'] = substr($line,129,5);
719
+			//$data['etaTime'] = substr($line,135,5);
720
+			$data['format_source'] = 'shipplotter';
721
+				$data['id_source'] = $id_source;
722
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
723
+			//print_r($data);
724
+			echo 'Add...'."\n";
725
+			$MI->add($data);
726
+			unset($data);
727 727
 		}
728
-    	    }
729
-    	    $last_exec[$id]['last'] = time();
728
+			}
729
+			$last_exec[$id]['last'] = time();
730 730
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
731 731
 	} elseif (
732
-	    (
732
+		(
733 733
 		$value['format'] === 'whazzup' && 
734 734
 		(
735
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
736
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
735
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
736
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
737 737
 		)
738
-	    ) || (
738
+		) || (
739 739
 		$value['format'] === 'vatsimtxt' && 
740 740
 		(
741
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
742
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
741
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
742
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
743
+		)
743 744
 		)
744
-	    )
745 745
 	) {
746
-	    //$buffer = $Common->getData($hosts[$id]);
747
-	    $buffer = $Common->getData($value['host']);
748
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
749
-	    $buffer = explode('\n',$buffer);
750
-	    $reset = 0;
751
-	    foreach ($buffer as $line) {
752
-    		if ($line != '') {
753
-    		    $line = explode(':', $line);
754
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
746
+		//$buffer = $Common->getData($hosts[$id]);
747
+		$buffer = $Common->getData($value['host']);
748
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
749
+		$buffer = explode('\n',$buffer);
750
+		$reset = 0;
751
+		foreach ($buffer as $line) {
752
+			if ($line != '') {
753
+				$line = explode(':', $line);
754
+				if (count($line) > 30 && $line[0] != 'callsign') {
755 755
 			$data = array();
756 756
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
757 757
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -764,37 +764,37 @@  discard block
 block discarded – undo
764 764
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
765 765
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
766 766
 			$data['latitude'] = $line[5]; // lat
767
-	        	$data['longitude'] = $line[6]; // long
768
-	        	$data['verticalrate'] = ''; // vertical rate
769
-	        	$data['squawk'] = ''; // squawk
770
-	        	$data['emergency'] = ''; // emergency
771
-	        	$data['waypoints'] = $line[30];
767
+				$data['longitude'] = $line[6]; // long
768
+				$data['verticalrate'] = ''; // vertical rate
769
+				$data['squawk'] = ''; // squawk
770
+				$data['emergency'] = ''; // emergency
771
+				$data['waypoints'] = $line[30];
772 772
 			$data['datetime'] = date('Y-m-d H:i:s');
773 773
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
774 774
 			//if (isset($line[37])) $data['last_update'] = $line[37];
775
-		        $data['departure_airport_icao'] = $line[11];
776
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
777
-		        $data['arrival_airport_icao'] = $line[13];
775
+				$data['departure_airport_icao'] = $line[11];
776
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
777
+				$data['arrival_airport_icao'] = $line[13];
778 778
 			$data['frequency'] = $line[4];
779 779
 			$data['type'] = $line[18];
780 780
 			$data['range'] = $line[19];
781 781
 			if (isset($line[35])) $data['info'] = $line[35];
782
-    			$data['id_source'] = $id_source;
783
-	    		//$data['arrival_airport_time'] = ;
784
-	    		if ($line[9] != '') {
785
-	    		    $aircraft_data = explode('/',$line[9]);
786
-	    		    if (isset($aircraft_data[1])) {
787
-	    			$data['aircraft_icao'] = $aircraft_data[1];
788
-	    		    }
789
-        		}
790
-	    		/*
782
+				$data['id_source'] = $id_source;
783
+				//$data['arrival_airport_time'] = ;
784
+				if ($line[9] != '') {
785
+					$aircraft_data = explode('/',$line[9]);
786
+					if (isset($aircraft_data[1])) {
787
+					$data['aircraft_icao'] = $aircraft_data[1];
788
+					}
789
+				}
790
+				/*
791 791
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
792 792
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
793 793
 	    		*/
794
-	    		$data['format_source'] = $value['format'];
794
+				$data['format_source'] = $value['format'];
795 795
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
796 796
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
797
-    			if ($line[3] === 'PILOT') $SI->add($data);
797
+				if ($line[3] === 'PILOT') $SI->add($data);
798 798
 			elseif ($line[3] === 'ATC') {
799 799
 				//print_r($data);
800 800
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -815,21 +815,21 @@  discard block
 block discarded – undo
815 815
 					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']);
816 816
 				}
817 817
 			}
818
-    			unset($data);
819
-    		    }
820
-    		}
821
-    	    }
822
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
823
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
824
-    	    $last_exec[$id]['last'] = time();
825
-    	} elseif ($value['format'] === 'airwhere' && 
826
-    	    (
827
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
828
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
829
-    	    )
830
-    	) {
831
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
832
-	    if ($buffer != '') {
818
+				unset($data);
819
+				}
820
+			}
821
+			}
822
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
823
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
824
+			$last_exec[$id]['last'] = time();
825
+		} elseif ($value['format'] === 'airwhere' && 
826
+			(
827
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
828
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
829
+			)
830
+		) {
831
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
832
+		if ($buffer != '') {
833 833
 		$all_data = simplexml_load_string($buffer);
834 834
 		foreach($all_data->children() as $childdata) {
835 835
 			$data = array();
@@ -851,10 +851,10 @@  discard block
 block discarded – undo
851 851
 			$SI->add($data);
852 852
 			unset($data);
853 853
 		}
854
-	    }
855
-	    $Source->deleteOldLocationByType('gs');
856
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
857
-	    if ($buffer != '') {
854
+		}
855
+		$Source->deleteOldLocationByType('gs');
856
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
857
+		if ($buffer != '') {
858 858
 		$all_data = simplexml_load_string($buffer);
859 859
 		foreach($all_data->children() as $childdata) {
860 860
 			$data = array();
@@ -872,8 +872,8 @@  discard block
 block discarded – undo
872 872
 			}
873 873
 			unset($data);
874 874
 		}
875
-	    }
876
-	    $last_exec[$id]['last'] = time();
875
+		}
876
+		$last_exec[$id]['last'] = time();
877 877
 	/*
878 878
 	} if ($value['format'] === 'aircraftlistjson') {
879 879
 	    print_r($globalSources);
@@ -881,17 +881,17 @@  discard block
 block discarded – undo
881 881
 	    echo $globalMinFetch;
882 882
 	*/
883 883
 	} elseif ($value['format'] === 'aircraftlistjson' && 
884
-	    (
884
+		(
885 885
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
886 886
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
887
-	    )
887
+		)
888 888
 	) {
889
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
890
-	    if ($buffer != '') {
891
-	        $all_data = json_decode($buffer,true);
889
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
890
+		if ($buffer != '') {
891
+			$all_data = json_decode($buffer,true);
892 892
 		if (isset($all_data['acList'])) {
893
-		    $reset = 0;
894
-		    foreach ($all_data['acList'] as $line) {
893
+			$reset = 0;
894
+			foreach ($all_data['acList'] as $line) {
895 895
 			$data = array();
896 896
 			$data['hex'] = $line['Icao']; // hex
897 897
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -914,10 +914,10 @@  discard block
 block discarded – undo
914 914
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
915 915
 			if (isset($data['latitude'])) $SI->add($data);
916 916
 			unset($data);
917
-		    }
917
+			}
918 918
 		} elseif (is_array($all_data)) {
919
-		    $reset = 0;
920
-		    foreach ($all_data as $line) {
919
+			$reset = 0;
920
+			foreach ($all_data as $line) {
921 921
 			$data = array();
922 922
 			$data['hex'] = $line['hex']; // hex
923 923
 			$data['ident'] = $line['flight']; // ident
@@ -937,257 +937,257 @@  discard block
 block discarded – undo
937 937
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
938 938
 			$SI->add($data);
939 939
 			unset($data);
940
-		    }
940
+			}
941 941
 		}
942
-	    } elseif ($globalDebug) echo 'No data'."\n";
943
-    	    //$last_exec['aircraftlistjson'] = time();
944
-    	    $last_exec[$id]['last'] = time();
945
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
946
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
947
-    	    (
948
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
949
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
950
-    	    )
951
-    	) {
952
-	    $buffer = $Common->getData($value['host']);
953
-	    $all_data = json_decode($buffer,true);
954
-	    if (isset($all_data['planes'])) {
942
+		} elseif ($globalDebug) echo 'No data'."\n";
943
+			//$last_exec['aircraftlistjson'] = time();
944
+			$last_exec[$id]['last'] = time();
945
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
946
+		} elseif ($value['format'] === 'planeupdatefaa' && 
947
+			(
948
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
949
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
950
+			)
951
+		) {
952
+		$buffer = $Common->getData($value['host']);
953
+		$all_data = json_decode($buffer,true);
954
+		if (isset($all_data['planes'])) {
955 955
 		$reset = 0;
956 956
 		foreach ($all_data['planes'] as $key => $line) {
957
-		    $data = array();
958
-		    $data['hex'] = $key; // hex
959
-		    $data['ident'] = $line[3]; // ident
960
-		    $data['altitude'] = $line[6]; // altitude
961
-		    $data['speed'] = $line[8]; // speed
962
-		    $data['heading'] = $line[7]; // heading
963
-		    $data['latitude'] = $line[4]; // lat
964
-		    $data['longitude'] = $line[5]; // long
965
-		    //$data['verticalrate'] = $line[]; // verticale rate
966
-		    $data['squawk'] = $line[10]; // squawk
967
-		    $data['emergency'] = ''; // emergency
968
-		    $data['registration'] = $line[2];
969
-		    $data['aircraft_icao'] = $line[0];
970
-		    $deparr = explode('-',$line[1]);
971
-		    if (count($deparr) === 2) {
957
+			$data = array();
958
+			$data['hex'] = $key; // hex
959
+			$data['ident'] = $line[3]; // ident
960
+			$data['altitude'] = $line[6]; // altitude
961
+			$data['speed'] = $line[8]; // speed
962
+			$data['heading'] = $line[7]; // heading
963
+			$data['latitude'] = $line[4]; // lat
964
+			$data['longitude'] = $line[5]; // long
965
+			//$data['verticalrate'] = $line[]; // verticale rate
966
+			$data['squawk'] = $line[10]; // squawk
967
+			$data['emergency'] = ''; // emergency
968
+			$data['registration'] = $line[2];
969
+			$data['aircraft_icao'] = $line[0];
970
+			$deparr = explode('-',$line[1]);
971
+			if (count($deparr) === 2) {
972 972
 			$data['departure_airport_icao'] = $deparr[0];
973 973
 			$data['arrival_airport_icao'] = $deparr[1];
974
-		    }
975
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
976
-	    	    $data['format_source'] = 'planeupdatefaa';
977
-    		    $data['id_source'] = $id_source;
978
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
979
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
980
-		    $SI->add($data);
981
-		    unset($data);
974
+			}
975
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
976
+				$data['format_source'] = 'planeupdatefaa';
977
+				$data['id_source'] = $id_source;
978
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
979
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
980
+			$SI->add($data);
981
+			unset($data);
982 982
 		}
983
-	    }
984
-	    //$last_exec['planeupdatefaa'] = time();
985
-	    $last_exec[$id]['last'] = time();
983
+		}
984
+		//$last_exec['planeupdatefaa'] = time();
985
+		$last_exec[$id]['last'] = time();
986 986
 	} elseif ($value['format'] === 'opensky' && 
987
-	    (
987
+		(
988 988
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
989 989
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
990
-	    )
990
+		)
991 991
 	) {
992
-	    $buffer = $Common->getData($value['host']);
993
-	    $all_data = json_decode($buffer,true);
994
-	    if (isset($all_data['states'])) {
992
+		$buffer = $Common->getData($value['host']);
993
+		$all_data = json_decode($buffer,true);
994
+		if (isset($all_data['states'])) {
995 995
 		$reset = 0;
996 996
 		foreach ($all_data['states'] as $key => $line) {
997
-		    $data = array();
998
-		    $data['hex'] = $line[0]; // hex
999
-		    $data['ident'] = trim($line[1]); // ident
1000
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1001
-		    $data['speed'] = round($line[9]*1.94384); // speed
1002
-		    $data['heading'] = round($line[10]); // heading
1003
-		    $data['latitude'] = $line[6]; // lat
1004
-		    $data['longitude'] = $line[5]; // long
1005
-		    $data['verticalrate'] = $line[11]; // verticale rate
1006
-		    //$data['squawk'] = $line[10]; // squawk
1007
-		    //$data['emergency'] = ''; // emergency
1008
-		    //$data['registration'] = $line[2];
1009
-		    //$data['aircraft_icao'] = $line[0];
1010
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1011
-		    $data['format_source'] = 'opensky';
1012
-		    $data['id_source'] = $id_source;
1013
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1014
-		    $SI->add($data);
1015
-		    unset($data);
997
+			$data = array();
998
+			$data['hex'] = $line[0]; // hex
999
+			$data['ident'] = trim($line[1]); // ident
1000
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1001
+			$data['speed'] = round($line[9]*1.94384); // speed
1002
+			$data['heading'] = round($line[10]); // heading
1003
+			$data['latitude'] = $line[6]; // lat
1004
+			$data['longitude'] = $line[5]; // long
1005
+			$data['verticalrate'] = $line[11]; // verticale rate
1006
+			//$data['squawk'] = $line[10]; // squawk
1007
+			//$data['emergency'] = ''; // emergency
1008
+			//$data['registration'] = $line[2];
1009
+			//$data['aircraft_icao'] = $line[0];
1010
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1011
+			$data['format_source'] = 'opensky';
1012
+			$data['id_source'] = $id_source;
1013
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1014
+			$SI->add($data);
1015
+			unset($data);
1016 1016
 		}
1017
-	    }
1018
-	    //$last_exec['planeupdatefaa'] = time();
1019
-	    $last_exec[$id]['last'] = time();
1017
+		}
1018
+		//$last_exec['planeupdatefaa'] = time();
1019
+		$last_exec[$id]['last'] = time();
1020 1020
 	} elseif ($value['format'] === 'aircraftjson' && 
1021
-	    (
1021
+		(
1022 1022
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1023 1023
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1024
-	    )
1024
+		)
1025 1025
 	) {
1026
-	    $buffer = $Common->getData($value['host']);
1027
-	    $all_data = json_decode($buffer,true);
1028
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1026
+		$buffer = $Common->getData($value['host']);
1027
+		$all_data = json_decode($buffer,true);
1028
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1029 1029
 		$reset = 0;
1030 1030
 		foreach ($all_data['aircraft'] as $key => $line) {
1031
-		    $data = array();
1032
-		    // add support for ground vehicule with ~ in front of hex
1033
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1034
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1035
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1036
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1037
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1038
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1039
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1040
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1041
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1042
-		    //$data['emergency'] = ''; // emergency
1043
-		    //$data['registration'] = $line[2];
1044
-		    //$data['aircraft_icao'] = $line[0];
1045
-		    $data['datetime'] = date('Y-m-d H:i:s');
1046
-		    $data['format_source'] = 'aircraftjson';
1047
-		    $data['id_source'] = $id_source;
1048
-		    if (isset($value['name']) && $value['name'] != '') {
1049
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1050
-			    else $data['source_name'] = $value['name'];
1051
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1052
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1053
-		    $SI->add($data);
1054
-		    unset($data);
1031
+			$data = array();
1032
+			// add support for ground vehicule with ~ in front of hex
1033
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1034
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1035
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1036
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1037
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1038
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1039
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1040
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1041
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1042
+			//$data['emergency'] = ''; // emergency
1043
+			//$data['registration'] = $line[2];
1044
+			//$data['aircraft_icao'] = $line[0];
1045
+			$data['datetime'] = date('Y-m-d H:i:s');
1046
+			$data['format_source'] = 'aircraftjson';
1047
+			$data['id_source'] = $id_source;
1048
+			if (isset($value['name']) && $value['name'] != '') {
1049
+				if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1050
+				else $data['source_name'] = $value['name'];
1051
+			} elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1052
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1053
+			$SI->add($data);
1054
+			unset($data);
1055 1055
 		}
1056
-	    }
1057
-	    //$last_exec['planeupdatefaa'] = time();
1058
-	    $last_exec[$id]['last'] = time();
1056
+		}
1057
+		//$last_exec['planeupdatefaa'] = time();
1058
+		$last_exec[$id]['last'] = time();
1059 1059
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1060 1060
 	} elseif ($value['format'] === 'fr24json' && 
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']);
1068
-	    $all_data = json_decode($buffer,true);
1069
-	    if (!empty($all_data)) $reset = 0;
1070
-	    foreach ($all_data as $key => $line) {
1066
+		//$buffer = $Common->getData($hosts[$id]);
1067
+		$buffer = $Common->getData($value['host']);
1068
+		$all_data = json_decode($buffer,true);
1069
+		if (!empty($all_data)) $reset = 0;
1070
+		foreach ($all_data as $key => $line) {
1071 1071
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1072
-		    $data = array();
1073
-		    $data['hex'] = $line[0];
1074
-		    $data['ident'] = $line[16]; //$line[13]
1075
-	    	    $data['altitude'] = $line[4]; // altitude
1076
-	    	    $data['speed'] = $line[5]; // speed
1077
-	    	    $data['heading'] = $line[3]; // heading
1078
-	    	    $data['latitude'] = $line[1]; // lat
1079
-	    	    $data['longitude'] = $line[2]; // long
1080
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1081
-	    	    $data['squawk'] = $line[6]; // squawk
1082
-	    	    $data['aircraft_icao'] = $line[8];
1083
-	    	    $data['registration'] = $line[9];
1084
-		    $data['departure_airport_iata'] = $line[11];
1085
-		    $data['arrival_airport_iata'] = $line[12];
1086
-	    	    $data['emergency'] = ''; // emergency
1087
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1088
-	    	    $data['format_source'] = 'fr24json';
1089
-    		    $data['id_source'] = $id_source;
1090
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1091
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1092
-		    $SI->add($data);
1093
-		    unset($data);
1072
+			$data = array();
1073
+			$data['hex'] = $line[0];
1074
+			$data['ident'] = $line[16]; //$line[13]
1075
+				$data['altitude'] = $line[4]; // altitude
1076
+				$data['speed'] = $line[5]; // speed
1077
+				$data['heading'] = $line[3]; // heading
1078
+				$data['latitude'] = $line[1]; // lat
1079
+				$data['longitude'] = $line[2]; // long
1080
+				$data['verticalrate'] = $line[15]; // verticale rate
1081
+				$data['squawk'] = $line[6]; // squawk
1082
+				$data['aircraft_icao'] = $line[8];
1083
+				$data['registration'] = $line[9];
1084
+			$data['departure_airport_iata'] = $line[11];
1085
+			$data['arrival_airport_iata'] = $line[12];
1086
+				$data['emergency'] = ''; // emergency
1087
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1088
+				$data['format_source'] = 'fr24json';
1089
+				$data['id_source'] = $id_source;
1090
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1091
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1092
+			$SI->add($data);
1093
+			unset($data);
1094
+		}
1094 1095
 		}
1095
-	    }
1096
-	    //$last_exec['fr24json'] = time();
1097
-	    $last_exec[$id]['last'] = time();
1096
+		//$last_exec['fr24json'] = time();
1097
+		$last_exec[$id]['last'] = time();
1098 1098
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1099 1099
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1100
-	    (
1100
+		(
1101 1101
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1102 1102
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1103
-	    )
1103
+		)
1104 1104
 	) {
1105
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1106
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1107
-	    //echo $buffer;
1108
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1109
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1110
-	    $all_data = json_decode($buffer,true);
1111
-	    if (json_last_error() != JSON_ERROR_NONE) {
1105
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1106
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1107
+		//echo $buffer;
1108
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1109
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1110
+		$all_data = json_decode($buffer,true);
1111
+		if (json_last_error() != JSON_ERROR_NONE) {
1112 1112
 		die(json_last_error_msg());
1113
-	    }
1114
-	    if (isset($all_data['mrkrs'])) {
1113
+		}
1114
+		if (isset($all_data['mrkrs'])) {
1115 1115
 		$reset = 0;
1116 1116
 		foreach ($all_data['mrkrs'] as $key => $line) {
1117
-		    if (isset($line['inf'])) {
1117
+			if (isset($line['inf'])) {
1118 1118
 			$data = array();
1119 1119
 			$data['hex'] = $line['inf']['ia'];
1120 1120
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1121
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1122
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1123
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1124
-	    		$data['latitude'] = $line['pt'][0]; // lat
1125
-	    		$data['longitude'] = $line['pt'][1]; // long
1126
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1127
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1128
-	    		//$data['aircraft_icao'] = $line[8];
1129
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1121
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1122
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1123
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1124
+				$data['latitude'] = $line['pt'][0]; // lat
1125
+				$data['longitude'] = $line['pt'][1]; // long
1126
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1127
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1128
+				//$data['aircraft_icao'] = $line[8];
1129
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1130 1130
 			//$data['departure_airport_iata'] = $line[11];
1131 1131
 			//$data['arrival_airport_iata'] = $line[12];
1132
-	    		//$data['emergency'] = ''; // emergency
1132
+				//$data['emergency'] = ''; // emergency
1133 1133
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1134
-	    		$data['format_source'] = 'radarvirtueljson';
1135
-    			$data['id_source'] = $id_source;
1134
+				$data['format_source'] = 'radarvirtueljson';
1135
+				$data['id_source'] = $id_source;
1136 1136
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1137 1137
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1138 1138
 			$SI->add($data);
1139 1139
 			unset($data);
1140
-		    }
1140
+			}
1141
+		}
1141 1142
 		}
1142
-	    }
1143
-	    //$last_exec['radarvirtueljson'] = time();
1144
-	    $last_exec[$id]['last'] = time();
1143
+		//$last_exec['radarvirtueljson'] = time();
1144
+		$last_exec[$id]['last'] = time();
1145 1145
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1146 1146
 	} elseif ($value['format'] === 'pirepsjson' && 
1147
-	    (
1147
+		(
1148 1148
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1149 1149
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1150
-	    )
1150
+		)
1151 1151
 	) {
1152
-	    //$buffer = $Common->getData($hosts[$id]);
1153
-	    $buffer = $Common->getData($value['host'].'?'.time());
1154
-	    $all_data = json_decode(utf8_encode($buffer),true);
1152
+		//$buffer = $Common->getData($hosts[$id]);
1153
+		$buffer = $Common->getData($value['host'].'?'.time());
1154
+		$all_data = json_decode(utf8_encode($buffer),true);
1155 1155
 	    
1156
-	    if (isset($all_data['pireps'])) {
1156
+		if (isset($all_data['pireps'])) {
1157 1157
 		$reset = 0;
1158
-	        foreach ($all_data['pireps'] as $line) {
1159
-		    $data = array();
1160
-		    $data['id'] = $line['id'];
1161
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1162
-		    $data['ident'] = $line['callsign']; // ident
1163
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1164
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1165
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1166
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1167
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1168
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1169
-		    $data['latitude'] = $line['lat']; // lat
1170
-		    $data['longitude'] = $line['lon']; // long
1171
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1172
-		    //$data['squawk'] = $line['squawk']; // squawk
1173
-		    //$data['emergency'] = ''; // emergency
1174
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1175
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1176
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1177
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1178
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1179
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1180
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1181
-		    else $data['info'] = '';
1182
-		    $data['format_source'] = 'pireps';
1183
-    		    $data['id_source'] = $id_source;
1184
-		    $data['datetime'] = date('Y-m-d H:i:s');
1185
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1186
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1187
-		    if ($line['icon'] === 'plane') {
1158
+			foreach ($all_data['pireps'] as $line) {
1159
+			$data = array();
1160
+			$data['id'] = $line['id'];
1161
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1162
+			$data['ident'] = $line['callsign']; // ident
1163
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1164
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1165
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1166
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1167
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1168
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1169
+			$data['latitude'] = $line['lat']; // lat
1170
+			$data['longitude'] = $line['lon']; // long
1171
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1172
+			//$data['squawk'] = $line['squawk']; // squawk
1173
+			//$data['emergency'] = ''; // emergency
1174
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1175
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1176
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1177
+			//$data['arrival_airport_time'] = $line['arrtime'];
1178
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1179
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1180
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1181
+			else $data['info'] = '';
1182
+			$data['format_source'] = 'pireps';
1183
+				$data['id_source'] = $id_source;
1184
+			$data['datetime'] = date('Y-m-d H:i:s');
1185
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1186
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1187
+			if ($line['icon'] === 'plane') {
1188 1188
 			$SI->add($data);
1189
-		    //    print_r($data);
1190
-    		    } elseif ($line['icon'] === 'ct') {
1189
+			//    print_r($data);
1190
+				} elseif ($line['icon'] === 'ct') {
1191 1191
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1192 1192
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1193 1193
 			$typec = substr($data['ident'],-3);
@@ -1202,209 +1202,209 @@  discard block
 block discarded – undo
1202 1202
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1203 1203
 			else $data['type'] = 'Observer';
1204 1204
 			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']);
1205
-		    }
1206
-		    unset($data);
1205
+			}
1206
+			unset($data);
1207
+		}
1207 1208
 		}
1208
-	    }
1209
-	    //$last_exec['pirepsjson'] = time();
1210
-	    $last_exec[$id]['last'] = time();
1209
+		//$last_exec['pirepsjson'] = time();
1210
+		$last_exec[$id]['last'] = time();
1211 1211
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1212 1212
 	} elseif ($value['format'] === 'phpvmacars' && 
1213
-	    (
1213
+		(
1214 1214
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1215 1215
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1216
-	    )
1216
+		)
1217 1217
 	) {
1218
-	    //$buffer = $Common->getData($hosts[$id]);
1219
-	    if ($globalDebug) echo 'Get Data...'."\n";
1220
-	    $buffer = $Common->getData($value['host']);
1221
-	    $all_data = json_decode($buffer,true);
1222
-	    if ($buffer != '' && is_array($all_data)) {
1218
+		//$buffer = $Common->getData($hosts[$id]);
1219
+		if ($globalDebug) echo 'Get Data...'."\n";
1220
+		$buffer = $Common->getData($value['host']);
1221
+		$all_data = json_decode($buffer,true);
1222
+		if ($buffer != '' && is_array($all_data)) {
1223 1223
 		$reset = 0;
1224 1224
 		foreach ($all_data as $line) {
1225
-	    	    $data = array();
1226
-	    	    //$data['id'] = $line['id']; // id not usable
1227
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1228
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1229
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1230
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1231
-	    	    $data['ident'] = $line['flightnum']; // ident
1232
-	    	    $data['altitude'] = $line['alt']; // altitude
1233
-	    	    $data['speed'] = $line['gs']; // speed
1234
-	    	    $data['heading'] = $line['heading']; // heading
1235
-	    	    $data['latitude'] = $line['lat']; // lat
1236
-	    	    $data['longitude'] = $line['lng']; // long
1237
-	    	    $data['verticalrate'] = ''; // verticale rate
1238
-	    	    $data['squawk'] = ''; // squawk
1239
-	    	    $data['emergency'] = ''; // emergency
1240
-	    	    //$data['datetime'] = $line['lastupdate'];
1241
-	    	    //$data['last_update'] = $line['lastupdate'];
1242
-	    	    if (isset($value['timezone'])) {
1243
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1244
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1245
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1246
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1247
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1248
-	    	    $data['departure_airport_time'] = $line['deptime'];
1249
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1250
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1251
-    		    if (isset($line['registration'])) {
1252
-    			$data['registration'] = $line['registration'];
1253
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1254
-    		    } else $data['registration'] = $line['aircraft'];
1255
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1256
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1257
-		    if (isset($line['aircraftname'])) {
1225
+				$data = array();
1226
+				//$data['id'] = $line['id']; // id not usable
1227
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1228
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1229
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1230
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1231
+				$data['ident'] = $line['flightnum']; // ident
1232
+				$data['altitude'] = $line['alt']; // altitude
1233
+				$data['speed'] = $line['gs']; // speed
1234
+				$data['heading'] = $line['heading']; // heading
1235
+				$data['latitude'] = $line['lat']; // lat
1236
+				$data['longitude'] = $line['lng']; // long
1237
+				$data['verticalrate'] = ''; // verticale rate
1238
+				$data['squawk'] = ''; // squawk
1239
+				$data['emergency'] = ''; // emergency
1240
+				//$data['datetime'] = $line['lastupdate'];
1241
+				//$data['last_update'] = $line['lastupdate'];
1242
+				if (isset($value['timezone'])) {
1243
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1244
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1245
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1246
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1247
+				$data['departure_airport_icao'] = $line['depicao'];
1248
+				$data['departure_airport_time'] = $line['deptime'];
1249
+				$data['arrival_airport_icao'] = $line['arricao'];
1250
+				$data['arrival_airport_time'] = $line['arrtime'];
1251
+				if (isset($line['registration'])) {
1252
+				$data['registration'] = $line['registration'];
1253
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1254
+				} else $data['registration'] = $line['aircraft'];
1255
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1256
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1257
+			if (isset($line['aircraftname'])) {
1258 1258
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1259 1259
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1260
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1261
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1262
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1263
-	    		else {
1264
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1265
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1266
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1267
-	    		}
1268
-	    	    }
1269
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1270
-    		    $data['id_source'] = $id_source;
1271
-	    	    $data['format_source'] = 'phpvmacars';
1272
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1273
-		    $SI->add($data);
1274
-		    unset($data);
1260
+				$aircraft_data = explode('-',$line['aircraftname']);
1261
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1262
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1263
+				else {
1264
+					$aircraft_data = explode(' ',$line['aircraftname']);
1265
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1266
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1267
+				}
1268
+				}
1269
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1270
+				$data['id_source'] = $id_source;
1271
+				$data['format_source'] = 'phpvmacars';
1272
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1273
+			$SI->add($data);
1274
+			unset($data);
1275 1275
 		}
1276 1276
 		if ($globalDebug) echo 'No more data...'."\n";
1277 1277
 		unset($buffer);
1278 1278
 		unset($all_data);
1279
-	    }
1280
-	    //$last_exec['phpvmacars'] = time();
1281
-	    $last_exec[$id]['last'] = time();
1279
+		}
1280
+		//$last_exec['phpvmacars'] = time();
1281
+		$last_exec[$id]['last'] = time();
1282 1282
 	} elseif ($value['format'] === 'vaos' && 
1283
-	    (
1283
+		(
1284 1284
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1285 1285
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1286
-	    )
1286
+		)
1287 1287
 	) {
1288
-	    //$buffer = $Common->getData($hosts[$id]);
1289
-	    if ($globalDebug) echo 'Get Data...'."\n";
1290
-	    $buffer = $Common->getData($value['host']);
1291
-	    $all_data = json_decode($buffer,true);
1292
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1288
+		//$buffer = $Common->getData($hosts[$id]);
1289
+		if ($globalDebug) echo 'Get Data...'."\n";
1290
+		$buffer = $Common->getData($value['host']);
1291
+		$all_data = json_decode($buffer,true);
1292
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1293 1293
 		$reset = 0;
1294 1294
 		foreach ($all_data['ACARSData'] as $line) {
1295
-		    //print_r($line);
1296
-	    	    $data = array();
1297
-	    	    //$data['id'] = $line['id']; // id not usable
1298
-	    	    $data['id'] = $line['id'];
1299
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1300
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1301
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1302
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1303
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1304
-	    	    $data['altitude'] = $line['altitude']; // altitude
1305
-	    	    $data['speed'] = $line['groundspeed']; // speed
1306
-	    	    $data['heading'] = $line['heading']; // heading
1307
-	    	    $data['latitude'] = $line['lat']; // lat
1308
-	    	    $data['longitude'] = $line['lon']; // long
1309
-	    	    //$data['verticalrate'] = ''; // verticale rate
1310
-	    	    //$data['squawk'] = ''; // squawk
1311
-	    	    //$data['emergency'] = ''; // emergency
1312
-	    	    if (isset($value['timezone'])) {
1313
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1314
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1315
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1316
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1295
+			//print_r($line);
1296
+				$data = array();
1297
+				//$data['id'] = $line['id']; // id not usable
1298
+				$data['id'] = $line['id'];
1299
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1300
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1301
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1302
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1303
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1304
+				$data['altitude'] = $line['altitude']; // altitude
1305
+				$data['speed'] = $line['groundspeed']; // speed
1306
+				$data['heading'] = $line['heading']; // heading
1307
+				$data['latitude'] = $line['lat']; // lat
1308
+				$data['longitude'] = $line['lon']; // long
1309
+				//$data['verticalrate'] = ''; // verticale rate
1310
+				//$data['squawk'] = ''; // squawk
1311
+				//$data['emergency'] = ''; // emergency
1312
+				if (isset($value['timezone'])) {
1313
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1314
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1315
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1316
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1317 1317
 	    	    
1318
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1319
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1320
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1321
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1322
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1318
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1319
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1320
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1321
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1322
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1323 1323
 
1324
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1325
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1326
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1324
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1325
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1326
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1327 1327
 
1328
-    		    $data['id_source'] = $id_source;
1329
-	    	    $data['format_source'] = 'vaos';
1330
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1331
-		    $SI->add($data);
1332
-		    unset($data);
1328
+				$data['id_source'] = $id_source;
1329
+				$data['format_source'] = 'vaos';
1330
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1331
+			$SI->add($data);
1332
+			unset($data);
1333 1333
 		}
1334 1334
 		if ($globalDebug) echo 'No more data...'."\n";
1335 1335
 		unset($buffer);
1336 1336
 		unset($all_data);
1337
-	    }
1338
-	    //$last_exec['phpvmacars'] = time();
1339
-	    $last_exec[$id]['last'] = time();
1337
+		}
1338
+		//$last_exec['phpvmacars'] = time();
1339
+		$last_exec[$id]['last'] = time();
1340 1340
 	} elseif ($value['format'] === 'vam' && 
1341
-	    (
1341
+		(
1342 1342
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1343 1343
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1344
-	    )
1344
+		)
1345 1345
 	) {
1346
-	    //$buffer = $Common->getData($hosts[$id]);
1347
-	    if ($globalDebug) echo 'Get Data...'."\n";
1348
-	    $buffer = $Common->getData($value['host']);
1349
-	    $all_data = json_decode($buffer,true);
1350
-	    if ($buffer != '' && is_array($all_data)) {
1346
+		//$buffer = $Common->getData($hosts[$id]);
1347
+		if ($globalDebug) echo 'Get Data...'."\n";
1348
+		$buffer = $Common->getData($value['host']);
1349
+		$all_data = json_decode($buffer,true);
1350
+		if ($buffer != '' && is_array($all_data)) {
1351 1351
 		$reset = 0;
1352 1352
 		foreach ($all_data as $line) {
1353
-	    	    $data = array();
1354
-	    	    //$data['id'] = $line['id']; // id not usable
1355
-	    	    $data['id'] = trim($line['flight_id']);
1356
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1357
-	    	    $data['pilot_name'] = $line['pilot_name'];
1358
-	    	    $data['pilot_id'] = $line['pilot_id'];
1359
-	    	    $data['ident'] = trim($line['callsign']); // ident
1360
-	    	    $data['altitude'] = $line['altitude']; // altitude
1361
-	    	    $data['speed'] = $line['gs']; // speed
1362
-	    	    $data['heading'] = $line['heading']; // heading
1363
-	    	    $data['latitude'] = $line['latitude']; // lat
1364
-	    	    $data['longitude'] = $line['longitude']; // long
1365
-	    	    $data['verticalrate'] = ''; // verticale rate
1366
-	    	    $data['squawk'] = ''; // squawk
1367
-	    	    $data['emergency'] = ''; // emergency
1368
-	    	    //$data['datetime'] = $line['lastupdate'];
1369
-	    	    $data['last_update'] = $line['last_update'];
1370
-		    $data['datetime'] = date('Y-m-d H:i:s');
1371
-	    	    $data['departure_airport_icao'] = $line['departure'];
1372
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1373
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1374
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1375
-    		    //$data['registration'] = $line['aircraft'];
1376
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1377
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1378
-    		    $data['id_source'] = $id_source;
1379
-	    	    $data['format_source'] = 'vam';
1380
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1381
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1382
-		    $SI->add($data);
1383
-		    unset($data);
1353
+				$data = array();
1354
+				//$data['id'] = $line['id']; // id not usable
1355
+				$data['id'] = trim($line['flight_id']);
1356
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1357
+				$data['pilot_name'] = $line['pilot_name'];
1358
+				$data['pilot_id'] = $line['pilot_id'];
1359
+				$data['ident'] = trim($line['callsign']); // ident
1360
+				$data['altitude'] = $line['altitude']; // altitude
1361
+				$data['speed'] = $line['gs']; // speed
1362
+				$data['heading'] = $line['heading']; // heading
1363
+				$data['latitude'] = $line['latitude']; // lat
1364
+				$data['longitude'] = $line['longitude']; // long
1365
+				$data['verticalrate'] = ''; // verticale rate
1366
+				$data['squawk'] = ''; // squawk
1367
+				$data['emergency'] = ''; // emergency
1368
+				//$data['datetime'] = $line['lastupdate'];
1369
+				$data['last_update'] = $line['last_update'];
1370
+			$data['datetime'] = date('Y-m-d H:i:s');
1371
+				$data['departure_airport_icao'] = $line['departure'];
1372
+				//$data['departure_airport_time'] = $line['departure_time'];
1373
+				$data['arrival_airport_icao'] = $line['arrival'];
1374
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1375
+				//$data['registration'] = $line['aircraft'];
1376
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1377
+				$data['aircraft_icao'] = $line['plane_type'];
1378
+				$data['id_source'] = $id_source;
1379
+				$data['format_source'] = 'vam';
1380
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1381
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1382
+			$SI->add($data);
1383
+			unset($data);
1384 1384
 		}
1385 1385
 		if ($globalDebug) echo 'No more data...'."\n";
1386 1386
 		unset($buffer);
1387 1387
 		unset($all_data);
1388
-	    }
1389
-	    //$last_exec['phpvmacars'] = time();
1390
-	    $last_exec[$id]['last'] = time();
1388
+		}
1389
+		//$last_exec['phpvmacars'] = time();
1390
+		$last_exec[$id]['last'] = time();
1391 1391
 	} elseif ($value['format'] === 'blitzortung' && 
1392
-	    (
1392
+		(
1393 1393
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1394 1394
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1395
-	    )
1395
+		)
1396 1396
 	) {
1397
-	    //$buffer = $Common->getData($hosts[$id]);
1398
-	    if ($globalDebug) echo 'Get Data...'."\n";
1399
-	    $buffer = $Common->getData($value['host']);
1400
-	    $all_data = json_decode($buffer,true);
1401
-	    if ($buffer != '') {
1397
+		//$buffer = $Common->getData($hosts[$id]);
1398
+		if ($globalDebug) echo 'Get Data...'."\n";
1399
+		$buffer = $Common->getData($value['host']);
1400
+		$all_data = json_decode($buffer,true);
1401
+		if ($buffer != '') {
1402 1402
 		$Source->deleteLocationBySource('blitzortung');
1403 1403
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1404 1404
 		$buffer = explode('\n',$buffer);
1405 1405
 		foreach ($buffer as $buffer_line) {
1406
-		    $line = json_decode($buffer_line,true);
1407
-		    if (isset($line['time'])) {
1406
+			$line = json_decode($buffer_line,true);
1407
+			if (isset($line['time'])) {
1408 1408
 			$data = array();
1409 1409
 			$data['altitude'] = $line['alt']; // altitude
1410 1410
 			$data['latitude'] = $line['lat']; // lat
@@ -1416,94 +1416,94 @@  discard block
 block discarded – undo
1416 1416
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1417 1417
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1418 1418
 			unset($data);
1419
-		    }
1419
+			}
1420 1420
 		}
1421 1421
 		if ($globalDebug) echo 'No more data...'."\n";
1422 1422
 		unset($buffer);
1423
-	    }
1424
-	    $last_exec[$id]['last'] = time();
1423
+		}
1424
+		$last_exec[$id]['last'] = time();
1425 1425
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1426 1426
 	} 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') {
1427
-	    //$last_exec[$id]['last'] = time();
1428
-	    //$read = array( $sockets[$id] );
1429
-	    $read = $sockets;
1430
-	    $write = NULL;
1431
-	    $e = NULL;
1432
-	    $n = socket_select($read, $write, $e, $timeout);
1433
-	    if ($e != NULL) var_dump($e);
1434
-	    if ($n > 0) {
1427
+		//$last_exec[$id]['last'] = time();
1428
+		//$read = array( $sockets[$id] );
1429
+		$read = $sockets;
1430
+		$write = NULL;
1431
+		$e = NULL;
1432
+		$n = socket_select($read, $write, $e, $timeout);
1433
+		if ($e != NULL) var_dump($e);
1434
+		if ($n > 0) {
1435 1435
 		$reset = 0;
1436 1436
 		foreach ($read as $nb => $r) {
1437
-		    //$value = $formats[$nb];
1438
-		    $format = $globalSources[$nb]['format'];
1439
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1437
+			//$value = $formats[$nb];
1438
+			$format = $globalSources[$nb]['format'];
1439
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1440 1440
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1441
-		    } elseif ($format === 'vrstcp') {
1441
+			} elseif ($format === 'vrstcp') {
1442 1442
 			$buffer = @socket_read($r, 6000);
1443
-		    } else {
1443
+			} else {
1444 1444
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1445
-		    }
1446
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1447
-		    //echo $buffer."\n";
1448
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1449
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1450
-		    $error = false;
1451
-		    //$SI::del();
1452
-		    if ($buffer !== FALSE) {
1445
+			}
1446
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1447
+			//echo $buffer."\n";
1448
+			// lets play nice and handle signals such as ctrl-c/kill properly
1449
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1450
+			$error = false;
1451
+			//$SI::del();
1452
+			if ($buffer !== FALSE) {
1453 1453
 			if ($format === 'vrstcp') {
1454
-			    $buffer = explode('},{',$buffer);
1454
+				$buffer = explode('},{',$buffer);
1455 1455
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1456
-		    }
1457
-		    // SBS format is CSV format
1458
-		    if ($buffer !== FALSE && $buffer !== '') {
1456
+			}
1457
+			// SBS format is CSV format
1458
+			if ($buffer !== FALSE && $buffer !== '') {
1459 1459
 			$tt[$format] = 0;
1460 1460
 			if ($format === 'acarssbs3') {
1461
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1462
-			    $ACARS->add(trim($buffer));
1463
-			    $ACARS->deleteLiveAcarsData();
1461
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1462
+				$ACARS->add(trim($buffer));
1463
+				$ACARS->deleteLiveAcarsData();
1464 1464
 			} elseif ($format === 'raw') {
1465
-			    // AVR format
1466
-			    $data = $SBS->parse($buffer);
1467
-			    if (is_array($data)) {
1465
+				// AVR format
1466
+				$data = $SBS->parse($buffer);
1467
+				if (is_array($data)) {
1468 1468
 				$data['datetime'] = date('Y-m-d H:i:s');
1469 1469
 				$data['format_source'] = 'raw';
1470 1470
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1471 1471
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1472 1472
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1473 1473
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1474
-			    }
1474
+				}
1475 1475
 			} elseif ($format === 'ais') {
1476
-			    $ais_data = $AIS->parse_line(trim($buffer));
1477
-			    $data = array();
1478
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1479
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1480
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1481
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1482
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1483
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1484
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1485
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1486
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1487
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1488
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1489
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1490
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1491
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1492
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1493
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1476
+				$ais_data = $AIS->parse_line(trim($buffer));
1477
+				$data = array();
1478
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1479
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1480
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1481
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1482
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1483
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1484
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1485
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1486
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1487
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1488
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1489
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1490
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1491
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1492
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1493
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1494 1494
 
1495
-			    if (isset($ais_data['timestamp'])) {
1495
+				if (isset($ais_data['timestamp'])) {
1496 1496
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1497
-			    } else {
1497
+				} else {
1498 1498
 				$data['datetime'] = date('Y-m-d H:i:s');
1499
-			    }
1500
-			    $data['format_source'] = 'aisnmea';
1501
-    			    $data['id_source'] = $id_source;
1502
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1503
-			    unset($data);
1504
-                        } elseif ($format === 'flightgearsp') {
1505
-                    	    //echo $buffer."\n";
1506
-                    	    if (strlen($buffer) > 5) {
1499
+				}
1500
+				$data['format_source'] = 'aisnmea';
1501
+					$data['id_source'] = $id_source;
1502
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1503
+				unset($data);
1504
+						} elseif ($format === 'flightgearsp') {
1505
+							//echo $buffer."\n";
1506
+							if (strlen($buffer) > 5) {
1507 1507
 				$line = explode(',',$buffer);
1508 1508
 				$data = array();
1509 1509
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1520,38 +1520,38 @@  discard block
 block discarded – undo
1520 1520
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1521 1521
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1522 1522
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1523
-			    }
1524
-                        } elseif ($format === 'acars') {
1525
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1526
-			    $ACARS->add(trim($buffer));
1527
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1528
-			    $ACARS->deleteLiveAcarsData();
1523
+				}
1524
+						} elseif ($format === 'acars') {
1525
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1526
+				$ACARS->add(trim($buffer));
1527
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1528
+				$ACARS->deleteLiveAcarsData();
1529 1529
 			} elseif ($format === 'flightgearmp') {
1530
-			    if (substr($buffer,0,1) != '#') {
1530
+				if (substr($buffer,0,1) != '#') {
1531 1531
 				$data = array();
1532 1532
 				//echo $buffer."\n";
1533 1533
 				$line = explode(' ',$buffer);
1534 1534
 				if (count($line) === 11) {
1535
-				    $userserver = explode('@',$line[0]);
1536
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1537
-				    $data['ident'] = $userserver[0];
1538
-				    $data['registration'] = $userserver[0];
1539
-				    $data['latitude'] = $line[4];
1540
-				    $data['longitude'] = $line[5];
1541
-				    $data['altitude'] = $line[6];
1542
-				    $data['datetime'] = date('Y-m-d H:i:s');
1543
-				    $aircraft_type = $line[10];
1544
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1545
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1546
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1547
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1535
+					$userserver = explode('@',$line[0]);
1536
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1537
+					$data['ident'] = $userserver[0];
1538
+					$data['registration'] = $userserver[0];
1539
+					$data['latitude'] = $line[4];
1540
+					$data['longitude'] = $line[5];
1541
+					$data['altitude'] = $line[6];
1542
+					$data['datetime'] = date('Y-m-d H:i:s');
1543
+					$aircraft_type = $line[10];
1544
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1545
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1546
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1547
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1548
+				}
1548 1549
 				}
1549
-			    }
1550 1550
 			} elseif ($format === 'beast') {
1551
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1552
-			    die;
1551
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1552
+				die;
1553 1553
 			} elseif ($format === 'vrstcp') {
1554
-			    foreach($buffer as $all_data) {
1554
+				foreach($buffer as $all_data) {
1555 1555
 				$line = json_decode('{'.$all_data.'}',true);
1556 1556
 				$data = array();
1557 1557
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1571,153 +1571,153 @@  discard block
 block discarded – undo
1571 1571
 				*/
1572 1572
 				$data['datetime'] = date('Y-m-d H:i:s');
1573 1573
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1574
-		    		$data['format_source'] = 'vrstcp';
1574
+					$data['format_source'] = 'vrstcp';
1575 1575
 				$data['id_source'] = $id_source;
1576 1576
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1577 1577
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1578 1578
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1579 1579
 				unset($data);
1580
-			    }
1580
+				}
1581 1581
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1582
-			    $line = explode("\t", $buffer);
1583
-			    for($k = 0; $k < count($line); $k=$k+2) {
1582
+				$line = explode("\t", $buffer);
1583
+				for($k = 0; $k < count($line); $k=$k+2) {
1584 1584
 				$key = $line[$k];
1585
-			        $lined[$key] = $line[$k+1];
1586
-			    }
1587
-    			    if (count($lined) > 3) {
1588
-    				$data['hex'] = $lined['hexid'];
1589
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1590
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1591
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1592
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1593
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1594
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1595
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1596
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1597
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1598
-    				$data['id_source'] = $id_source;
1599
-    				$data['format_source'] = 'tsv';
1600
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1601
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1585
+					$lined[$key] = $line[$k+1];
1586
+				}
1587
+					if (count($lined) > 3) {
1588
+					$data['hex'] = $lined['hexid'];
1589
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1590
+					$data['datetime'] = date('Y-m-d H:i:s');;
1591
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1592
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1593
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1594
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1595
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1596
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1597
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1598
+					$data['id_source'] = $id_source;
1599
+					$data['format_source'] = 'tsv';
1600
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1601
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1602 1602
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1603
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1604
-    				unset($lined);
1605
-    				unset($data);
1606
-    			    } else $error = true;
1603
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1604
+					unset($lined);
1605
+					unset($data);
1606
+					} else $error = true;
1607 1607
 			} elseif ($format === 'aprs' && $use_aprs) {
1608
-			    if ($aprs_connect === 0) {
1608
+				if ($aprs_connect === 0) {
1609 1609
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1610 1610
 				$aprs_connect = 1;
1611
-			    }
1611
+				}
1612 1612
 			    
1613
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1613
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1614 1614
 				$aprs_last_tx = time();
1615 1615
 				$data_aprs = "# Keep alive";
1616 1616
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1617
-			    }
1617
+				}
1618 1618
 			    
1619
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1620
-			    //echo 'APRS data : '.$buffer."\n";
1621
-			    $buffer = str_replace('APRS <- ','',$buffer);
1622
-			    $buffer = str_replace('APRS -> ','',$buffer);
1623
-			    //echo $buffer."\n";
1624
-			    date_default_timezone_set('UTC');
1625
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1619
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1620
+				//echo 'APRS data : '.$buffer."\n";
1621
+				$buffer = str_replace('APRS <- ','',$buffer);
1622
+				$buffer = str_replace('APRS -> ','',$buffer);
1623
+				//echo $buffer."\n";
1624
+				date_default_timezone_set('UTC');
1625
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1626 1626
 				$line = $APRS->parse($buffer);
1627 1627
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1628 1628
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1629
-				    $aprs_last_tx = time();
1630
-				    $data = array();
1631
-				    //print_r($line);
1632
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1633
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1634
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1635
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1636
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1637
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1638
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1639
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1640
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1641
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1642
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1643
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1644
-				    $data['latitude'] = $line['latitude'];
1645
-				    $data['longitude'] = $line['longitude'];
1646
-				    //$data['verticalrate'] = $line[16];
1647
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1648
-				    //else $data['speed'] = 0;
1649
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1650
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1651
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1652
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1629
+					$aprs_last_tx = time();
1630
+					$data = array();
1631
+					//print_r($line);
1632
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1633
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1634
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1635
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1636
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1637
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1638
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1639
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1640
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1641
+					else $data['datetime'] = date('Y-m-d H:i:s');
1642
+					//$data['datetime'] = date('Y-m-d H:i:s');
1643
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1644
+					$data['latitude'] = $line['latitude'];
1645
+					$data['longitude'] = $line['longitude'];
1646
+					//$data['verticalrate'] = $line[16];
1647
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1648
+					//else $data['speed'] = 0;
1649
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1650
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1651
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1652
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1653 1653
 				    
1654
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1655
-				    //else echo 'No heading...'."\n";
1656
-				    //else $data['heading'] = 0;
1657
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1658
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1659
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1660
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1661
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1662
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1663
-    				    $data['id_source'] = $id_source;
1664
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1665
-				    else $data['format_source'] = 'aprs';
1666
-				    $data['source_name'] = $line['source'];
1667
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1668
-				    else $data['source_type'] = 'flarm';
1669
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1670
-				    $currentdate = date('Y-m-d H:i:s');
1671
-				    $aprsdate = strtotime($data['datetime']);
1672
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1673
-				    // Accept data if time <= system time + 20s
1674
-				    //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'])))) {
1675
-				    if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1654
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1655
+					//else echo 'No heading...'."\n";
1656
+					//else $data['heading'] = 0;
1657
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1658
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1659
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1660
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1661
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1662
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1663
+						$data['id_source'] = $id_source;
1664
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1665
+					else $data['format_source'] = 'aprs';
1666
+					$data['source_name'] = $line['source'];
1667
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1668
+					else $data['source_type'] = 'flarm';
1669
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1670
+					$currentdate = date('Y-m-d H:i:s');
1671
+					$aprsdate = strtotime($data['datetime']);
1672
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1673
+					// Accept data if time <= system time + 20s
1674
+					//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'])))) {
1675
+					if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1676 1676
 					$send = $SI->add($data);
1677
-				    } elseif ($data['source_type'] === 'ais') {
1677
+					} elseif ($data['source_type'] === 'ais') {
1678 1678
 					$data['type'] = '';
1679 1679
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1680
-				    } elseif (isset($line['stealth'])) {
1680
+					} elseif (isset($line['stealth'])) {
1681 1681
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1682 1682
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1683
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1684
-					    //$line['symbol'] === 'Balloon' ||
1685
-					    $line['symbol'] === 'Glider' || 
1686
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1687
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1688
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1689
-					    $send = $SI->add($data);
1690
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1691
-					    $line['symbol'] === 'Yacht (Sail)' || 
1692
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1693
-					    $send = $MI->add($data);
1694
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1695
-					    $line['symbol'] === 'Car' || 
1696
-					    $line['symbol'] === 'Ambulance' || 
1697
-					    $line['symbol'] === 'Van' || 
1698
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1699
-					    $line['symbol'] === 'Motorcycle' || 
1700
-					    $line['symbol'] === 'Tractor' || 
1701
-					    $line['symbol'] === 'Police' || 
1702
-					    $line['symbol'] === 'Bike' || 
1703
-					    $line['symbol'] === 'Jogger' || 
1704
-					    $line['symbol'] === 'Horse' || 
1705
-					    $line['symbol'] === 'Bus' || 
1706
-					    $line['symbol'] === 'Jeep' || 
1707
-					    $line['symbol'] === 'Recreational Vehicle' || 
1708
-					    $line['symbol'] === 'Yacht (Sail)' || 
1709
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1710
-					    $line['symbol'] === 'Firetruck' || 
1711
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1712
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1713
-					    $line['symbol'] === 'SUV' ||
1714
-					    $line['symbol'] === 'Snowmobile' ||
1715
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1716
-				    //} 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') {
1683
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1684
+						//$line['symbol'] === 'Balloon' ||
1685
+						$line['symbol'] === 'Glider' || 
1686
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1687
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1688
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1689
+						$send = $SI->add($data);
1690
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1691
+						$line['symbol'] === 'Yacht (Sail)' || 
1692
+						$line['symbol'] === 'Ship (Power Boat)')) {
1693
+						$send = $MI->add($data);
1694
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1695
+						$line['symbol'] === 'Car' || 
1696
+						$line['symbol'] === 'Ambulance' || 
1697
+						$line['symbol'] === 'Van' || 
1698
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1699
+						$line['symbol'] === 'Motorcycle' || 
1700
+						$line['symbol'] === 'Tractor' || 
1701
+						$line['symbol'] === 'Police' || 
1702
+						$line['symbol'] === 'Bike' || 
1703
+						$line['symbol'] === 'Jogger' || 
1704
+						$line['symbol'] === 'Horse' || 
1705
+						$line['symbol'] === 'Bus' || 
1706
+						$line['symbol'] === 'Jeep' || 
1707
+						$line['symbol'] === 'Recreational Vehicle' || 
1708
+						$line['symbol'] === 'Yacht (Sail)' || 
1709
+						$line['symbol'] === 'Ship (Power Boat)' || 
1710
+						$line['symbol'] === 'Firetruck' || 
1711
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1712
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1713
+						$line['symbol'] === 'SUV' ||
1714
+						$line['symbol'] === 'Snowmobile' ||
1715
+						$line['symbol'] === 'Mobile Satellite Station')) {
1716
+					//} 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') {
1717 1717
 				//    } 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') {
1718 1718
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1719 1719
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1720
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1720
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1721 1721
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1722 1722
 					$Source->deleteOldLocationByType('gs');
1723 1723
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1725,7 +1725,7 @@  discard block
 block discarded – undo
1725 1725
 					} else {
1726 1726
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1727 1727
 					}
1728
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1728
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1729 1729
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1730 1730
 					if ($globalDebug) echo '# Weather Station added'."\n";
1731 1731
 					$Source->deleteOldLocationByType('wx');
@@ -1735,7 +1735,7 @@  discard block
 block discarded – undo
1735 1735
 					} else {
1736 1736
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1737 1737
 					}
1738
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1738
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1739 1739
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1740 1740
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1741 1741
 					$Source->deleteOldLocationByType('lightning');
@@ -1744,11 +1744,11 @@  discard block
 block discarded – undo
1744 1744
 					} else {
1745 1745
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1746 1746
 					}
1747
-				    } elseif ($globalDebug) {
1748
-				    	echo '/!\ Not added: '.$buffer."\n";
1749
-				    	print_r($line);
1750
-				    }
1751
-				    unset($data);
1747
+					} elseif ($globalDebug) {
1748
+						echo '/!\ Not added: '.$buffer."\n";
1749
+						print_r($line);
1750
+					}
1751
+					unset($data);
1752 1752
 				}
1753 1753
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1754 1754
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1767,12 +1767,12 @@  discard block
 block discarded – undo
1767 1767
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1768 1768
 					$globalSources[$nb]['last_weather_clean'] = time();
1769 1769
 				}
1770
-			    }
1770
+				}
1771 1771
 			} else {
1772
-			    $line = explode(',', $buffer);
1773
-    			    if (count($line) > 20) {
1774
-    			    	$data['hex'] = $line[4];
1775
-    				/*
1772
+				$line = explode(',', $buffer);
1773
+					if (count($line) > 20) {
1774
+						$data['hex'] = $line[4];
1775
+					/*
1776 1776
     				$data['datetime'] = $line[6].' '.$line[7];
1777 1777
     					date_default_timezone_set($globalTimezone);
1778 1778
     					$datetime = new DateTime($data['datetime']);
@@ -1780,30 +1780,30 @@  discard block
 block discarded – undo
1780 1780
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1781 1781
     					date_default_timezone_set('UTC');
1782 1782
     				*/
1783
-    				// Force datetime to current UTC datetime
1784
-    				date_default_timezone_set('UTC');
1785
-    				$data['datetime'] = date('Y-m-d H:i:s');
1786
-    				$data['ident'] = trim($line[10]);
1787
-    				$data['latitude'] = $line[14];
1788
-    				$data['longitude'] = $line[15];
1789
-    				$data['verticalrate'] = $line[16];
1790
-    				$data['emergency'] = $line[20];
1791
-    				$data['speed'] = $line[12];
1792
-    				$data['squawk'] = $line[17];
1793
-    				$data['altitude'] = $line[11];
1794
-    				$data['heading'] = $line[13];
1795
-    				$data['ground'] = $line[21];
1796
-    				$data['emergency'] = $line[19];
1797
-    				$data['format_source'] = 'sbs';
1783
+					// Force datetime to current UTC datetime
1784
+					date_default_timezone_set('UTC');
1785
+					$data['datetime'] = date('Y-m-d H:i:s');
1786
+					$data['ident'] = trim($line[10]);
1787
+					$data['latitude'] = $line[14];
1788
+					$data['longitude'] = $line[15];
1789
+					$data['verticalrate'] = $line[16];
1790
+					$data['emergency'] = $line[20];
1791
+					$data['speed'] = $line[12];
1792
+					$data['squawk'] = $line[17];
1793
+					$data['altitude'] = $line[11];
1794
+					$data['heading'] = $line[13];
1795
+					$data['ground'] = $line[21];
1796
+					$data['emergency'] = $line[19];
1797
+					$data['format_source'] = 'sbs';
1798 1798
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1799
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1799
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1800 1800
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1801
-    				$data['id_source'] = $id_source;
1802
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1803
-    				else $error = true;
1804
-    				unset($data);
1805
-    			    } else $error = true;
1806
-			    if ($error) {
1801
+					$data['id_source'] = $id_source;
1802
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1803
+					else $error = true;
1804
+					unset($data);
1805
+					} else $error = true;
1806
+				if ($error) {
1807 1807
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1808 1808
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1809 1809
 				} else {
@@ -1819,13 +1819,13 @@  discard block
 block discarded – undo
1819 1819
 					connect_all($sourceer);
1820 1820
 					$sourceer = array();
1821 1821
 				}
1822
-			    }
1822
+				}
1823 1823
 			}
1824 1824
 			// Sleep for xxx microseconds
1825 1825
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1826
-		    } else {
1826
+			} else {
1827 1827
 			if ($format === 'flightgearmp') {
1828
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1828
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1829 1829
 				//@socket_close($r);
1830 1830
 				sleep($globalMinFetch);
1831 1831
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1834,9 +1834,9 @@  discard block
 block discarded – undo
1834 1834
 				break;
1835 1835
 				
1836 1836
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1837
-			    if (isset($tt[$format])) $tt[$format]++;
1838
-			    else $tt[$format] = 0;
1839
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
1837
+				if (isset($tt[$format])) $tt[$format]++;
1838
+				else $tt[$format] = 0;
1839
+				if ($tt[$format] > 30 || $buffer === FALSE) {
1840 1840
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1841 1841
 				//@socket_close($r);
1842 1842
 				sleep(2);
@@ -1847,24 +1847,24 @@  discard block
 block discarded – undo
1847 1847
 				//connect_all($globalSources);
1848 1848
 				$tt[$format]=0;
1849 1849
 				break;
1850
-			    } 
1851
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1850
+				} 
1851
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1852
+			}
1852 1853
 			}
1853
-		    }
1854 1854
 		}
1855
-	    } else {
1855
+		} else {
1856 1856
 		$error = socket_strerror(socket_last_error());
1857 1857
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1858 1858
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1859 1859
 			if (isset($globalDebug)) echo "Restarting...\n";
1860 1860
 			// Restart the script if possible
1861 1861
 			if (is_array($sockets)) {
1862
-			    if ($globalDebug) echo "Shutdown all sockets...";
1862
+				if ($globalDebug) echo "Shutdown all sockets...";
1863 1863
 			    
1864
-			    foreach ($sockets as $sock) {
1864
+				foreach ($sockets as $sock) {
1865 1865
 				@socket_shutdown($sock,2);
1866 1866
 				@socket_close($sock);
1867
-			    }
1867
+				}
1868 1868
 			    
1869 1869
 			}
1870 1870
 			if ($globalDebug) echo "Waiting...";
@@ -1879,15 +1879,15 @@  discard block
 block discarded – undo
1879 1879
 			if ($globalDebug) echo "Restart all connections...";
1880 1880
 			connect_all($globalSources);
1881 1881
 		}
1882
-	    }
1882
+		}
1883 1883
 	}
1884 1884
 	if ($globalDaemon === false) {
1885
-	    if ($globalDebug) echo 'Check all...'."\n";
1886
-	    if (isset($SI)) $SI->checkAll();
1887
-	    if (isset($TI)) $TI->checkAll();
1888
-	    if (isset($MI)) $MI->checkAll();
1885
+		if ($globalDebug) echo 'Check all...'."\n";
1886
+		if (isset($SI)) $SI->checkAll();
1887
+		if (isset($TI)) $TI->checkAll();
1888
+		if (isset($MI)) $MI->checkAll();
1889
+	}
1889 1890
 	}
1890
-    }
1891 1891
 }
1892 1892
 
1893 1893
 ?>
Please login to merge, or discard this patch.