Completed
Push — master ( 7c97e3...5d2224 )
by Yannick
31:05
created
scripts/daemon-spotter.php 2 patches
Indentation   +1205 added lines, -1205 removed lines patch added patch discarded remove patch
@@ -15,65 +15,65 @@  discard block
 block discarded – undo
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) {
18
-    require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19 19
 }
20 20
 if (isset($globalMarine) && $globalMarine) {
21
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
22
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
22
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25 25
 if (!isset($globalDebug)) $globalDebug = FALSE;
26 26
 
27 27
 if ($globalInstalled === FALSE) {
28
-    echo "This script MUST be run after install script. Use your web browser to run install/index.php";
29
-    sleep(5);
30
-    die();
28
+	echo "This script MUST be run after install script. Use your web browser to run install/index.php";
29
+	sleep(5);
30
+	die();
31 31
 }
32 32
 
33 33
 
34 34
 // Check if schema is at latest version
35 35
 $Connection = new Connection();
36 36
 if ($Connection->connectionExists() === false) {
37
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
38
-    exit();
37
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
38
+	exit();
39 39
 }
40 40
 if ($Connection->latest() === false) {
41
-    echo "You MUST update to latest schema. Use your web browser to run install/index.php";
42
-    exit();
41
+	echo "You MUST update to latest schema. Use your web browser to run install/index.php";
42
+	exit();
43 43
 }
44 44
 if (PHP_SAPI != 'cli') {
45
-    echo "This script MUST be called from console, not a web browser.";
45
+	echo "This script MUST be called from console, not a web browser.";
46 46
 //    exit();
47 47
 }
48 48
 
49 49
 // This is to be compatible with old version of settings.php
50 50
 if (!isset($globalSources)) {
51
-    if (isset($globalSBS1Hosts)) {
52
-        //$hosts = $globalSBS1Hosts;
53
-        foreach ($globalSBS1Hosts as $host) {
54
-	    $globalSources[] = array('host' => $host);
55
-    	}
56
-    } else {
57
-        if (!isset($globalSBS1Host)) {
58
-	    echo '$globalSources MUST be defined !';
59
-	    die;
51
+	if (isset($globalSBS1Hosts)) {
52
+		//$hosts = $globalSBS1Hosts;
53
+		foreach ($globalSBS1Hosts as $host) {
54
+		$globalSources[] = array('host' => $host);
55
+		}
56
+	} else {
57
+		if (!isset($globalSBS1Host)) {
58
+		echo '$globalSources MUST be defined !';
59
+		die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62 62
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
63
-    }
63
+	}
64 64
 }
65 65
 
66 66
 $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'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70
-    $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
-    else $globalSources[] = array('host' => $options['s']);
70
+	$globalSources = array();
71
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
+	else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74
-    $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
-    else $globalSources[] = array('host' => $options['source']);
74
+	$globalSources = array();
75
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
+	else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
79 79
 	$globalServerAPRS = TRUE;
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 if (isset($options['idsource'])) $id_source = $options['idsource'];
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115
-    if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
115
+	if ($globalDebug) echo "Using Server Mode\n";
116
+	$SI=new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
126
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
127
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
126
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
127
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
128 128
 }
129 129
 
130 130
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
131 131
 if (isset($globalMarine) && $globalMarine) {
132
-    $AIS = new AIS();
133
-    $MI = new MarineImport($Connection->db);
132
+	$AIS = new AIS();
133
+	$MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136 136
 $SBS=new SBS();
@@ -143,12 +143,12 @@  discard block
 block discarded – undo
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
147
-        global $sockets;
148
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149
-        die("Bye!\n");
150
-    });
151
-    pcntl_signal_dispatch();
146
+	pcntl_signal(SIGINT,  function() {
147
+		global $sockets;
148
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149
+		die("Bye!\n");
150
+	});
151
+	pcntl_signal_dispatch();
152 152
 }
153 153
 
154 154
 // let's try and connect
@@ -158,47 +158,47 @@  discard block
 block discarded – undo
158 158
 $reset = 0;
159 159
 
160 160
 function connect_all($hosts) {
161
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163
-    $reset++;
164
-    if ($globalDebug) echo 'Connect to all...'."\n";
165
-    foreach ($hosts as $id => $value) {
161
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163
+	$reset++;
164
+	if ($globalDebug) echo 'Connect to all...'."\n";
165
+	foreach ($hosts as $id => $value) {
166 166
 	$host = $value['host'];
167 167
 	$udp = false;
168 168
 	$globalSources[$id]['last_exec'] = 0;
169 169
 	// Here we check type of source(s)
170 170
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
-            if (preg_match('/deltadb.txt$/i',$host)) {
172
-        	//$formats[$id] = 'deltadbtxt';
173
-        	$globalSources[$id]['format'] = 'deltadbtxt';
174
-        	//$last_exec['deltadbtxt'] = 0;
175
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
177
-        	//$formats[$id] = 'vatsimtxt';
178
-        	$globalSources[$id]['format'] = 'vatsimtxt';
179
-        	//$last_exec['vatsimtxt'] = 0;
180
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
182
-        	//$formats[$id] = 'aircraftlistjson';
183
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
184
-        	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
187
-        	//$formats[$id] = 'aircraftjson';
188
-        	$globalSources[$id]['format'] = 'aircraftjson';
189
-        	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
-    	    } else if (preg_match('/aircraft$/i',$host)) {
192
-        	//$formats[$id] = 'planefinderclient';
193
-        	$globalSources[$id]['format'] = 'planefinderclient';
194
-        	//$last_exec['aircraftlistjson'] = 0;
195
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
-    	    } else if (preg_match('/opensky/i',$host)) {
197
-        	//$formats[$id] = 'aircraftlistjson';
198
-        	$globalSources[$id]['format'] = 'opensky';
199
-        	//$last_exec['aircraftlistjson'] = 0;
200
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
201
-    	    /*
171
+			if (preg_match('/deltadb.txt$/i',$host)) {
172
+			//$formats[$id] = 'deltadbtxt';
173
+			$globalSources[$id]['format'] = 'deltadbtxt';
174
+			//$last_exec['deltadbtxt'] = 0;
175
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
177
+			//$formats[$id] = 'vatsimtxt';
178
+			$globalSources[$id]['format'] = 'vatsimtxt';
179
+			//$last_exec['vatsimtxt'] = 0;
180
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
182
+			//$formats[$id] = 'aircraftlistjson';
183
+			$globalSources[$id]['format'] = 'aircraftlistjson';
184
+			//$last_exec['aircraftlistjson'] = 0;
185
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
+			} else if (preg_match('/aircraft.json$/i',$host)) {
187
+			//$formats[$id] = 'aircraftjson';
188
+			$globalSources[$id]['format'] = 'aircraftjson';
189
+			//$last_exec['aircraftlistjson'] = 0;
190
+			if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
+			} else if (preg_match('/aircraft$/i',$host)) {
192
+			//$formats[$id] = 'planefinderclient';
193
+			$globalSources[$id]['format'] = 'planefinderclient';
194
+			//$last_exec['aircraftlistjson'] = 0;
195
+			if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
+			} else if (preg_match('/opensky/i',$host)) {
197
+			//$formats[$id] = 'aircraftlistjson';
198
+			$globalSources[$id]['format'] = 'opensky';
199
+			//$last_exec['aircraftlistjson'] = 0;
200
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
201
+			/*
202 202
     	    // Disabled for now, site change source format
203 203
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
204 204
         	//$formats[$id] = 'radarvirtueljson';
@@ -210,130 +210,130 @@  discard block
 block discarded – undo
210 210
         	    exit(0);
211 211
         	}
212 212
     	    */
213
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
214
-        	//$formats[$id] = 'planeupdatefaa';
215
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
216
-        	//$last_exec['planeupdatefaa'] = 0;
217
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
218
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
219
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220
-        	    exit(0);
221
-        	}
222
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
223
-        	//$formats[$id] = 'phpvmacars';
224
-        	$globalSources[$id]['format'] = 'phpvmacars';
225
-        	//$last_exec['phpvmacars'] = 0;
226
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
228
-        	//$formats[$id] = 'phpvmacars';
229
-        	$globalSources[$id]['format'] = 'vaos';
230
-        	//$last_exec['phpvmacars'] = 0;
231
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
233
-        	//$formats[$id] = 'phpvmacars';
234
-        	$globalSources[$id]['format'] = 'vam';
235
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
-            } else if (preg_match('/whazzup/i',$host)) {
237
-        	//$formats[$id] = 'whazzup';
238
-        	$globalSources[$id]['format'] = 'whazzup';
239
-        	//$last_exec['whazzup'] = 0;
240
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
-            } else if (preg_match('/blitzortung/i',$host)) {
242
-        	$globalSources[$id]['format'] = 'blitzortung';
243
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
-            } else if (preg_match('/airwhere/i',$host)) {
245
-        	$globalSources[$id]['format'] = 'airwhere';
246
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
-            } else if (preg_match('/recentpireps/i',$host)) {
248
-        	//$formats[$id] = 'pirepsjson';
249
-        	$globalSources[$id]['format'] = 'pirepsjson';
250
-        	//$last_exec['pirepsjson'] = 0;
251
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
253
-        	//$formats[$id] = 'fr24json';
254
-        	$globalSources[$id]['format'] = 'fr24json';
255
-        	//$last_exec['fr24json'] = 0;
256
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
257
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
258
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259
-        	    exit(0);
260
-        	}
261
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
262
-        	//$formats[$id] = 'fr24json';
263
-        	$globalSources[$id]['format'] = 'myshiptracking';
264
-        	//$last_exec['fr24json'] = 0;
265
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
266
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
267
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
268
-        	    exit(0);
269
-        	}
270
-            //} else if (preg_match('/10001/',$host)) {
271
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272
-        	//$formats[$id] = 'tsv';
273
-        	$globalSources[$id]['format'] = 'tsv';
274
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275
-            }
276
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
279
-    		    if ($idf !== false) {
280
-    			$httpfeeds[$id] = $idf;
281
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
285
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
286
-	    $hostport = explode(':',$host);
287
-	    if (isset($hostport[1])) {
213
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
214
+			//$formats[$id] = 'planeupdatefaa';
215
+			$globalSources[$id]['format'] = 'planeupdatefaa';
216
+			//$last_exec['planeupdatefaa'] = 0;
217
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
218
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
219
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220
+				exit(0);
221
+			}
222
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
223
+			//$formats[$id] = 'phpvmacars';
224
+			$globalSources[$id]['format'] = 'phpvmacars';
225
+			//$last_exec['phpvmacars'] = 0;
226
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
228
+			//$formats[$id] = 'phpvmacars';
229
+			$globalSources[$id]['format'] = 'vaos';
230
+			//$last_exec['phpvmacars'] = 0;
231
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
233
+			//$formats[$id] = 'phpvmacars';
234
+			$globalSources[$id]['format'] = 'vam';
235
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
+			} else if (preg_match('/whazzup/i',$host)) {
237
+			//$formats[$id] = 'whazzup';
238
+			$globalSources[$id]['format'] = 'whazzup';
239
+			//$last_exec['whazzup'] = 0;
240
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
+			} else if (preg_match('/blitzortung/i',$host)) {
242
+			$globalSources[$id]['format'] = 'blitzortung';
243
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
+			} else if (preg_match('/airwhere/i',$host)) {
245
+			$globalSources[$id]['format'] = 'airwhere';
246
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
+			} else if (preg_match('/recentpireps/i',$host)) {
248
+			//$formats[$id] = 'pirepsjson';
249
+			$globalSources[$id]['format'] = 'pirepsjson';
250
+			//$last_exec['pirepsjson'] = 0;
251
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
253
+			//$formats[$id] = 'fr24json';
254
+			$globalSources[$id]['format'] = 'fr24json';
255
+			//$last_exec['fr24json'] = 0;
256
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
257
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
258
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259
+				exit(0);
260
+			}
261
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
262
+			//$formats[$id] = 'fr24json';
263
+			$globalSources[$id]['format'] = 'myshiptracking';
264
+			//$last_exec['fr24json'] = 0;
265
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
266
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
267
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
268
+				exit(0);
269
+			}
270
+			//} else if (preg_match('/10001/',$host)) {
271
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272
+			//$formats[$id] = 'tsv';
273
+			$globalSources[$id]['format'] = 'tsv';
274
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275
+			}
276
+		} elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277
+			if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
279
+				if ($idf !== false) {
280
+				$httpfeeds[$id] = $idf;
281
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283
+			} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284
+			elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
285
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
286
+		$hostport = explode(':',$host);
287
+		if (isset($hostport[1])) {
288 288
 		$port = $hostport[1];
289 289
 		$hostn = $hostport[0];
290
-	    } else {
290
+		} else {
291 291
 		$port = $globalSources[$id]['port'];
292 292
 		$hostn = $globalSources[$id]['host'];
293
-	    }
294
-	    $Common = new Common();
295
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
296
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
297
-    	    } else {
298
-    		$udp = true;
299
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
300
-	    }
301
-	    if ($s) {
302
-    	        $sockets[$id] = $s;
303
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
304
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
293
+		}
294
+		$Common = new Common();
295
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
296
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
297
+			} else {
298
+			$udp = true;
299
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
300
+		}
301
+		if ($s) {
302
+				$sockets[$id] = $s;
303
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
304
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
305 305
 			//$formats[$id] = 'aprs';
306 306
 			$globalSources[$id]['format'] = 'aprs';
307 307
 			//$aprs_connect = 0;
308 308
 			//$use_aprs = true;
309
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
309
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
310 310
 			$globalSources[$id]['format'] = 'vrstcp';
311
-    		    } elseif ($port == '10001') {
312
-        		//$formats[$id] = 'tsv';
313
-        		$globalSources[$id]['format'] = 'tsv';
314
-		    } elseif ($port == '30002') {
315
-        		//$formats[$id] = 'raw';
316
-        		$globalSources[$id]['format'] = 'raw';
317
-		    } elseif ($port == '5001') {
318
-        		//$formats[$id] = 'raw';
319
-        		$globalSources[$id]['format'] = 'flightgearmp';
320
-		    } elseif ($port == '30005') {
311
+				} elseif ($port == '10001') {
312
+				//$formats[$id] = 'tsv';
313
+				$globalSources[$id]['format'] = 'tsv';
314
+			} elseif ($port == '30002') {
315
+				//$formats[$id] = 'raw';
316
+				$globalSources[$id]['format'] = 'raw';
317
+			} elseif ($port == '5001') {
318
+				//$formats[$id] = 'raw';
319
+				$globalSources[$id]['format'] = 'flightgearmp';
320
+			} elseif ($port == '30005') {
321 321
 			// Not yet supported
322
-        		//$formats[$id] = 'beast';
323
-        		$globalSources[$id]['format'] = 'beast';
324
-		    //} else $formats[$id] = 'sbs';
325
-		    } else $globalSources[$id]['format'] = 'sbs';
326
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
322
+				//$formats[$id] = 'beast';
323
+				$globalSources[$id]['format'] = 'beast';
324
+			//} else $formats[$id] = 'sbs';
325
+			} else $globalSources[$id]['format'] = 'sbs';
326
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
327 327
 		}
328 328
 		if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
329 329
 		elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
330
-            } else {
330
+			} else {
331 331
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
332 332
 		sleep(10);
333 333
 		connect_all($hosts);
334
-    	    }
335
-        }
336
-    }
334
+			}
335
+		}
336
+	}
337 337
 }
338 338
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
339 339
 
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 //connect_all($globalSources);
357 357
 
358 358
 if (isset($globalProxy) && $globalProxy) {
359
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
359
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
360 360
 } else {
361
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
361
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
362 362
 }
363 363
 
364 364
 // APRS Configuration
@@ -367,21 +367,21 @@  discard block
 block discarded – undo
367 367
 	die;
368 368
 }
369 369
 foreach ($globalSources as $key => $source) {
370
-    if (!isset($source['format'])) {
371
-        $globalSources[$key]['format'] = 'auto';
372
-    }
373
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
374
-        unset($globalSources[$key]);
375
-    }
370
+	if (!isset($source['format'])) {
371
+		$globalSources[$key]['format'] = 'auto';
372
+	}
373
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
374
+		unset($globalSources[$key]);
375
+	}
376 376
 }
377 377
 connect_all($globalSources);
378 378
 foreach ($globalSources as $key => $source) {
379
-    if (isset($source['format']) && $source['format'] == 'aprs') {
379
+	if (isset($source['format']) && $source['format'] == 'aprs') {
380 380
 	$aprs_connect = 0;
381 381
 	$use_aprs = true;
382 382
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
383 383
 	break;
384
-    }
384
+	}
385 385
 }
386 386
 
387 387
 if ($use_aprs) {
@@ -422,173 +422,173 @@  discard block
 block discarded – undo
422 422
 
423 423
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
424 424
 while ($i > 0) {
425
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
425
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
426 426
 
427
-    if (!$globalDaemon) $i = $endtime-time();
428
-    // Delete old ATC
429
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
427
+	if (!$globalDaemon) $i = $endtime-time();
428
+	// Delete old ATC
429
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
430 430
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
431
-        $ATC->deleteOldATC();
432
-    }
431
+		$ATC->deleteOldATC();
432
+	}
433 433
     
434
-    if (count($last_exec) == count($globalSources)) {
434
+	if (count($last_exec) == count($globalSources)) {
435 435
 	$max = $globalMinFetch;
436 436
 	foreach ($last_exec as $last) {
437
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
437
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
438 438
 	}
439 439
 	if ($max < $globalMinFetch) {
440
-	    if ($globalDebug) echo 'Sleeping...'."\n";
441
-	    sleep($globalMinFetch-$max+2);
440
+		if ($globalDebug) echo 'Sleeping...'."\n";
441
+		sleep($globalMinFetch-$max+2);
442
+	}
442 443
 	}
443
-    }
444 444
 
445 445
     
446
-    //foreach ($formats as $id => $value) {
447
-    foreach ($globalSources as $id => $value) {
446
+	//foreach ($formats as $id => $value) {
447
+	foreach ($globalSources as $id => $value) {
448 448
 	date_default_timezone_set('UTC');
449 449
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
450 450
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
451 451
 	if ($value['format'] === 'deltadbtxt' && 
452
-	    (
452
+		(
453 453
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
454 454
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
455
-	    )
455
+		)
456 456
 	) {
457
-        //$buffer = $Common->getData($hosts[$id]);
458
-        $buffer = $Common->getData($value['host']);
459
-        if ($buffer != '') $reset = 0;
460
-        $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
461
-        $buffer = explode('\n', $buffer);
462
-        foreach ($buffer as $line) {
463
-            if ($line != '' && count($line) > 7) {
464
-                $line = explode(',', $line);
465
-                $data = array();
466
-                $data['hex'] = $line[1]; // hex
467
-                $data['ident'] = $line[2]; // ident
468
-                if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
469
-                if (isset($line[4])) $data['speed'] = $line[4]; // speed
470
-                if (isset($line[5])) $data['heading'] = $line[5]; // heading
471
-                if (isset($line[6])) $data['latitude'] = $line[6]; // lat
472
-                if (isset($line[7])) $data['longitude'] = $line[7]; // long
473
-                $data['verticalrate'] = ''; // vertical rate
474
-                //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
475
-                $data['emergency'] = ''; // emergency
476
-                $data['datetime'] = date('Y-m-d H:i:s');
477
-                $data['format_source'] = 'deltadbtxt';
478
-                $data['id_source'] = $id_source;
479
-                if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
480
-                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
481
-                if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
482
-                $SI->add($data);
483
-                unset($data);
484
-            }
485
-        }
486
-        $last_exec[$id]['last'] = time();
487
-    } elseif ($value['format'] === 'radarcapejson' &&
488
-            (
489
-                (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
490
-                (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
491
-            )
492
-        ) {
493
-            //$buffer = $Common->getData($hosts[$id]);
494
-            $buffer = $Common->getData($value['host']);
495
-            if ($buffer != '') {
496
-                $all_data = json_decode($buffer,true);
497
-                foreach ($all_data as $line) {
498
-                    $data = array();
499
-                    $data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
500
-                    $data['hex'] = $line['hex']; // hex
501
-                    $data['ident'] = $line['fli']; // ident
502
-                    $data['altitude'] = $line['alt']; // altitude
503
-                    $data['speed'] = $line['spd']; // speed
504
-                    $data['heading'] = $line['trk']; // heading
505
-                    $data['latitude'] = $line['lat']; // lat
506
-                    $data['longitude'] = $line['lon']; // long
507
-                    $data['verticalrate'] = $line['vrt']; // vertical rate
508
-                    $data['squawk'] = $line['squ']; // squawk
509
-                    $data['ground'] = $line['gda']; // ground
510
-                    $data['registration'] = $line['reg'];
511
-                    //$data['emergency'] = ''; // emergency
512
-                    $data['datetime'] = date('Y-m-d H:i:s');
513
-                    $data['format_source'] = 'radarcapejson';
514
-                    $data['id_source'] = $id_source;
515
-                    if (isset($value['name']) && $value['name'] != '') {
516
-                        if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
517
-                        else $data['source_name'] = $value['name'];
518
-                    } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
519
-                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
520
-                    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
457
+		//$buffer = $Common->getData($hosts[$id]);
458
+		$buffer = $Common->getData($value['host']);
459
+		if ($buffer != '') $reset = 0;
460
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
461
+		$buffer = explode('\n', $buffer);
462
+		foreach ($buffer as $line) {
463
+			if ($line != '' && count($line) > 7) {
464
+				$line = explode(',', $line);
465
+				$data = array();
466
+				$data['hex'] = $line[1]; // hex
467
+				$data['ident'] = $line[2]; // ident
468
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
469
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
470
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
471
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
472
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
473
+				$data['verticalrate'] = ''; // vertical rate
474
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
475
+				$data['emergency'] = ''; // emergency
476
+				$data['datetime'] = date('Y-m-d H:i:s');
477
+				$data['format_source'] = 'deltadbtxt';
478
+				$data['id_source'] = $id_source;
479
+				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
480
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
481
+				if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
482
+				$SI->add($data);
483
+				unset($data);
484
+			}
485
+		}
486
+		$last_exec[$id]['last'] = time();
487
+	} elseif ($value['format'] === 'radarcapejson' &&
488
+			(
489
+				(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
490
+				(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
491
+			)
492
+		) {
493
+			//$buffer = $Common->getData($hosts[$id]);
494
+			$buffer = $Common->getData($value['host']);
495
+			if ($buffer != '') {
496
+				$all_data = json_decode($buffer,true);
497
+				foreach ($all_data as $line) {
498
+					$data = array();
499
+					$data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
500
+					$data['hex'] = $line['hex']; // hex
501
+					$data['ident'] = $line['fli']; // ident
502
+					$data['altitude'] = $line['alt']; // altitude
503
+					$data['speed'] = $line['spd']; // speed
504
+					$data['heading'] = $line['trk']; // heading
505
+					$data['latitude'] = $line['lat']; // lat
506
+					$data['longitude'] = $line['lon']; // long
507
+					$data['verticalrate'] = $line['vrt']; // vertical rate
508
+					$data['squawk'] = $line['squ']; // squawk
509
+					$data['ground'] = $line['gda']; // ground
510
+					$data['registration'] = $line['reg'];
511
+					//$data['emergency'] = ''; // emergency
512
+					$data['datetime'] = date('Y-m-d H:i:s');
513
+					$data['format_source'] = 'radarcapejson';
514
+					$data['id_source'] = $id_source;
515
+					if (isset($value['name']) && $value['name'] != '') {
516
+						if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
517
+						else $data['source_name'] = $value['name'];
518
+					} elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
519
+					if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
520
+					if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
521 521
 
522
-                    $SI->add($data);
523
-                    unset($data);
524
-                }
525
-            }
526
-            $last_exec[$id]['last'] = time();
522
+					$SI->add($data);
523
+					unset($data);
524
+				}
525
+			}
526
+			$last_exec[$id]['last'] = time();
527 527
 	} elseif ($value['format'] === 'aisnmeatxt' && 
528
-	    (
528
+		(
529 529
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
530 530
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
531
-	    )
531
+		)
532 532
 	) {
533
-	    date_default_timezone_set('CET');
534
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
535
-	    date_default_timezone_set('UTC');
536
-	    if ($buffer != '') $reset = 0;
537
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
538
-	    $buffer = explode('\n',$buffer);
539
-	    foreach ($buffer as $line) {
533
+		date_default_timezone_set('CET');
534
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
535
+		date_default_timezone_set('UTC');
536
+		if ($buffer != '') $reset = 0;
537
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
538
+		$buffer = explode('\n',$buffer);
539
+		foreach ($buffer as $line) {
540 540
 		if ($line != '') {
541
-		    //echo "'".$line."'\n";
542
-		    $add = false;
543
-		    $ais_data = $AIS->parse_line(trim($line));
544
-		    $data = array();
545
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
546
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
547
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
548
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
549
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
550
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
551
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
552
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
553
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
554
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
555
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
556
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
557
-		    if (isset($ais_data['timestamp'])) {
541
+			//echo "'".$line."'\n";
542
+			$add = false;
543
+			$ais_data = $AIS->parse_line(trim($line));
544
+			$data = array();
545
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
546
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
547
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
548
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
549
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
550
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
551
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
552
+			if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
553
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
554
+			if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
555
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
556
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
557
+			if (isset($ais_data['timestamp'])) {
558 558
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
559 559
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
560
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
561
-			    $add = true;
560
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
561
+				$add = true;
562 562
 			}
563
-		    } else {
563
+			} else {
564 564
 			$data['datetime'] = date('Y-m-d H:i:s');
565 565
 			$add = true;
566
-		    }
567
-		    $data['format_source'] = 'aisnmeatxt';
568
-    		    $data['id_source'] = $id_source;
569
-		    //print_r($data);
570
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
571
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
572
-		    unset($data);
566
+			}
567
+			$data['format_source'] = 'aisnmeatxt';
568
+				$data['id_source'] = $id_source;
569
+			//print_r($data);
570
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
571
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
572
+			unset($data);
573 573
 		}
574
-    	    }
575
-    	    $last_exec[$id]['last'] = time();
574
+			}
575
+			$last_exec[$id]['last'] = time();
576 576
 	} elseif ($value['format'] === 'aisnmeahttp') {
577
-	    $arr = $httpfeeds;
578
-	    $w = $e = null;
577
+		$arr = $httpfeeds;
578
+		$w = $e = null;
579 579
 	    
580
-	    if (isset($arr[$id])) {
580
+		if (isset($arr[$id])) {
581 581
 		$nn = stream_select($arr,$w,$e,$timeout);
582 582
 		if ($nn > 0) {
583
-		    foreach ($httpfeeds as $feed) {
583
+			foreach ($httpfeeds as $feed) {
584 584
 			$buffer = stream_get_line($feed,2000,"\n");
585 585
 			if ($buffer === FALSE) {
586
-			    connect_all($globalSources);
586
+				connect_all($globalSources);
587 587
 			}
588 588
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
589 589
 			$buffer = explode('\n',$buffer);
590 590
 			foreach ($buffer as $line) {
591
-			    if ($line != '') {
591
+				if ($line != '') {
592 592
 				$ais_data = $AIS->parse_line(trim($line));
593 593
 				$data = array();
594 594
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -606,117 +606,117 @@  discard block
 block discarded – undo
606 606
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
607 607
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
608 608
 				if (isset($ais_data['timestamp'])) {
609
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
609
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
610 610
 				} else {
611
-				    $data['datetime'] = date('Y-m-d H:i:s');
611
+					$data['datetime'] = date('Y-m-d H:i:s');
612 612
 				}
613 613
 				$data['format_source'] = 'aisnmeahttp';
614 614
 				$data['id_source'] = $id_source;
615 615
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
616 616
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
617 617
 				unset($data);
618
-			    }
618
+				}
619
+			}
619 620
 			}
620
-		    }
621 621
 		} else {
622
-		    $format = $value['format'];
623
-		    if (isset($tt[$format])) $tt[$format]++;
624
-		    else $tt[$format] = 0;
625
-		    if ($tt[$format] > 30) {
622
+			$format = $value['format'];
623
+			if (isset($tt[$format])) $tt[$format]++;
624
+			else $tt[$format] = 0;
625
+			if ($tt[$format] > 30) {
626 626
 			if ($globalDebug) echo 'Reconnect...'."\n";
627 627
 			sleep(2);
628 628
 			//$sourceeen[] = $value;
629 629
 			//connect_all($sourceeen);
630 630
 			//$sourceeen = array();
631 631
 			connect_all($globalSources);
632
-		    }
632
+			}
633
+		}
633 634
 		}
634
-	    }
635 635
 	} elseif ($value['format'] === 'myshiptracking' && 
636
-	    (
636
+		(
637 637
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
638 638
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
639
-	    )
639
+		)
640 640
 	) {
641
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
642
-	    if ($buffer != '') {
641
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
642
+		if ($buffer != '') {
643 643
 		//echo $buffer;
644 644
 		$all_data = json_decode($buffer,true);
645 645
 		//print_r($all_data);
646 646
 		if (isset($all_data[0]['DATA'])) {
647
-		    foreach ($all_data[0]['DATA'] as $line) {
647
+			foreach ($all_data[0]['DATA'] as $line) {
648 648
 			if ($line != '') {
649
-			    $data = array();
650
-			    $data['ident'] = $line['NAME'];
651
-			    $data['mmsi'] = $line['MMSI'];
652
-			    if (strlen($data['mmsi']) > 9) {
649
+				$data = array();
650
+				$data['ident'] = $line['NAME'];
651
+				$data['mmsi'] = $line['MMSI'];
652
+				if (strlen($data['mmsi']) > 9) {
653 653
 				$data['mmsi'] = substr($data['mmsi'],-9);
654
-			    }
655
-			    $data['speed'] = $line['SOG'];
656
-			    $data['heading'] = $line['COG'];
657
-			    $data['latitude'] = $line['LAT'];
658
-			    $data['longitude'] = $line['LNG'];
659
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
660
-			    //$data['type_id'] = $line['TYPE'];
661
-			    $data['imo'] = $line['IMO'];
662
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
663
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
664
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
665
-			    $data['format_source'] = 'myshiptracking';
666
-			    $data['id_source'] = $id_source;
667
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
668
-			    $MI->add($data);
669
-			    unset($data);
654
+				}
655
+				$data['speed'] = $line['SOG'];
656
+				$data['heading'] = $line['COG'];
657
+				$data['latitude'] = $line['LAT'];
658
+				$data['longitude'] = $line['LNG'];
659
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
660
+				//$data['type_id'] = $line['TYPE'];
661
+				$data['imo'] = $line['IMO'];
662
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
663
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
664
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
665
+				$data['format_source'] = 'myshiptracking';
666
+				$data['id_source'] = $id_source;
667
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
668
+				$MI->add($data);
669
+				unset($data);
670
+			}
670 671
 			}
671
-		    }
672 672
 		}
673
-	    }
674
-	    $last_exec[$id]['last'] = time();
673
+		}
674
+		$last_exec[$id]['last'] = time();
675 675
 	} elseif ($value['format'] === 'boatbeaconapp' && 
676
-	    (
676
+		(
677 677
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
678 678
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
679
-	    )
679
+		)
680 680
 	) {
681
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
682
-	    if ($buffer != '') {
681
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
682
+		if ($buffer != '') {
683 683
 		$all_data = json_decode($buffer,true);
684 684
 		if (isset($all_data[0]['mmsi'])) {
685
-		    foreach ($all_data as $line) {
685
+			foreach ($all_data as $line) {
686 686
 			if ($line != '') {
687
-			    $data = array();
688
-			    $data['ident'] = $line['shipname'];
689
-			    $data['callsign'] = $line['callsign'];
690
-			    $data['mmsi'] = substr($line['mmsi'],-9);
691
-			    $data['speed'] = $line['sog'];
692
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
693
-			    $data['latitude'] = $line['latitude'];
694
-			    $data['longitude'] = $line['longitude'];
695
-			    $data['type_id'] = $line['shiptype'];
696
-			    $data['arrival_code'] = $line['destination'];
697
-			    $data['datetime'] = $line['time'];
698
-			    $data['format_source'] = 'boatbeaconapp';
699
-			    $data['id_source'] = $id_source;
700
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
701
-			    $MI->add($data);
702
-			    unset($data);
687
+				$data = array();
688
+				$data['ident'] = $line['shipname'];
689
+				$data['callsign'] = $line['callsign'];
690
+				$data['mmsi'] = substr($line['mmsi'],-9);
691
+				$data['speed'] = $line['sog'];
692
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
693
+				$data['latitude'] = $line['latitude'];
694
+				$data['longitude'] = $line['longitude'];
695
+				$data['type_id'] = $line['shiptype'];
696
+				$data['arrival_code'] = $line['destination'];
697
+				$data['datetime'] = $line['time'];
698
+				$data['format_source'] = 'boatbeaconapp';
699
+				$data['id_source'] = $id_source;
700
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
701
+				$MI->add($data);
702
+				unset($data);
703
+			}
703 704
 			}
704
-		    }
705 705
 		}
706 706
 		
707
-	    }
708
-    	    $last_exec[$id]['last'] = time();
707
+		}
708
+			$last_exec[$id]['last'] = time();
709 709
 	} elseif ($value['format'] === 'boatnerd' && 
710
-	    (
710
+		(
711 711
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
712 712
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
713
-	    )
713
+		)
714 714
 	) {
715
-	    $buffer = $Common->getData($value['host']);
716
-	    if ($buffer != '') {
715
+		$buffer = $Common->getData($value['host']);
716
+		if ($buffer != '') {
717 717
 		$all_data = json_decode($buffer,true);
718 718
 		if (isset($all_data['features'][0]['id'])) {
719
-		    foreach ($all_data['features'] as $line) {
719
+			foreach ($all_data['features'] as $line) {
720 720
 			print_r($line);
721 721
 			$data = array();
722 722
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -736,75 +736,75 @@  discard block
 block discarded – undo
736 736
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
737 737
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
738 738
 			unset($data);
739
-		    }
739
+			}
740 740
 		}
741 741
 		
742
-	    }
743
-    	    $last_exec[$id]['last'] = time();
742
+		}
743
+			$last_exec[$id]['last'] = time();
744 744
 	} elseif ($value['format'] === 'shipplotter' && 
745
-	    (
745
+		(
746 746
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
747 747
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
748
-	    )
748
+		)
749 749
 	) {
750
-	    if ($globalDebug) echo 'download...';
751
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
752
-	    if ($globalDebug) echo 'done !'."\n";
753
-	    // FIXME: Need more work
754
-	    if ($buffer != '') $reset = 0;
755
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
756
-	    $buffer = explode('\n',$buffer);
757
-	    foreach ($buffer as $line) {
750
+		if ($globalDebug) echo 'download...';
751
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
752
+		if ($globalDebug) echo 'done !'."\n";
753
+		// FIXME: Need more work
754
+		if ($buffer != '') $reset = 0;
755
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
756
+		$buffer = explode('\n',$buffer);
757
+		foreach ($buffer as $line) {
758 758
 		if ($line != '') {
759
-		    $data = array();
760
-		    //echo $line."\n";
761
-		    $data['mmsi'] = (int)substr($line,0,9);
762
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
763
-		    $data['status_id'] = substr($line,21,2);
764
-		    $data['type_id'] = substr($line,24,3);
765
-		    $data['latitude'] = substr($line,29,9);
766
-		    $data['longitude'] = substr($line,41,9);
767
-		    $data['speed'] = round(substr($line,51,5));
768
-		    //$data['course'] = substr($line,57,5);
769
-		    $data['heading'] = round(substr($line,63,3));
770
-		    //$data['draft'] = substr($line,67,4);
771
-		    //$data['length'] = substr($line,72,3);
772
-		    //$data['beam'] = substr($line,76,2);
773
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
774
-		    //$data['callsign'] = trim(substr($line,100,7);
775
-		    $data['arrival_code'] = substr($line,108,20);
776
-		    //$data['etaDate'] = substr($line,129,5);
777
-		    //$data['etaTime'] = substr($line,135,5);
778
-		    $data['format_source'] = 'shipplotter';
779
-    		    $data['id_source'] = $id_source;
780
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
781
-		    //print_r($data);
782
-		    //echo 'Add...'."\n";
783
-		    $MI->add($data);
784
-		    unset($data);
759
+			$data = array();
760
+			//echo $line."\n";
761
+			$data['mmsi'] = (int)substr($line,0,9);
762
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
763
+			$data['status_id'] = substr($line,21,2);
764
+			$data['type_id'] = substr($line,24,3);
765
+			$data['latitude'] = substr($line,29,9);
766
+			$data['longitude'] = substr($line,41,9);
767
+			$data['speed'] = round(substr($line,51,5));
768
+			//$data['course'] = substr($line,57,5);
769
+			$data['heading'] = round(substr($line,63,3));
770
+			//$data['draft'] = substr($line,67,4);
771
+			//$data['length'] = substr($line,72,3);
772
+			//$data['beam'] = substr($line,76,2);
773
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
774
+			//$data['callsign'] = trim(substr($line,100,7);
775
+			$data['arrival_code'] = substr($line,108,20);
776
+			//$data['etaDate'] = substr($line,129,5);
777
+			//$data['etaTime'] = substr($line,135,5);
778
+			$data['format_source'] = 'shipplotter';
779
+				$data['id_source'] = $id_source;
780
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
781
+			//print_r($data);
782
+			//echo 'Add...'."\n";
783
+			$MI->add($data);
784
+			unset($data);
785 785
 		}
786
-    	    }
787
-    	    $last_exec[$id]['last'] = time();
786
+			}
787
+			$last_exec[$id]['last'] = time();
788 788
 	} elseif ($value['format'] === 'sailaway' && 
789
-	    (
789
+		(
790 790
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > 5*60))
791
-	    )
791
+		)
792 792
 	) {
793
-	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
793
+		if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
794 794
 		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
795 795
 		//echo $authsailaway;
796 796
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
797 797
 		if (isset($setcookie[1][0])) {
798
-		    $sailaway_authcookie = $setcookie[1][0];
798
+			$sailaway_authcookie = $setcookie[1][0];
799
+		}
799 800
 		}
800
-	    }
801 801
 
802
-	    if ($globalDebug) echo '! Download... ';
803
-	    for ($i =0; $i <= 1; $i++) {
802
+		if ($globalDebug) echo '! Download... ';
803
+		for ($i =0; $i <= 1; $i++) {
804 804
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
805 805
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
806
-	    if ($globalDebug) echo 'done'."\n";
807
-	    if ($buffer != '') {
806
+		if ($globalDebug) echo 'done'."\n";
807
+		if ($buffer != '') {
808 808
 		$all_data = json_decode($buffer,true);
809 809
 		if (isset($all_data['missions'])) {
810 810
 			foreach ($all_data['missions'] as $mission) {
@@ -825,19 +825,19 @@  discard block
 block discarded – undo
825 825
 					//print_r($race_data);
826 826
 					unset($racebuffer);
827 827
 					if (isset($race_data['mission'])) {
828
-					    $datar = array();
829
-					    $datar['id'] = $mission['misnr'];
830
-					    $datar['desc'] = $race_data['mission']['misdescr'];
831
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
832
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
833
-					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
834
-					    $markers = array();
835
-					    foreach ($race_data['mission']['course'] as $course) {
828
+						$datar = array();
829
+						$datar['id'] = $mission['misnr'];
830
+						$datar['desc'] = $race_data['mission']['misdescr'];
831
+						$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
832
+						$datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
833
+						$datar['startdate'] = $race_data['mission']['misstartdatetime'];
834
+						$markers = array();
835
+						foreach ($race_data['mission']['course'] as $course) {
836 836
 						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
837
-					    }
838
-					    $datar['markers'] = json_encode($markers);
839
-					    //print_r($datar);
840
-					    $MI->race_add($datar);
837
+						}
838
+						$datar['markers'] = json_encode($markers);
839
+						//print_r($datar);
840
+						$MI->race_add($datar);
841 841
 					}
842 842
 				}
843 843
 				if ($bufferm != '') {
@@ -902,35 +902,35 @@  discard block
 block discarded – undo
902 902
 				sleep(30);
903 903
 			}
904 904
 		}
905
-	    }
906
-	    sleep(5);
907
-	    }
908
-    	    $last_exec[$id]['last'] = time();
905
+		}
906
+		sleep(5);
907
+		}
908
+			$last_exec[$id]['last'] = time();
909 909
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
910 910
 	} elseif (
911
-	    (
911
+		(
912 912
 		$value['format'] === 'whazzup' && 
913 913
 		(
914
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
915
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
914
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
915
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
916 916
 		)
917
-	    ) || (
917
+		) || (
918 918
 		$value['format'] === 'vatsimtxt' && 
919 919
 		(
920
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
921
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
920
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
921
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
922
+		)
922 923
 		)
923
-	    )
924 924
 	) {
925
-	    //$buffer = $Common->getData($hosts[$id]);
926
-	    $buffer = $Common->getData($value['host']);
927
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
928
-	    $buffer = explode('\n',$buffer);
929
-	    $reset = 0;
930
-	    foreach ($buffer as $line) {
931
-    		if ($line != '') {
932
-    		    $line = explode(':', $line);
933
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
925
+		//$buffer = $Common->getData($hosts[$id]);
926
+		$buffer = $Common->getData($value['host']);
927
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
928
+		$buffer = explode('\n',$buffer);
929
+		$reset = 0;
930
+		foreach ($buffer as $line) {
931
+			if ($line != '') {
932
+				$line = explode(':', $line);
933
+				if (count($line) > 30 && $line[0] != 'callsign') {
934 934
 			$data = array();
935 935
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
936 936
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -943,37 +943,37 @@  discard block
 block discarded – undo
943 943
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
944 944
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
945 945
 			$data['latitude'] = $line[5]; // lat
946
-	        	$data['longitude'] = $line[6]; // long
947
-	        	$data['verticalrate'] = ''; // vertical rate
948
-	        	$data['squawk'] = ''; // squawk
949
-	        	$data['emergency'] = ''; // emergency
950
-	        	$data['waypoints'] = $line[30];
946
+				$data['longitude'] = $line[6]; // long
947
+				$data['verticalrate'] = ''; // vertical rate
948
+				$data['squawk'] = ''; // squawk
949
+				$data['emergency'] = ''; // emergency
950
+				$data['waypoints'] = $line[30];
951 951
 			$data['datetime'] = date('Y-m-d H:i:s');
952 952
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
953 953
 			//if (isset($line[37])) $data['last_update'] = $line[37];
954
-		        $data['departure_airport_icao'] = $line[11];
955
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
956
-		        $data['arrival_airport_icao'] = $line[13];
954
+				$data['departure_airport_icao'] = $line[11];
955
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
956
+				$data['arrival_airport_icao'] = $line[13];
957 957
 			$data['frequency'] = $line[4];
958 958
 			$data['type'] = $line[18];
959 959
 			$data['range'] = $line[19];
960 960
 			if (isset($line[35])) $data['info'] = $line[35];
961
-    			$data['id_source'] = $id_source;
962
-	    		//$data['arrival_airport_time'] = ;
963
-	    		if ($line[9] != '') {
964
-	    		    $aircraft_data = explode('/',$line[9]);
965
-	    		    if (isset($aircraft_data[1])) {
966
-	    			$data['aircraft_icao'] = $aircraft_data[1];
967
-	    		    }
968
-        		}
969
-	    		/*
961
+				$data['id_source'] = $id_source;
962
+				//$data['arrival_airport_time'] = ;
963
+				if ($line[9] != '') {
964
+					$aircraft_data = explode('/',$line[9]);
965
+					if (isset($aircraft_data[1])) {
966
+					$data['aircraft_icao'] = $aircraft_data[1];
967
+					}
968
+				}
969
+				/*
970 970
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
971 971
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
972 972
 	    		*/
973
-	    		$data['format_source'] = $value['format'];
973
+				$data['format_source'] = $value['format'];
974 974
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
975 975
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
976
-    			if ($line[3] === 'PILOT') $SI->add($data);
976
+				if ($line[3] === 'PILOT') $SI->add($data);
977 977
 			elseif ($line[3] === 'ATC') {
978 978
 				//print_r($data);
979 979
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -994,21 +994,21 @@  discard block
 block discarded – undo
994 994
 					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']);
995 995
 				}
996 996
 			}
997
-    			unset($data);
998
-    		    }
999
-    		}
1000
-    	    }
1001
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
1002
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
1003
-    	    $last_exec[$id]['last'] = time();
1004
-    	} elseif ($value['format'] === 'airwhere' && 
1005
-    	    (
1006
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1007
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1008
-    	    )
1009
-    	) {
1010
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1011
-	    if ($buffer != '') {
997
+				unset($data);
998
+				}
999
+			}
1000
+			}
1001
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
1002
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
1003
+			$last_exec[$id]['last'] = time();
1004
+		} elseif ($value['format'] === 'airwhere' && 
1005
+			(
1006
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1007
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1008
+			)
1009
+		) {
1010
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1011
+		if ($buffer != '') {
1012 1012
 		$all_data = simplexml_load_string($buffer);
1013 1013
 		foreach($all_data->children() as $childdata) {
1014 1014
 			$data = array();
@@ -1030,10 +1030,10 @@  discard block
 block discarded – undo
1030 1030
 			$SI->add($data);
1031 1031
 			unset($data);
1032 1032
 		}
1033
-	    }
1034
-	    $Source->deleteOldLocationByType('gs');
1035
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1036
-	    if ($buffer != '') {
1033
+		}
1034
+		$Source->deleteOldLocationByType('gs');
1035
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1036
+		if ($buffer != '') {
1037 1037
 		$all_data = simplexml_load_string($buffer);
1038 1038
 		foreach($all_data->children() as $childdata) {
1039 1039
 			$data = array();
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
 			}
1052 1052
 			unset($data);
1053 1053
 		}
1054
-	    }
1055
-	    $last_exec[$id]['last'] = time();
1054
+		}
1055
+		$last_exec[$id]['last'] = time();
1056 1056
 	/*
1057 1057
 	} if ($value['format'] === 'aircraftlistjson') {
1058 1058
 	    print_r($globalSources);
@@ -1060,17 +1060,17 @@  discard block
 block discarded – undo
1060 1060
 	    echo $globalMinFetch;
1061 1061
 	*/
1062 1062
 	} elseif ($value['format'] === 'aircraftlistjson' && 
1063
-	    (
1063
+		(
1064 1064
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1065 1065
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1066
-	    )
1066
+		)
1067 1067
 	) {
1068
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1069
-	    if ($buffer != '') {
1070
-	        $all_data = json_decode($buffer,true);
1068
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
1069
+		if ($buffer != '') {
1070
+			$all_data = json_decode($buffer,true);
1071 1071
 		if (isset($all_data['acList'])) {
1072
-		    $reset = 0;
1073
-		    foreach ($all_data['acList'] as $line) {
1072
+			$reset = 0;
1073
+			foreach ($all_data['acList'] as $line) {
1074 1074
 			$data = array();
1075 1075
 			$data['hex'] = $line['Icao']; // hex
1076 1076
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1093,10 +1093,10 @@  discard block
 block discarded – undo
1093 1093
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1094 1094
 			if (isset($data['latitude'])) $SI->add($data);
1095 1095
 			unset($data);
1096
-		    }
1096
+			}
1097 1097
 		} elseif (is_array($all_data)) {
1098
-		    $reset = 0;
1099
-		    foreach ($all_data as $line) {
1098
+			$reset = 0;
1099
+			foreach ($all_data as $line) {
1100 1100
 			$data = array();
1101 1101
 			$data['hex'] = $line['hex']; // hex
1102 1102
 			$data['ident'] = $line['flight']; // ident
@@ -1116,291 +1116,291 @@  discard block
 block discarded – undo
1116 1116
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1117 1117
 			$SI->add($data);
1118 1118
 			unset($data);
1119
-		    }
1119
+			}
1120 1120
 		}
1121
-	    } elseif ($globalDebug) echo 'No data'."\n";
1122
-    	    //$last_exec['aircraftlistjson'] = time();
1123
-    	    $last_exec[$id]['last'] = time();
1124
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1125
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
1126
-    	    (
1127
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1128
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1129
-    	    )
1130
-    	) {
1131
-	    $buffer = $Common->getData($value['host']);
1132
-	    $all_data = json_decode($buffer,true);
1133
-	    if (isset($all_data['planes'])) {
1121
+		} elseif ($globalDebug) echo 'No data'."\n";
1122
+			//$last_exec['aircraftlistjson'] = time();
1123
+			$last_exec[$id]['last'] = time();
1124
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1125
+		} elseif ($value['format'] === 'planeupdatefaa' && 
1126
+			(
1127
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1128
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1129
+			)
1130
+		) {
1131
+		$buffer = $Common->getData($value['host']);
1132
+		$all_data = json_decode($buffer,true);
1133
+		if (isset($all_data['planes'])) {
1134 1134
 		$reset = 0;
1135 1135
 		foreach ($all_data['planes'] as $key => $line) {
1136
-		    $data = array();
1137
-		    $data['hex'] = $key; // hex
1138
-		    $data['ident'] = $line[3]; // ident
1139
-		    $data['altitude'] = $line[6]; // altitude
1140
-		    $data['speed'] = $line[8]; // speed
1141
-		    $data['heading'] = $line[7]; // heading
1142
-		    $data['latitude'] = $line[4]; // lat
1143
-		    $data['longitude'] = $line[5]; // long
1144
-		    //$data['verticalrate'] = $line[]; // verticale rate
1145
-		    $data['squawk'] = $line[10]; // squawk
1146
-		    $data['emergency'] = ''; // emergency
1147
-		    $data['registration'] = $line[2];
1148
-		    $data['aircraft_icao'] = $line[0];
1149
-		    $deparr = explode('-',$line[1]);
1150
-		    if (count($deparr) === 2) {
1136
+			$data = array();
1137
+			$data['hex'] = $key; // hex
1138
+			$data['ident'] = $line[3]; // ident
1139
+			$data['altitude'] = $line[6]; // altitude
1140
+			$data['speed'] = $line[8]; // speed
1141
+			$data['heading'] = $line[7]; // heading
1142
+			$data['latitude'] = $line[4]; // lat
1143
+			$data['longitude'] = $line[5]; // long
1144
+			//$data['verticalrate'] = $line[]; // verticale rate
1145
+			$data['squawk'] = $line[10]; // squawk
1146
+			$data['emergency'] = ''; // emergency
1147
+			$data['registration'] = $line[2];
1148
+			$data['aircraft_icao'] = $line[0];
1149
+			$deparr = explode('-',$line[1]);
1150
+			if (count($deparr) === 2) {
1151 1151
 			$data['departure_airport_icao'] = $deparr[0];
1152 1152
 			$data['arrival_airport_icao'] = $deparr[1];
1153
-		    }
1154
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1155
-	    	    $data['format_source'] = 'planeupdatefaa';
1156
-    		    $data['id_source'] = $id_source;
1157
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1158
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1159
-		    $SI->add($data);
1160
-		    unset($data);
1153
+			}
1154
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1155
+				$data['format_source'] = 'planeupdatefaa';
1156
+				$data['id_source'] = $id_source;
1157
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1158
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1159
+			$SI->add($data);
1160
+			unset($data);
1161
+		}
1161 1162
 		}
1162
-	    }
1163
-	    //$last_exec['planeupdatefaa'] = time();
1164
-	    $last_exec[$id]['last'] = time();
1163
+		//$last_exec['planeupdatefaa'] = time();
1164
+		$last_exec[$id]['last'] = time();
1165 1165
 	} elseif ($value['format'] === 'opensky' && 
1166
-	    (
1166
+		(
1167 1167
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1168 1168
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1169
-	    )
1169
+		)
1170 1170
 	) {
1171
-	    $buffer = $Common->getData($value['host']);
1172
-	    $all_data = json_decode($buffer,true);
1173
-	    if (isset($all_data['states'])) {
1171
+		$buffer = $Common->getData($value['host']);
1172
+		$all_data = json_decode($buffer,true);
1173
+		if (isset($all_data['states'])) {
1174 1174
 		$reset = 0;
1175 1175
 		foreach ($all_data['states'] as $key => $line) {
1176
-		    $data = array();
1177
-		    $data['hex'] = $line[0]; // hex
1178
-		    $data['ident'] = trim($line[1]); // ident
1179
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1180
-		    $data['speed'] = round($line[9]*1.94384); // speed
1181
-		    $data['heading'] = round($line[10]); // heading
1182
-		    $data['latitude'] = $line[6]; // lat
1183
-		    $data['longitude'] = $line[5]; // long
1184
-		    $data['verticalrate'] = $line[11]; // verticale rate
1185
-		    //$data['squawk'] = $line[10]; // squawk
1186
-		    //$data['emergency'] = ''; // emergency
1187
-		    //$data['registration'] = $line[2];
1188
-		    //$data['aircraft_icao'] = $line[0];
1189
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1190
-		    $data['format_source'] = 'opensky';
1191
-		    $data['id_source'] = $id_source;
1192
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1193
-		    $SI->add($data);
1194
-		    unset($data);
1176
+			$data = array();
1177
+			$data['hex'] = $line[0]; // hex
1178
+			$data['ident'] = trim($line[1]); // ident
1179
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1180
+			$data['speed'] = round($line[9]*1.94384); // speed
1181
+			$data['heading'] = round($line[10]); // heading
1182
+			$data['latitude'] = $line[6]; // lat
1183
+			$data['longitude'] = $line[5]; // long
1184
+			$data['verticalrate'] = $line[11]; // verticale rate
1185
+			//$data['squawk'] = $line[10]; // squawk
1186
+			//$data['emergency'] = ''; // emergency
1187
+			//$data['registration'] = $line[2];
1188
+			//$data['aircraft_icao'] = $line[0];
1189
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1190
+			$data['format_source'] = 'opensky';
1191
+			$data['id_source'] = $id_source;
1192
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1193
+			$SI->add($data);
1194
+			unset($data);
1195 1195
 		}
1196
-	    }
1197
-	    //$last_exec['planeupdatefaa'] = time();
1198
-	    $last_exec[$id]['last'] = time();
1196
+		}
1197
+		//$last_exec['planeupdatefaa'] = time();
1198
+		$last_exec[$id]['last'] = time();
1199 1199
 	} elseif ($value['format'] === 'aircraftjson' && 
1200
-	    (
1200
+		(
1201 1201
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1202 1202
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1203
-	    )
1203
+		)
1204 1204
 	) {
1205
-	    $buffer = $Common->getData($value['host']);
1206
-	    $all_data = json_decode($buffer,true);
1207
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1205
+		$buffer = $Common->getData($value['host']);
1206
+		$all_data = json_decode($buffer,true);
1207
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1208 1208
 		$reset = 0;
1209 1209
 		foreach ($all_data['aircraft'] as $key => $line) {
1210
-		    $data = array();
1211
-		    // add support for ground vehicule with ~ in front of hex
1212
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1213
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1214
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1215
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1216
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1217
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1218
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1219
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1220
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1221
-		    //$data['emergency'] = ''; // emergency
1222
-		    //$data['registration'] = $line[2];
1223
-		    //$data['aircraft_icao'] = $line[0];
1224
-		    $data['datetime'] = date('Y-m-d H:i:s');
1225
-		    $data['format_source'] = 'aircraftjson';
1226
-		    $data['id_source'] = $id_source;
1227
-		    if (isset($value['name']) && $value['name'] != '') {
1228
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1229
-			    else $data['source_name'] = $value['name'];
1230
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1231
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1232
-		    $SI->add($data);
1233
-		    unset($data);
1210
+			$data = array();
1211
+			// add support for ground vehicule with ~ in front of hex
1212
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1213
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1214
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1215
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1216
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1217
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1218
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1219
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1220
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1221
+			//$data['emergency'] = ''; // emergency
1222
+			//$data['registration'] = $line[2];
1223
+			//$data['aircraft_icao'] = $line[0];
1224
+			$data['datetime'] = date('Y-m-d H:i:s');
1225
+			$data['format_source'] = 'aircraftjson';
1226
+			$data['id_source'] = $id_source;
1227
+			if (isset($value['name']) && $value['name'] != '') {
1228
+				if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1229
+				else $data['source_name'] = $value['name'];
1230
+			} elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1231
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1232
+			$SI->add($data);
1233
+			unset($data);
1234
+		}
1234 1235
 		}
1235
-	    }
1236
-	    //$last_exec['planeupdatefaa'] = time();
1237
-	    $last_exec[$id]['last'] = time();
1236
+		//$last_exec['planeupdatefaa'] = time();
1237
+		$last_exec[$id]['last'] = time();
1238 1238
 	} elseif ($value['format'] === 'planefinderclient' && 
1239
-	    (
1239
+		(
1240 1240
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1241 1241
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1242
-	    )
1242
+		)
1243 1243
 	) {
1244
-	    $buffer = $Common->getData($value['host']);
1245
-	    $all_data = json_decode($buffer,true);
1246
-	    if (isset($all_data['aircraft'])) {
1244
+		$buffer = $Common->getData($value['host']);
1245
+		$all_data = json_decode($buffer,true);
1246
+		if (isset($all_data['aircraft'])) {
1247 1247
 		$reset = 0;
1248 1248
 		foreach ($all_data['aircraft'] as $key => $line) {
1249
-		    $data = array();
1250
-		    $data['hex'] = $key; // hex
1251
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1252
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1253
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1254
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1255
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1256
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1257
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1258
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1259
-		    //$data['emergency'] = ''; // emergency
1260
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1261
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1262
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1263
-		    $data['format_source'] = 'planefinderclient';
1264
-		    $data['id_source'] = $id_source;
1265
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1266
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1267
-		    $SI->add($data);
1268
-		    unset($data);
1249
+			$data = array();
1250
+			$data['hex'] = $key; // hex
1251
+			if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1252
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1253
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1254
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1255
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1256
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1257
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1258
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1259
+			//$data['emergency'] = ''; // emergency
1260
+			if (isset($line['reg'])) $data['registration'] = $line['reg'];
1261
+			if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1262
+			$data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1263
+			$data['format_source'] = 'planefinderclient';
1264
+			$data['id_source'] = $id_source;
1265
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1266
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1267
+			$SI->add($data);
1268
+			unset($data);
1269 1269
 		}
1270
-	    }
1271
-	    $last_exec[$id]['last'] = time();
1270
+		}
1271
+		$last_exec[$id]['last'] = time();
1272 1272
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1273 1273
 	} elseif ($value['format'] === 'fr24json' && 
1274
-	    (
1274
+		(
1275 1275
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1276 1276
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1277
-	    )
1277
+		)
1278 1278
 	) {
1279
-	    //$buffer = $Common->getData($hosts[$id]);
1280
-	    $buffer = $Common->getData($value['host']);
1281
-	    $all_data = json_decode($buffer,true);
1282
-	    if (!empty($all_data)) $reset = 0;
1283
-	    foreach ($all_data as $key => $line) {
1279
+		//$buffer = $Common->getData($hosts[$id]);
1280
+		$buffer = $Common->getData($value['host']);
1281
+		$all_data = json_decode($buffer,true);
1282
+		if (!empty($all_data)) $reset = 0;
1283
+		foreach ($all_data as $key => $line) {
1284 1284
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1285
-		    $data = array();
1286
-		    $data['hex'] = $line[0];
1287
-		    $data['ident'] = $line[16]; //$line[13]
1288
-	    	    $data['altitude'] = $line[4]; // altitude
1289
-	    	    $data['speed'] = $line[5]; // speed
1290
-	    	    $data['heading'] = $line[3]; // heading
1291
-	    	    $data['latitude'] = $line[1]; // lat
1292
-	    	    $data['longitude'] = $line[2]; // long
1293
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1294
-	    	    $data['squawk'] = $line[6]; // squawk
1295
-	    	    $data['aircraft_icao'] = $line[8];
1296
-	    	    $data['registration'] = $line[9];
1297
-		    $data['departure_airport_iata'] = $line[11];
1298
-		    $data['arrival_airport_iata'] = $line[12];
1299
-	    	    $data['emergency'] = ''; // emergency
1300
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1301
-	    	    $data['format_source'] = 'fr24json';
1302
-    		    $data['id_source'] = $id_source;
1303
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1304
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1305
-		    $SI->add($data);
1306
-		    unset($data);
1285
+			$data = array();
1286
+			$data['hex'] = $line[0];
1287
+			$data['ident'] = $line[16]; //$line[13]
1288
+				$data['altitude'] = $line[4]; // altitude
1289
+				$data['speed'] = $line[5]; // speed
1290
+				$data['heading'] = $line[3]; // heading
1291
+				$data['latitude'] = $line[1]; // lat
1292
+				$data['longitude'] = $line[2]; // long
1293
+				$data['verticalrate'] = $line[15]; // verticale rate
1294
+				$data['squawk'] = $line[6]; // squawk
1295
+				$data['aircraft_icao'] = $line[8];
1296
+				$data['registration'] = $line[9];
1297
+			$data['departure_airport_iata'] = $line[11];
1298
+			$data['arrival_airport_iata'] = $line[12];
1299
+				$data['emergency'] = ''; // emergency
1300
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1301
+				$data['format_source'] = 'fr24json';
1302
+				$data['id_source'] = $id_source;
1303
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1304
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1305
+			$SI->add($data);
1306
+			unset($data);
1307 1307
 		}
1308
-	    }
1309
-	    //$last_exec['fr24json'] = time();
1310
-	    $last_exec[$id]['last'] = time();
1308
+		}
1309
+		//$last_exec['fr24json'] = time();
1310
+		$last_exec[$id]['last'] = time();
1311 1311
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1312 1312
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1313
-	    (
1313
+		(
1314 1314
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1315 1315
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1316
-	    )
1316
+		)
1317 1317
 	) {
1318
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1319
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1320
-	    //echo $buffer;
1321
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1322
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1323
-	    $all_data = json_decode($buffer,true);
1324
-	    if (json_last_error() != JSON_ERROR_NONE) {
1318
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1319
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1320
+		//echo $buffer;
1321
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1322
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1323
+		$all_data = json_decode($buffer,true);
1324
+		if (json_last_error() != JSON_ERROR_NONE) {
1325 1325
 		die(json_last_error_msg());
1326
-	    }
1327
-	    if (isset($all_data['mrkrs'])) {
1326
+		}
1327
+		if (isset($all_data['mrkrs'])) {
1328 1328
 		$reset = 0;
1329 1329
 		foreach ($all_data['mrkrs'] as $key => $line) {
1330
-		    if (isset($line['inf'])) {
1330
+			if (isset($line['inf'])) {
1331 1331
 			$data = array();
1332 1332
 			$data['hex'] = $line['inf']['ia'];
1333 1333
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1334
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1335
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1336
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1337
-	    		$data['latitude'] = $line['pt'][0]; // lat
1338
-	    		$data['longitude'] = $line['pt'][1]; // long
1339
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1340
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1341
-	    		//$data['aircraft_icao'] = $line[8];
1342
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1334
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1335
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1336
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1337
+				$data['latitude'] = $line['pt'][0]; // lat
1338
+				$data['longitude'] = $line['pt'][1]; // long
1339
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1340
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1341
+				//$data['aircraft_icao'] = $line[8];
1342
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1343 1343
 			//$data['departure_airport_iata'] = $line[11];
1344 1344
 			//$data['arrival_airport_iata'] = $line[12];
1345
-	    		//$data['emergency'] = ''; // emergency
1345
+				//$data['emergency'] = ''; // emergency
1346 1346
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1347
-	    		$data['format_source'] = 'radarvirtueljson';
1348
-    			$data['id_source'] = $id_source;
1347
+				$data['format_source'] = 'radarvirtueljson';
1348
+				$data['id_source'] = $id_source;
1349 1349
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1350 1350
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1351 1351
 			$SI->add($data);
1352 1352
 			unset($data);
1353
-		    }
1353
+			}
1354 1354
 		}
1355
-	    }
1356
-	    //$last_exec['radarvirtueljson'] = time();
1357
-	    $last_exec[$id]['last'] = time();
1355
+		}
1356
+		//$last_exec['radarvirtueljson'] = time();
1357
+		$last_exec[$id]['last'] = time();
1358 1358
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1359 1359
 	} elseif ($value['format'] === 'pirepsjson' && 
1360
-	    (
1360
+		(
1361 1361
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1362 1362
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1363
-	    )
1363
+		)
1364 1364
 	) {
1365
-	    //$buffer = $Common->getData($hosts[$id]);
1366
-	    $buffer = $Common->getData($value['host'].'?'.time());
1367
-	    $all_data = json_decode(utf8_encode($buffer),true);
1365
+		//$buffer = $Common->getData($hosts[$id]);
1366
+		$buffer = $Common->getData($value['host'].'?'.time());
1367
+		$all_data = json_decode(utf8_encode($buffer),true);
1368 1368
 	    
1369
-	    if (isset($all_data['pireps'])) {
1369
+		if (isset($all_data['pireps'])) {
1370 1370
 		$reset = 0;
1371
-	        foreach ($all_data['pireps'] as $line) {
1372
-		    $data = array();
1373
-		    $data['id'] = $line['id'];
1374
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1375
-		    $data['ident'] = $line['callsign']; // ident
1376
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1377
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1378
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1379
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1380
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1381
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1382
-		    $data['latitude'] = $line['lat']; // lat
1383
-		    $data['longitude'] = $line['lon']; // long
1384
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1385
-		    //$data['squawk'] = $line['squawk']; // squawk
1386
-		    //$data['emergency'] = ''; // emergency
1387
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1388
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1389
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1390
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1391
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1392
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1393
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1394
-		    else $data['info'] = '';
1395
-		    $data['format_source'] = 'pireps';
1396
-    		    $data['id_source'] = $id_source;
1397
-		    $data['datetime'] = date('Y-m-d H:i:s');
1398
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1399
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1400
-		    if ($line['icon'] === 'plane') {
1371
+			foreach ($all_data['pireps'] as $line) {
1372
+			$data = array();
1373
+			$data['id'] = $line['id'];
1374
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1375
+			$data['ident'] = $line['callsign']; // ident
1376
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1377
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1378
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1379
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1380
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1381
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1382
+			$data['latitude'] = $line['lat']; // lat
1383
+			$data['longitude'] = $line['lon']; // long
1384
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1385
+			//$data['squawk'] = $line['squawk']; // squawk
1386
+			//$data['emergency'] = ''; // emergency
1387
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1388
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1389
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1390
+			//$data['arrival_airport_time'] = $line['arrtime'];
1391
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1392
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1393
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1394
+			else $data['info'] = '';
1395
+			$data['format_source'] = 'pireps';
1396
+				$data['id_source'] = $id_source;
1397
+			$data['datetime'] = date('Y-m-d H:i:s');
1398
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1399
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1400
+			if ($line['icon'] === 'plane') {
1401 1401
 			$SI->add($data);
1402
-		    //    print_r($data);
1403
-    		    } elseif ($line['icon'] === 'ct') {
1402
+			//    print_r($data);
1403
+				} elseif ($line['icon'] === 'ct') {
1404 1404
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1405 1405
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1406 1406
 			$typec = substr($data['ident'],-3);
@@ -1415,209 +1415,209 @@  discard block
 block discarded – undo
1415 1415
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1416 1416
 			else $data['type'] = 'Observer';
1417 1417
 			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']);
1418
-		    }
1419
-		    unset($data);
1418
+			}
1419
+			unset($data);
1420 1420
 		}
1421
-	    }
1422
-	    //$last_exec['pirepsjson'] = time();
1423
-	    $last_exec[$id]['last'] = time();
1421
+		}
1422
+		//$last_exec['pirepsjson'] = time();
1423
+		$last_exec[$id]['last'] = time();
1424 1424
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1425 1425
 	} elseif ($value['format'] === 'phpvmacars' && 
1426
-	    (
1426
+		(
1427 1427
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1428 1428
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1429
-	    )
1429
+		)
1430 1430
 	) {
1431
-	    //$buffer = $Common->getData($hosts[$id]);
1432
-	    if ($globalDebug) echo 'Get Data...'."\n";
1433
-	    $buffer = $Common->getData($value['host']);
1434
-	    $all_data = json_decode($buffer,true);
1435
-	    if ($buffer != '' && is_array($all_data)) {
1431
+		//$buffer = $Common->getData($hosts[$id]);
1432
+		if ($globalDebug) echo 'Get Data...'."\n";
1433
+		$buffer = $Common->getData($value['host']);
1434
+		$all_data = json_decode($buffer,true);
1435
+		if ($buffer != '' && is_array($all_data)) {
1436 1436
 		$reset = 0;
1437 1437
 		foreach ($all_data as $line) {
1438
-	    	    $data = array();
1439
-	    	    //$data['id'] = $line['id']; // id not usable
1440
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1441
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1442
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1443
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1444
-	    	    $data['ident'] = $line['flightnum']; // ident
1445
-	    	    $data['altitude'] = $line['alt']; // altitude
1446
-	    	    $data['speed'] = $line['gs']; // speed
1447
-	    	    $data['heading'] = $line['heading']; // heading
1448
-	    	    $data['latitude'] = $line['lat']; // lat
1449
-	    	    $data['longitude'] = $line['lng']; // long
1450
-	    	    $data['verticalrate'] = ''; // verticale rate
1451
-	    	    $data['squawk'] = ''; // squawk
1452
-	    	    $data['emergency'] = ''; // emergency
1453
-	    	    //$data['datetime'] = $line['lastupdate'];
1454
-	    	    //$data['last_update'] = $line['lastupdate'];
1455
-	    	    if (isset($value['timezone'])) {
1456
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1457
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1458
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1459
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1460
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1461
-	    	    $data['departure_airport_time'] = $line['deptime'];
1462
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1463
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1464
-    		    if (isset($line['registration'])) {
1465
-    			$data['registration'] = $line['registration'];
1466
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1467
-    		    } else $data['registration'] = $line['aircraft'];
1468
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1469
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1470
-		    if (isset($line['aircraftname'])) {
1438
+				$data = array();
1439
+				//$data['id'] = $line['id']; // id not usable
1440
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1441
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1442
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1443
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1444
+				$data['ident'] = $line['flightnum']; // ident
1445
+				$data['altitude'] = $line['alt']; // altitude
1446
+				$data['speed'] = $line['gs']; // speed
1447
+				$data['heading'] = $line['heading']; // heading
1448
+				$data['latitude'] = $line['lat']; // lat
1449
+				$data['longitude'] = $line['lng']; // long
1450
+				$data['verticalrate'] = ''; // verticale rate
1451
+				$data['squawk'] = ''; // squawk
1452
+				$data['emergency'] = ''; // emergency
1453
+				//$data['datetime'] = $line['lastupdate'];
1454
+				//$data['last_update'] = $line['lastupdate'];
1455
+				if (isset($value['timezone'])) {
1456
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1457
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1458
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1459
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1460
+				$data['departure_airport_icao'] = $line['depicao'];
1461
+				$data['departure_airport_time'] = $line['deptime'];
1462
+				$data['arrival_airport_icao'] = $line['arricao'];
1463
+				$data['arrival_airport_time'] = $line['arrtime'];
1464
+				if (isset($line['registration'])) {
1465
+				$data['registration'] = $line['registration'];
1466
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1467
+				} else $data['registration'] = $line['aircraft'];
1468
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1469
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1470
+			if (isset($line['aircraftname'])) {
1471 1471
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1472 1472
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1473
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1474
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1475
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1476
-	    		else {
1477
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1478
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1479
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1480
-	    		}
1481
-	    	    }
1482
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1483
-    		    $data['id_source'] = $id_source;
1484
-	    	    $data['format_source'] = 'phpvmacars';
1485
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1486
-		    $SI->add($data);
1487
-		    unset($data);
1473
+				$aircraft_data = explode('-',$line['aircraftname']);
1474
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1475
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1476
+				else {
1477
+					$aircraft_data = explode(' ',$line['aircraftname']);
1478
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1479
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1480
+				}
1481
+				}
1482
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1483
+				$data['id_source'] = $id_source;
1484
+				$data['format_source'] = 'phpvmacars';
1485
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1486
+			$SI->add($data);
1487
+			unset($data);
1488 1488
 		}
1489 1489
 		if ($globalDebug) echo 'No more data...'."\n";
1490 1490
 		unset($buffer);
1491 1491
 		unset($all_data);
1492
-	    }
1493
-	    //$last_exec['phpvmacars'] = time();
1494
-	    $last_exec[$id]['last'] = time();
1492
+		}
1493
+		//$last_exec['phpvmacars'] = time();
1494
+		$last_exec[$id]['last'] = time();
1495 1495
 	} elseif ($value['format'] === 'vaos' && 
1496
-	    (
1496
+		(
1497 1497
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1498 1498
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1499
-	    )
1499
+		)
1500 1500
 	) {
1501
-	    //$buffer = $Common->getData($hosts[$id]);
1502
-	    if ($globalDebug) echo 'Get Data...'."\n";
1503
-	    $buffer = $Common->getData($value['host']);
1504
-	    $all_data = json_decode($buffer,true);
1505
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1501
+		//$buffer = $Common->getData($hosts[$id]);
1502
+		if ($globalDebug) echo 'Get Data...'."\n";
1503
+		$buffer = $Common->getData($value['host']);
1504
+		$all_data = json_decode($buffer,true);
1505
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1506 1506
 		$reset = 0;
1507 1507
 		foreach ($all_data['ACARSData'] as $line) {
1508
-		    //print_r($line);
1509
-	    	    $data = array();
1510
-	    	    //$data['id'] = $line['id']; // id not usable
1511
-	    	    $data['id'] = $line['id'];
1512
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1513
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1514
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1515
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1516
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1517
-	    	    $data['altitude'] = $line['altitude']; // altitude
1518
-	    	    $data['speed'] = $line['groundspeed']; // speed
1519
-	    	    $data['heading'] = $line['heading']; // heading
1520
-	    	    $data['latitude'] = $line['lat']; // lat
1521
-	    	    $data['longitude'] = $line['lon']; // long
1522
-	    	    //$data['verticalrate'] = ''; // verticale rate
1523
-	    	    //$data['squawk'] = ''; // squawk
1524
-	    	    //$data['emergency'] = ''; // emergency
1525
-	    	    if (isset($value['timezone'])) {
1526
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1527
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1528
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1529
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1508
+			//print_r($line);
1509
+				$data = array();
1510
+				//$data['id'] = $line['id']; // id not usable
1511
+				$data['id'] = $line['id'];
1512
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1513
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1514
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1515
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1516
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1517
+				$data['altitude'] = $line['altitude']; // altitude
1518
+				$data['speed'] = $line['groundspeed']; // speed
1519
+				$data['heading'] = $line['heading']; // heading
1520
+				$data['latitude'] = $line['lat']; // lat
1521
+				$data['longitude'] = $line['lon']; // long
1522
+				//$data['verticalrate'] = ''; // verticale rate
1523
+				//$data['squawk'] = ''; // squawk
1524
+				//$data['emergency'] = ''; // emergency
1525
+				if (isset($value['timezone'])) {
1526
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1527
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1528
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1529
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1530 1530
 	    	    
1531
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1532
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1533
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1534
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1535
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1531
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1532
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1533
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1534
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1535
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1536 1536
 
1537
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1538
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1539
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1537
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1538
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1539
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1540 1540
 
1541
-    		    $data['id_source'] = $id_source;
1542
-	    	    $data['format_source'] = 'vaos';
1543
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1544
-		    $SI->add($data);
1545
-		    unset($data);
1541
+				$data['id_source'] = $id_source;
1542
+				$data['format_source'] = 'vaos';
1543
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1544
+			$SI->add($data);
1545
+			unset($data);
1546 1546
 		}
1547 1547
 		if ($globalDebug) echo 'No more data...'."\n";
1548 1548
 		unset($buffer);
1549 1549
 		unset($all_data);
1550
-	    }
1551
-	    //$last_exec['phpvmacars'] = time();
1552
-	    $last_exec[$id]['last'] = time();
1550
+		}
1551
+		//$last_exec['phpvmacars'] = time();
1552
+		$last_exec[$id]['last'] = time();
1553 1553
 	} elseif ($value['format'] === 'vam' && 
1554
-	    (
1554
+		(
1555 1555
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1556 1556
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1557
-	    )
1557
+		)
1558 1558
 	) {
1559
-	    //$buffer = $Common->getData($hosts[$id]);
1560
-	    if ($globalDebug) echo 'Get Data...'."\n";
1561
-	    $buffer = $Common->getData($value['host']);
1562
-	    $all_data = json_decode($buffer,true);
1563
-	    if ($buffer != '' && is_array($all_data)) {
1559
+		//$buffer = $Common->getData($hosts[$id]);
1560
+		if ($globalDebug) echo 'Get Data...'."\n";
1561
+		$buffer = $Common->getData($value['host']);
1562
+		$all_data = json_decode($buffer,true);
1563
+		if ($buffer != '' && is_array($all_data)) {
1564 1564
 		$reset = 0;
1565 1565
 		foreach ($all_data as $line) {
1566
-	    	    $data = array();
1567
-	    	    //$data['id'] = $line['id']; // id not usable
1568
-	    	    $data['id'] = trim($line['flight_id']);
1569
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1570
-	    	    $data['pilot_name'] = $line['pilot_name'];
1571
-	    	    $data['pilot_id'] = $line['pilot_id'];
1572
-	    	    $data['ident'] = trim($line['callsign']); // ident
1573
-	    	    $data['altitude'] = $line['altitude']; // altitude
1574
-	    	    $data['speed'] = $line['gs']; // speed
1575
-	    	    $data['heading'] = $line['heading']; // heading
1576
-	    	    $data['latitude'] = $line['latitude']; // lat
1577
-	    	    $data['longitude'] = $line['longitude']; // long
1578
-	    	    $data['verticalrate'] = ''; // verticale rate
1579
-	    	    $data['squawk'] = ''; // squawk
1580
-	    	    $data['emergency'] = ''; // emergency
1581
-	    	    //$data['datetime'] = $line['lastupdate'];
1582
-	    	    $data['last_update'] = $line['last_update'];
1583
-		    $data['datetime'] = date('Y-m-d H:i:s');
1584
-	    	    $data['departure_airport_icao'] = $line['departure'];
1585
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1586
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1587
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1588
-    		    //$data['registration'] = $line['aircraft'];
1589
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1590
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1591
-    		    $data['id_source'] = $id_source;
1592
-	    	    $data['format_source'] = 'vam';
1593
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1594
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1595
-		    $SI->add($data);
1596
-		    unset($data);
1566
+				$data = array();
1567
+				//$data['id'] = $line['id']; // id not usable
1568
+				$data['id'] = trim($line['flight_id']);
1569
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1570
+				$data['pilot_name'] = $line['pilot_name'];
1571
+				$data['pilot_id'] = $line['pilot_id'];
1572
+				$data['ident'] = trim($line['callsign']); // ident
1573
+				$data['altitude'] = $line['altitude']; // altitude
1574
+				$data['speed'] = $line['gs']; // speed
1575
+				$data['heading'] = $line['heading']; // heading
1576
+				$data['latitude'] = $line['latitude']; // lat
1577
+				$data['longitude'] = $line['longitude']; // long
1578
+				$data['verticalrate'] = ''; // verticale rate
1579
+				$data['squawk'] = ''; // squawk
1580
+				$data['emergency'] = ''; // emergency
1581
+				//$data['datetime'] = $line['lastupdate'];
1582
+				$data['last_update'] = $line['last_update'];
1583
+			$data['datetime'] = date('Y-m-d H:i:s');
1584
+				$data['departure_airport_icao'] = $line['departure'];
1585
+				//$data['departure_airport_time'] = $line['departure_time'];
1586
+				$data['arrival_airport_icao'] = $line['arrival'];
1587
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1588
+				//$data['registration'] = $line['aircraft'];
1589
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1590
+				$data['aircraft_icao'] = $line['plane_type'];
1591
+				$data['id_source'] = $id_source;
1592
+				$data['format_source'] = 'vam';
1593
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1594
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1595
+			$SI->add($data);
1596
+			unset($data);
1597 1597
 		}
1598 1598
 		if ($globalDebug) echo 'No more data...'."\n";
1599 1599
 		unset($buffer);
1600 1600
 		unset($all_data);
1601
-	    }
1602
-	    //$last_exec['phpvmacars'] = time();
1603
-	    $last_exec[$id]['last'] = time();
1601
+		}
1602
+		//$last_exec['phpvmacars'] = time();
1603
+		$last_exec[$id]['last'] = time();
1604 1604
 	} elseif ($value['format'] === 'blitzortung' && 
1605
-	    (
1605
+		(
1606 1606
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1607 1607
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1608
-	    )
1608
+		)
1609 1609
 	) {
1610
-	    //$buffer = $Common->getData($hosts[$id]);
1611
-	    if ($globalDebug) echo 'Get Data...'."\n";
1612
-	    $buffer = $Common->getData($value['host']);
1613
-	    $all_data = json_decode($buffer,true);
1614
-	    if ($buffer != '') {
1610
+		//$buffer = $Common->getData($hosts[$id]);
1611
+		if ($globalDebug) echo 'Get Data...'."\n";
1612
+		$buffer = $Common->getData($value['host']);
1613
+		$all_data = json_decode($buffer,true);
1614
+		if ($buffer != '') {
1615 1615
 		$Source->deleteLocationBySource('blitzortung');
1616 1616
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1617 1617
 		$buffer = explode('\n',$buffer);
1618 1618
 		foreach ($buffer as $buffer_line) {
1619
-		    $line = json_decode($buffer_line,true);
1620
-		    if (isset($line['time'])) {
1619
+			$line = json_decode($buffer_line,true);
1620
+			if (isset($line['time'])) {
1621 1621
 			$data = array();
1622 1622
 			$data['altitude'] = $line['alt']; // altitude
1623 1623
 			$data['latitude'] = $line['lat']; // lat
@@ -1629,92 +1629,92 @@  discard block
 block discarded – undo
1629 1629
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1630 1630
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1631 1631
 			unset($data);
1632
-		    }
1632
+			}
1633 1633
 		}
1634 1634
 		if ($globalDebug) echo 'No more data...'."\n";
1635 1635
 		unset($buffer);
1636
-	    }
1637
-	    $last_exec[$id]['last'] = time();
1636
+		}
1637
+		$last_exec[$id]['last'] = time();
1638 1638
 	} elseif ($value['format'] === 'acarsjson') {
1639
-        $arr = $httpfeeds;
1640
-        $w = $e = null;
1641
-        if (isset($arr[$id])) {
1642
-            $nn = stream_select($arr,$w,$e,$timeout);
1643
-            if ($nn > 0) {
1644
-                foreach ($httpfeeds as $feed) {
1645
-                    $buffer = stream_get_line($feed,2000,"\n");
1646
-                    if ($buffer === FALSE) {
1647
-                        connect_all($globalSources);
1648
-                    }
1649
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1650
-                    $buffer = explode('\n',$buffer);
1651
-                    foreach ($buffer as $line) {
1652
-                        if ($line != '') {
1653
-                            $line = json_decode($line, true);
1654
-                            if (!empty($line)) {
1655
-                                $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1656
-                                $ACARS->deleteLiveAcarsData();
1657
-                            }
1658
-                        }
1659
-                    }
1660
-                }
1661
-            } else {
1662
-                $format = $value['format'];
1663
-                if (isset($tt[$format])) $tt[$format]++;
1664
-                else $tt[$format] = 0;
1665
-                if ($tt[$format] > 30) {
1666
-                    if ($globalDebug) echo 'Reconnect...'."\n";
1667
-                    sleep(2);
1668
-                    //$sourceeen[] = $value;
1669
-                    //connect_all($sourceeen);
1670
-                    //$sourceeen = array();
1671
-                    connect_all($globalSources);
1672
-                }
1673
-            }
1674
-        }
1639
+		$arr = $httpfeeds;
1640
+		$w = $e = null;
1641
+		if (isset($arr[$id])) {
1642
+			$nn = stream_select($arr,$w,$e,$timeout);
1643
+			if ($nn > 0) {
1644
+				foreach ($httpfeeds as $feed) {
1645
+					$buffer = stream_get_line($feed,2000,"\n");
1646
+					if ($buffer === FALSE) {
1647
+						connect_all($globalSources);
1648
+					}
1649
+					$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1650
+					$buffer = explode('\n',$buffer);
1651
+					foreach ($buffer as $line) {
1652
+						if ($line != '') {
1653
+							$line = json_decode($line, true);
1654
+							if (!empty($line)) {
1655
+								$ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1656
+								$ACARS->deleteLiveAcarsData();
1657
+							}
1658
+						}
1659
+					}
1660
+				}
1661
+			} else {
1662
+				$format = $value['format'];
1663
+				if (isset($tt[$format])) $tt[$format]++;
1664
+				else $tt[$format] = 0;
1665
+				if ($tt[$format] > 30) {
1666
+					if ($globalDebug) echo 'Reconnect...'."\n";
1667
+					sleep(2);
1668
+					//$sourceeen[] = $value;
1669
+					//connect_all($sourceeen);
1670
+					//$sourceeen = array();
1671
+					connect_all($globalSources);
1672
+				}
1673
+			}
1674
+		}
1675 1675
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1676 1676
 	} 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'] === 'acarsjsonudp' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') {
1677
-	    //$last_exec[$id]['last'] = time();
1678
-	    //$read = array( $sockets[$id] );
1679
-	    $read = $sockets;
1680
-	    $write = NULL;
1681
-	    $e = NULL;
1682
-	    $n = socket_select($read, $write, $e, $timeout);
1683
-	    if ($e != NULL) var_dump($e);
1684
-	    if ($n > 0) {
1677
+		//$last_exec[$id]['last'] = time();
1678
+		//$read = array( $sockets[$id] );
1679
+		$read = $sockets;
1680
+		$write = NULL;
1681
+		$e = NULL;
1682
+		$n = socket_select($read, $write, $e, $timeout);
1683
+		if ($e != NULL) var_dump($e);
1684
+		if ($n > 0) {
1685 1685
 		$reset = 0;
1686 1686
 		foreach ($read as $nb => $r) {
1687
-		    //$value = $formats[$nb];
1688
-		    $format = $globalSources[$nb]['format'];
1689
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1687
+			//$value = $formats[$nb];
1688
+			$format = $globalSources[$nb]['format'];
1689
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1690 1690
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1691
-		    } elseif ($format === 'vrstcp') {
1691
+			} elseif ($format === 'vrstcp') {
1692 1692
 			$buffer = @socket_read($r, 6000);
1693
-		    } else {
1693
+			} else {
1694 1694
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1695
-		    }
1696
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1697
-		    //echo $buffer."\n";
1698
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1699
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1700
-		    $error = false;
1701
-		    //$SI::del();
1702
-		    if ($buffer !== FALSE) {
1695
+			}
1696
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1697
+			//echo $buffer."\n";
1698
+			// lets play nice and handle signals such as ctrl-c/kill properly
1699
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1700
+			$error = false;
1701
+			//$SI::del();
1702
+			if ($buffer !== FALSE) {
1703 1703
 			if ($format === 'vrstcp') {
1704
-			    $buffer = explode('},{',$buffer);
1704
+				$buffer = explode('},{',$buffer);
1705 1705
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1706
-		    }
1707
-		    // SBS format is CSV format
1708
-		    if ($buffer !== FALSE && $buffer !== '') {
1706
+			}
1707
+			// SBS format is CSV format
1708
+			if ($buffer !== FALSE && $buffer !== '') {
1709 1709
 			$tt[$format] = 0;
1710 1710
 			if ($format === 'acarssbs3') {
1711
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1712
-			    $ACARS->add(trim($buffer));
1713
-			    $ACARS->deleteLiveAcarsData();
1711
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1712
+				$ACARS->add(trim($buffer));
1713
+				$ACARS->deleteLiveAcarsData();
1714 1714
 			} elseif ($format === 'raw') {
1715
-			    // AVR format
1716
-			    $data = $SBS->parse($buffer);
1717
-			    if (is_array($data)) {
1715
+				// AVR format
1716
+				$data = $SBS->parse($buffer);
1717
+				if (is_array($data)) {
1718 1718
 				//if (!empty($data)) print_r($data);
1719 1719
 				$data['datetime'] = date('Y-m-d H:i:s');
1720 1720
 				$data['format_source'] = 'raw';
@@ -1724,39 +1724,39 @@  discard block
 block discarded – undo
1724 1724
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1725 1725
 				$SI->add($data);
1726 1726
 				unset($data);
1727
-			    }
1727
+				}
1728 1728
 			} elseif ($format === 'ais') {
1729
-			    $ais_data = $AIS->parse_line(trim($buffer));
1730
-			    $data = array();
1731
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1732
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1733
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1734
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1735
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1736
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1737
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1738
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1739
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1740
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1741
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1742
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1743
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1744
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1745
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1746
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1729
+				$ais_data = $AIS->parse_line(trim($buffer));
1730
+				$data = array();
1731
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1732
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1733
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1734
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1735
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1736
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1737
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1738
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1739
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1740
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1741
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1742
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1743
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1744
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1745
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1746
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1747 1747
 
1748
-			    if (isset($ais_data['timestamp'])) {
1748
+				if (isset($ais_data['timestamp'])) {
1749 1749
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1750
-			    } else {
1750
+				} else {
1751 1751
 				$data['datetime'] = date('Y-m-d H:i:s');
1752
-			    }
1753
-			    $data['format_source'] = 'aisnmea';
1754
-    			    $data['id_source'] = $id_source;
1755
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1756
-			    unset($data);
1757
-                        } elseif ($format === 'flightgearsp') {
1758
-                    	    //echo $buffer."\n";
1759
-                    	    if (strlen($buffer) > 5) {
1752
+				}
1753
+				$data['format_source'] = 'aisnmea';
1754
+					$data['id_source'] = $id_source;
1755
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1756
+				unset($data);
1757
+						} elseif ($format === 'flightgearsp') {
1758
+							//echo $buffer."\n";
1759
+							if (strlen($buffer) > 5) {
1760 1760
 				$line = explode(',',$buffer);
1761 1761
 				$data = array();
1762 1762
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1773,47 +1773,47 @@  discard block
 block discarded – undo
1773 1773
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1774 1774
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1775 1775
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1776
-			    }
1777
-                        } elseif ($format === 'acars') {
1778
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1779
-			    $ACARS->add(trim($buffer));
1780
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1781
-			    $ACARS->deleteLiveAcarsData();
1776
+				}
1777
+						} elseif ($format === 'acars') {
1778
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1779
+				$ACARS->add(trim($buffer));
1780
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1781
+				$ACARS->deleteLiveAcarsData();
1782 1782
 			} elseif ($format === 'acarsjsonudp') {
1783
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1784
-                            $line = json_decode(trim($buffer), true);
1785
-                            if (!empty($line)) {
1783
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1784
+							$line = json_decode(trim($buffer), true);
1785
+							if (!empty($line)) {
1786 1786
 				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line);
1787
-                                $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1788
-                                $ACARS->deleteLiveAcarsData();
1789
-                            }
1790
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1787
+								$ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1788
+								$ACARS->deleteLiveAcarsData();
1789
+							}
1790
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1791 1791
 			} elseif ($format === 'flightgearmp') {
1792
-			    if (substr($buffer,0,1) != '#') {
1792
+				if (substr($buffer,0,1) != '#') {
1793 1793
 				$data = array();
1794 1794
 				//echo $buffer."\n";
1795 1795
 				$line = explode(' ',$buffer);
1796 1796
 				if (count($line) === 11) {
1797
-				    $userserver = explode('@',$line[0]);
1798
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1799
-				    $data['ident'] = $userserver[0];
1800
-				    $data['registration'] = $userserver[0];
1801
-				    $data['latitude'] = $line[4];
1802
-				    $data['longitude'] = $line[5];
1803
-				    $data['altitude'] = $line[6];
1804
-				    $data['datetime'] = date('Y-m-d H:i:s');
1805
-				    $aircraft_type = $line[10];
1806
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1807
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1808
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1809
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1797
+					$userserver = explode('@',$line[0]);
1798
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1799
+					$data['ident'] = $userserver[0];
1800
+					$data['registration'] = $userserver[0];
1801
+					$data['latitude'] = $line[4];
1802
+					$data['longitude'] = $line[5];
1803
+					$data['altitude'] = $line[6];
1804
+					$data['datetime'] = date('Y-m-d H:i:s');
1805
+					$aircraft_type = $line[10];
1806
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1807
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1808
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1809
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1810
+				}
1810 1811
 				}
1811
-			    }
1812 1812
 			} elseif ($format === 'beast') {
1813
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1814
-			    die;
1813
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1814
+				die;
1815 1815
 			} elseif ($format === 'vrstcp') {
1816
-			    foreach($buffer as $all_data) {
1816
+				foreach($buffer as $all_data) {
1817 1817
 				$line = json_decode('{'.$all_data.'}',true);
1818 1818
 				$data = array();
1819 1819
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1833,158 +1833,158 @@  discard block
 block discarded – undo
1833 1833
 				*/
1834 1834
 				$data['datetime'] = date('Y-m-d H:i:s');
1835 1835
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1836
-		    		$data['format_source'] = 'vrstcp';
1836
+					$data['format_source'] = 'vrstcp';
1837 1837
 				$data['id_source'] = $id_source;
1838 1838
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1839 1839
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1840 1840
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1841 1841
 				unset($data);
1842
-			    }
1842
+				}
1843 1843
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1844
-			    $line = explode("\t", $buffer);
1845
-			    for($k = 0; $k < count($line); $k=$k+2) {
1844
+				$line = explode("\t", $buffer);
1845
+				for($k = 0; $k < count($line); $k=$k+2) {
1846 1846
 				$key = $line[$k];
1847
-			        $lined[$key] = $line[$k+1];
1848
-			    }
1849
-    			    if (count($lined) > 3) {
1850
-    				$data['hex'] = $lined['hexid'];
1851
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1852
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1853
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1854
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1855
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1856
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1857
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1858
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1859
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1860
-    				$data['id_source'] = $id_source;
1861
-    				$data['format_source'] = 'tsv';
1862
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1863
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1847
+					$lined[$key] = $line[$k+1];
1848
+				}
1849
+					if (count($lined) > 3) {
1850
+					$data['hex'] = $lined['hexid'];
1851
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1852
+					$data['datetime'] = date('Y-m-d H:i:s');;
1853
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1854
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1855
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1856
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1857
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1858
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1859
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1860
+					$data['id_source'] = $id_source;
1861
+					$data['format_source'] = 'tsv';
1862
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1863
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1864 1864
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1865
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1866
-    				unset($lined);
1867
-    				unset($data);
1868
-    			    } else $error = true;
1865
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1866
+					unset($lined);
1867
+					unset($data);
1868
+					} else $error = true;
1869 1869
 			} elseif ($format === 'aprs' && $use_aprs) {
1870
-			    if ($aprs_connect === 0) {
1870
+				if ($aprs_connect === 0) {
1871 1871
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1872 1872
 				$aprs_connect = 1;
1873
-			    }
1873
+				}
1874 1874
 			    
1875
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1875
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1876 1876
 				$aprs_last_tx = time();
1877 1877
 				$data_aprs = "# Keep alive";
1878 1878
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1879
-			    }
1879
+				}
1880 1880
 			    
1881
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1882
-			    //echo 'APRS data : '.$buffer."\n";
1883
-			    $buffer = str_replace('APRS <- ','',$buffer);
1884
-			    $buffer = str_replace('APRS -> ','',$buffer);
1885
-			    //echo $buffer."\n";
1886
-			    date_default_timezone_set('UTC');
1887
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1881
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1882
+				//echo 'APRS data : '.$buffer."\n";
1883
+				$buffer = str_replace('APRS <- ','',$buffer);
1884
+				$buffer = str_replace('APRS -> ','',$buffer);
1885
+				//echo $buffer."\n";
1886
+				date_default_timezone_set('UTC');
1887
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1888 1888
 				$line = $APRS->parse($buffer);
1889 1889
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1890 1890
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1891
-				    $aprs_last_tx = time();
1892
-				    $data = array();
1893
-				    //print_r($line);
1894
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1895
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1896
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1897
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1898
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1899
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1900
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1901
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1902
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1903
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1904
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1905
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1906
-				    $data['latitude'] = $line['latitude'];
1907
-				    $data['longitude'] = $line['longitude'];
1908
-				    //$data['verticalrate'] = $line[16];
1909
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1910
-				    //else $data['speed'] = 0;
1911
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1912
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1913
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1914
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1891
+					$aprs_last_tx = time();
1892
+					$data = array();
1893
+					//print_r($line);
1894
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1895
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1896
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1897
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1898
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1899
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1900
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1901
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1902
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1903
+					else $data['datetime'] = date('Y-m-d H:i:s');
1904
+					//$data['datetime'] = date('Y-m-d H:i:s');
1905
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1906
+					$data['latitude'] = $line['latitude'];
1907
+					$data['longitude'] = $line['longitude'];
1908
+					//$data['verticalrate'] = $line[16];
1909
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1910
+					//else $data['speed'] = 0;
1911
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1912
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1913
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1914
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1915 1915
 				    
1916
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1917
-				    //else echo 'No heading...'."\n";
1918
-				    //else $data['heading'] = 0;
1919
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1920
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1921
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1922
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1923
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1924
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1925
-    				    $data['id_source'] = $id_source;
1926
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1927
-				    else $data['format_source'] = 'aprs';
1928
-				    $data['source_name'] = $line['source'];
1929
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1930
-				    else $data['source_type'] = 'flarm';
1931
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1932
-				    $currentdate = date('Y-m-d H:i:s');
1933
-				    $aprsdate = strtotime($data['datetime']);
1934
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1935
-				    // Accept data if time <= system time + 20s
1936
-				    //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'])))) {
1937
-				    if (
1916
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1917
+					//else echo 'No heading...'."\n";
1918
+					//else $data['heading'] = 0;
1919
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1920
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1921
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1922
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1923
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1924
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1925
+						$data['id_source'] = $id_source;
1926
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1927
+					else $data['format_source'] = 'aprs';
1928
+					$data['source_name'] = $line['source'];
1929
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1930
+					else $data['source_type'] = 'flarm';
1931
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1932
+					$currentdate = date('Y-m-d H:i:s');
1933
+					$aprsdate = strtotime($data['datetime']);
1934
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1935
+					// Accept data if time <= system time + 20s
1936
+					//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'])))) {
1937
+					if (
1938 1938
 					($data['source_type'] === 'modes') || 
1939 1939
 					isset($line['stealth']) && 
1940 1940
 					(!isset($data['hex']) || $data['hex'] != 'FFFFFF') && 
1941 1941
 					 ($line['stealth'] === 0 || $line['stealth'] == '') && 
1942 1942
 					 (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1943 1943
 					$send = $SI->add($data);
1944
-				    } elseif ($data['source_type'] === 'ais') {
1944
+					} elseif ($data['source_type'] === 'ais') {
1945 1945
 					$data['type'] = '';
1946 1946
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1947
-				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1947
+					} elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1948 1948
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1949
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1950
-					    //$line['symbol'] === 'Balloon' ||
1951
-					    $line['symbol'] === 'Glider' || 
1952
-					    $line['symbol'] === 'No. Plane' || 
1953
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1954
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1955
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1956
-					    $send = $SI->add($data);
1957
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1958
-					    $line['symbol'] === 'Yacht (Sail)' || 
1959
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1960
-					    $send = $MI->add($data);
1961
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1962
-					    $line['symbol'] === 'Car' || 
1963
-					    $line['symbol'] === 'Ambulance' || 
1964
-					    $line['symbol'] === 'Van' || 
1965
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1966
-					    $line['symbol'] === 'Motorcycle' || 
1967
-					    $line['symbol'] === 'Tractor' || 
1968
-					    $line['symbol'] === 'Police' || 
1969
-					    $line['symbol'] === 'Bike' || 
1970
-					    $line['symbol'] === 'Jogger' || 
1971
-					    $line['symbol'] === 'Horse' || 
1972
-					    $line['symbol'] === 'Bus' || 
1973
-					    $line['symbol'] === 'Jeep' || 
1974
-					    $line['symbol'] === 'Recreational Vehicle' || 
1975
-					    $line['symbol'] === 'Yacht (Sail)' || 
1976
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1977
-					    $line['symbol'] === 'Firetruck' || 
1978
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1979
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1980
-					    $line['symbol'] === 'SUV' ||
1981
-					    $line['symbol'] === 'Snowmobile' ||
1982
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1983
-				    //} 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') {
1949
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1950
+						//$line['symbol'] === 'Balloon' ||
1951
+						$line['symbol'] === 'Glider' || 
1952
+						$line['symbol'] === 'No. Plane' || 
1953
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1954
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1955
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1956
+						$send = $SI->add($data);
1957
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1958
+						$line['symbol'] === 'Yacht (Sail)' || 
1959
+						$line['symbol'] === 'Ship (Power Boat)')) {
1960
+						$send = $MI->add($data);
1961
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1962
+						$line['symbol'] === 'Car' || 
1963
+						$line['symbol'] === 'Ambulance' || 
1964
+						$line['symbol'] === 'Van' || 
1965
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1966
+						$line['symbol'] === 'Motorcycle' || 
1967
+						$line['symbol'] === 'Tractor' || 
1968
+						$line['symbol'] === 'Police' || 
1969
+						$line['symbol'] === 'Bike' || 
1970
+						$line['symbol'] === 'Jogger' || 
1971
+						$line['symbol'] === 'Horse' || 
1972
+						$line['symbol'] === 'Bus' || 
1973
+						$line['symbol'] === 'Jeep' || 
1974
+						$line['symbol'] === 'Recreational Vehicle' || 
1975
+						$line['symbol'] === 'Yacht (Sail)' || 
1976
+						$line['symbol'] === 'Ship (Power Boat)' || 
1977
+						$line['symbol'] === 'Firetruck' || 
1978
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1979
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1980
+						$line['symbol'] === 'SUV' ||
1981
+						$line['symbol'] === 'Snowmobile' ||
1982
+						$line['symbol'] === 'Mobile Satellite Station')) {
1983
+					//} 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') {
1984 1984
 				//    } 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') {
1985 1985
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1986 1986
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1987
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1987
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1988 1988
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1989 1989
 					$Source->deleteOldLocationByType('gs');
1990 1990
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1992,7 +1992,7 @@  discard block
 block discarded – undo
1992 1992
 					} else {
1993 1993
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1994 1994
 					}
1995
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1995
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1996 1996
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1997 1997
 					if ($globalDebug) echo '# Weather Station added'."\n";
1998 1998
 					$Source->deleteOldLocationByType('wx');
@@ -2002,7 +2002,7 @@  discard block
 block discarded – undo
2002 2002
 					} else {
2003 2003
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2004 2004
 					}
2005
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2005
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2006 2006
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2007 2007
 					if ($globalDebug) echo '☈ Lightning added'."\n";
2008 2008
 					$Source->deleteOldLocationByType('lightning');
@@ -2011,11 +2011,11 @@  discard block
 block discarded – undo
2011 2011
 					} else {
2012 2012
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2013 2013
 					}
2014
-				    } elseif ($globalDebug) {
2015
-				    	echo '/!\ Not added: '.$buffer."\n";
2016
-				    	print_r($line);
2017
-				    }
2018
-				    unset($data);
2014
+					} elseif ($globalDebug) {
2015
+						echo '/!\ Not added: '.$buffer."\n";
2016
+						print_r($line);
2017
+					}
2018
+					unset($data);
2019 2019
 				}
2020 2020
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2021 2021
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -2034,13 +2034,13 @@  discard block
 block discarded – undo
2034 2034
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
2035 2035
 					$globalSources[$nb]['last_weather_clean'] = time();
2036 2036
 				}
2037
-			    }
2037
+				}
2038 2038
 			} else {
2039
-			    $line = explode(',', $buffer);
2040
-			    //print_r($line);
2041
-    			    if (count($line) > 20) {
2042
-    			    	$data['hex'] = $line[4];
2043
-    				/*
2039
+				$line = explode(',', $buffer);
2040
+				//print_r($line);
2041
+					if (count($line) > 20) {
2042
+						$data['hex'] = $line[4];
2043
+					/*
2044 2044
     				$data['datetime'] = $line[6].' '.$line[7];
2045 2045
     					date_default_timezone_set($globalTimezone);
2046 2046
     					$datetime = new DateTime($data['datetime']);
@@ -2048,31 +2048,31 @@  discard block
 block discarded – undo
2048 2048
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
2049 2049
     					date_default_timezone_set('UTC');
2050 2050
     				*/
2051
-    				// Force datetime to current UTC datetime
2052
-    				date_default_timezone_set('UTC');
2053
-    				$data['datetime'] = date('Y-m-d H:i:s');
2054
-    				$data['ident'] = trim($line[10]);
2055
-    				$data['latitude'] = $line[14];
2056
-    				$data['longitude'] = $line[15];
2057
-    				$data['verticalrate'] = $line[16];
2058
-    				$data['emergency'] = $line[20];
2059
-    				$data['speed'] = $line[12];
2060
-    				$data['squawk'] = $line[17];
2061
-    				$data['altitude'] = $line[11];
2062
-    				$data['heading'] = $line[13];
2063
-    				$data['ground'] = $line[21];
2064
-    				$data['emergency'] = $line[19];
2065
-    				$data['format_source'] = 'sbs';
2051
+					// Force datetime to current UTC datetime
2052
+					date_default_timezone_set('UTC');
2053
+					$data['datetime'] = date('Y-m-d H:i:s');
2054
+					$data['ident'] = trim($line[10]);
2055
+					$data['latitude'] = $line[14];
2056
+					$data['longitude'] = $line[15];
2057
+					$data['verticalrate'] = $line[16];
2058
+					$data['emergency'] = $line[20];
2059
+					$data['speed'] = $line[12];
2060
+					$data['squawk'] = $line[17];
2061
+					$data['altitude'] = $line[11];
2062
+					$data['heading'] = $line[13];
2063
+					$data['ground'] = $line[21];
2064
+					$data['emergency'] = $line[19];
2065
+					$data['format_source'] = 'sbs';
2066 2066
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
2067 2067
 				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
2068 2068
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2069 2069
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2070
-    				$data['id_source'] = $id_source;
2071
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2072
-    				else $error = true;
2073
-    				unset($data);
2074
-    			    } else $error = true;
2075
-			    if ($error) {
2070
+					$data['id_source'] = $id_source;
2071
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2072
+					else $error = true;
2073
+					unset($data);
2074
+					} else $error = true;
2075
+				if ($error) {
2076 2076
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
2077 2077
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
2078 2078
 				} else {
@@ -2088,13 +2088,13 @@  discard block
 block discarded – undo
2088 2088
 					connect_all($sourceer);
2089 2089
 					$sourceer = array();
2090 2090
 				}
2091
-			    }
2091
+				}
2092 2092
 			}
2093 2093
 			// Sleep for xxx microseconds
2094 2094
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2095
-		    } else {
2095
+			} else {
2096 2096
 			if ($format === 'flightgearmp') {
2097
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2097
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
2098 2098
 				//@socket_close($r);
2099 2099
 				sleep($globalMinFetch);
2100 2100
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2103,9 +2103,9 @@  discard block
 block discarded – undo
2103 2103
 				break;
2104 2104
 				
2105 2105
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2106
-			    if (isset($tt[$format])) $tt[$format]++;
2107
-			    else $tt[$format] = 0;
2108
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
2106
+				if (isset($tt[$format])) $tt[$format]++;
2107
+				else $tt[$format] = 0;
2108
+				if ($tt[$format] > 30 || $buffer === FALSE) {
2109 2109
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2110 2110
 				//@socket_close($r);
2111 2111
 				sleep(2);
@@ -2116,24 +2116,24 @@  discard block
 block discarded – undo
2116 2116
 				//connect_all($globalSources);
2117 2117
 				$tt[$format]=0;
2118 2118
 				break;
2119
-			    } 
2120
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2119
+				} 
2120
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2121
+			}
2121 2122
 			}
2122
-		    }
2123 2123
 		}
2124
-	    } else {
2124
+		} else {
2125 2125
 		$error = socket_strerror(socket_last_error());
2126 2126
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2127 2127
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2128 2128
 			if (isset($globalDebug)) echo "Restarting...\n";
2129 2129
 			// Restart the script if possible
2130 2130
 			if (is_array($sockets)) {
2131
-			    if ($globalDebug) echo "Shutdown all sockets...";
2131
+				if ($globalDebug) echo "Shutdown all sockets...";
2132 2132
 			    
2133
-			    foreach ($sockets as $sock) {
2133
+				foreach ($sockets as $sock) {
2134 2134
 				@socket_shutdown($sock,2);
2135 2135
 				@socket_close($sock);
2136
-			    }
2136
+				}
2137 2137
 			    
2138 2138
 			}
2139 2139
 			if ($globalDebug) echo "Waiting...";
@@ -2148,15 +2148,15 @@  discard block
 block discarded – undo
2148 2148
 			if ($globalDebug) echo "Restart all connections...";
2149 2149
 			connect_all($globalSources);
2150 2150
 		}
2151
-	    }
2151
+		}
2152 2152
 	}
2153 2153
 	if ($globalDaemon === false) {
2154
-	    if ($globalDebug) echo 'Check all...'."\n";
2155
-	    if (isset($SI)) $SI->checkAll();
2156
-	    if (isset($TI)) $TI->checkAll();
2157
-	    if (isset($MI)) $MI->checkAll();
2154
+		if ($globalDebug) echo 'Check all...'."\n";
2155
+		if (isset($SI)) $SI->checkAll();
2156
+		if (isset($TI)) $TI->checkAll();
2157
+		if (isset($MI)) $MI->checkAll();
2158
+	}
2158 2159
 	}
2159
-    }
2160 2160
 }
2161 2161
 
2162 2162
 ?>
Please login to merge, or discard this patch.
Spacing   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
 	    die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
62
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
63 63
     }
64 64
 }
65 65
 
66
-$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'));
66
+$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'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70 70
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
71
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
72 72
     else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74 74
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
76 76
     else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115 115
     if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
116
+    $SI = new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
120 120
     $SI->connect();
121 121
 */
122
-} else $SI=new SpotterImport($Connection->db);
122
+} else $SI = new SpotterImport($Connection->db);
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
     $MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136
-$SBS=new SBS();
136
+$SBS = new SBS();
137 137
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
138
-	$ACARS=new ACARS($Connection->db,true);
139
-	$Source=new Source($Connection->db);
138
+	$ACARS = new ACARS($Connection->db, true);
139
+	$Source = new Source($Connection->db);
140 140
 }
141
-$Common=new Common();
141
+$Common = new Common();
142 142
 date_default_timezone_set('UTC');
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
146
+    pcntl_signal(SIGINT, function() {
147 147
         global $sockets;
148 148
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149 149
         die("Bye!\n");
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
 function connect_all($hosts) {
161 161
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
162
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
163 163
     $reset++;
164 164
     if ($globalDebug) echo 'Connect to all...'."\n";
165 165
     foreach ($hosts as $id => $value) {
@@ -167,33 +167,33 @@  discard block
 block discarded – undo
167 167
 	$udp = false;
168 168
 	$globalSources[$id]['last_exec'] = 0;
169 169
 	// Here we check type of source(s)
170
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
-            if (preg_match('/deltadb.txt$/i',$host)) {
170
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
+            if (preg_match('/deltadb.txt$/i', $host)) {
172 172
         	//$formats[$id] = 'deltadbtxt';
173 173
         	$globalSources[$id]['format'] = 'deltadbtxt';
174 174
         	//$last_exec['deltadbtxt'] = 0;
175 175
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
176
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
177 177
         	//$formats[$id] = 'vatsimtxt';
178 178
         	$globalSources[$id]['format'] = 'vatsimtxt';
179 179
         	//$last_exec['vatsimtxt'] = 0;
180 180
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
181
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
182 182
         	//$formats[$id] = 'aircraftlistjson';
183 183
         	$globalSources[$id]['format'] = 'aircraftlistjson';
184 184
         	//$last_exec['aircraftlistjson'] = 0;
185 185
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
186
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
187 187
         	//$formats[$id] = 'aircraftjson';
188 188
         	$globalSources[$id]['format'] = 'aircraftjson';
189 189
         	//$last_exec['aircraftlistjson'] = 0;
190 190
         	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
-    	    } else if (preg_match('/aircraft$/i',$host)) {
191
+    	    } else if (preg_match('/aircraft$/i', $host)) {
192 192
         	//$formats[$id] = 'planefinderclient';
193 193
         	$globalSources[$id]['format'] = 'planefinderclient';
194 194
         	//$last_exec['aircraftlistjson'] = 0;
195 195
         	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
-    	    } else if (preg_match('/opensky/i',$host)) {
196
+    	    } else if (preg_match('/opensky/i', $host)) {
197 197
         	//$formats[$id] = 'aircraftlistjson';
198 198
         	$globalSources[$id]['format'] = 'opensky';
199 199
         	//$last_exec['aircraftlistjson'] = 0;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         	    exit(0);
211 211
         	}
212 212
     	    */
213
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
213
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
214 214
         	//$formats[$id] = 'planeupdatefaa';
215 215
         	$globalSources[$id]['format'] = 'planeupdatefaa';
216 216
         	//$last_exec['planeupdatefaa'] = 0;
@@ -219,37 +219,37 @@  discard block
 block discarded – undo
219 219
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220 220
         	    exit(0);
221 221
         	}
222
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
222
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
223 223
         	//$formats[$id] = 'phpvmacars';
224 224
         	$globalSources[$id]['format'] = 'phpvmacars';
225 225
         	//$last_exec['phpvmacars'] = 0;
226 226
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
227
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
228 228
         	//$formats[$id] = 'phpvmacars';
229 229
         	$globalSources[$id]['format'] = 'vaos';
230 230
         	//$last_exec['phpvmacars'] = 0;
231 231
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
232
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
233 233
         	//$formats[$id] = 'phpvmacars';
234 234
         	$globalSources[$id]['format'] = 'vam';
235 235
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
-            } else if (preg_match('/whazzup/i',$host)) {
236
+            } else if (preg_match('/whazzup/i', $host)) {
237 237
         	//$formats[$id] = 'whazzup';
238 238
         	$globalSources[$id]['format'] = 'whazzup';
239 239
         	//$last_exec['whazzup'] = 0;
240 240
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
-            } else if (preg_match('/blitzortung/i',$host)) {
241
+            } else if (preg_match('/blitzortung/i', $host)) {
242 242
         	$globalSources[$id]['format'] = 'blitzortung';
243 243
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
-            } else if (preg_match('/airwhere/i',$host)) {
244
+            } else if (preg_match('/airwhere/i', $host)) {
245 245
         	$globalSources[$id]['format'] = 'airwhere';
246 246
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
-            } else if (preg_match('/recentpireps/i',$host)) {
247
+            } else if (preg_match('/recentpireps/i', $host)) {
248 248
         	//$formats[$id] = 'pirepsjson';
249 249
         	$globalSources[$id]['format'] = 'pirepsjson';
250 250
         	//$last_exec['pirepsjson'] = 0;
251 251
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
252
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
253 253
         	//$formats[$id] = 'fr24json';
254 254
         	$globalSources[$id]['format'] = 'fr24json';
255 255
         	//$last_exec['fr24json'] = 0;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259 259
         	    exit(0);
260 260
         	}
261
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
261
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
262 262
         	//$formats[$id] = 'fr24json';
263 263
         	$globalSources[$id]['format'] = 'myshiptracking';
264 264
         	//$last_exec['fr24json'] = 0;
@@ -268,22 +268,22 @@  discard block
 block discarded – undo
268 268
         	    exit(0);
269 269
         	}
270 270
             //} else if (preg_match('/10001/',$host)) {
271
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272 272
         	//$formats[$id] = 'tsv';
273 273
         	$globalSources[$id]['format'] = 'tsv';
274 274
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275 275
             }
276
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276
+        } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277 277
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
278
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
279 279
     		    if ($idf !== false) {
280 280
     			$httpfeeds[$id] = $idf;
281 281
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282 282
     		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283 283
     		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284 284
     		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
285
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
286
-	    $hostport = explode(':',$host);
285
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
286
+	    $hostport = explode(':', $host);
287 287
 	    if (isset($hostport[1])) {
288 288
 		$port = $hostport[1];
289 289
 		$hostn = $hostport[0];
@@ -293,20 +293,20 @@  discard block
 block discarded – undo
293 293
 	    }
294 294
 	    $Common = new Common();
295 295
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
296
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
296
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
297 297
     	    } else {
298 298
     		$udp = true;
299
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
299
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
300 300
 	    }
301 301
 	    if ($s) {
302 302
     	        $sockets[$id] = $s;
303 303
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
304
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
304
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
305 305
 			//$formats[$id] = 'aprs';
306 306
 			$globalSources[$id]['format'] = 'aprs';
307 307
 			//$aprs_connect = 0;
308 308
 			//$use_aprs = true;
309
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
309
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
310 310
 			$globalSources[$id]['format'] = 'vrstcp';
311 311
     		    } elseif ($port == '10001') {
312 312
         		//$formats[$id] = 'tsv';
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
349 349
 else $timeout = 20;
350 350
 $errno = '';
351
-$errstr='';
351
+$errstr = '';
352 352
 
353 353
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
354 354
 /* Initiate connections to all the hosts simultaneously */
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 //connect_all($globalSources);
357 357
 
358 358
 if (isset($globalProxy) && $globalProxy) {
359
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
359
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
360 360
 } else {
361 361
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
362 362
 }
@@ -386,16 +386,16 @@  discard block
 block discarded – undo
386 386
 
387 387
 if ($use_aprs) {
388 388
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
389
-	$APRS=new APRS();
389
+	$APRS = new APRS();
390 390
 	$aprs_connect = 0;
391 391
 	$aprs_keep = 120;
392 392
 	$aprs_last_tx = time();
393 393
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
394
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
394
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
395 395
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
396
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
396
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
397 397
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
398
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
398
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
399 399
 	if ($aprs_full) $aprs_filter = '';
400 400
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
401 401
 	else $aprs_pass = '-1';
@@ -409,12 +409,12 @@  discard block
 block discarded – undo
409 409
 sleep(1);
410 410
 if ($globalDebug) echo "SCAN MODE \n\n";
411 411
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
412
-$endtime = time()+$globalCronEnd;
412
+$endtime = time() + $globalCronEnd;
413 413
 $i = 1;
414 414
 $tt = array();
415 415
 // Delete all ATC
416 416
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
417
-	$ATC=new ATC($Connection->db);
417
+	$ATC = new ATC($Connection->db);
418 418
 }
419 419
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
420 420
 	$ATC->deleteAll();
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 while ($i > 0) {
425 425
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
426 426
 
427
-    if (!$globalDaemon) $i = $endtime-time();
427
+    if (!$globalDaemon) $i = $endtime - time();
428 428
     // Delete old ATC
429 429
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
430 430
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	}
439 439
 	if ($max < $globalMinFetch) {
440 440
 	    if ($globalDebug) echo 'Sleeping...'."\n";
441
-	    sleep($globalMinFetch-$max+2);
441
+	    sleep($globalMinFetch - $max + 2);
442 442
 	}
443 443
     }
444 444
 
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
             //$buffer = $Common->getData($hosts[$id]);
494 494
             $buffer = $Common->getData($value['host']);
495 495
             if ($buffer != '') {
496
-                $all_data = json_decode($buffer,true);
496
+                $all_data = json_decode($buffer, true);
497 497
                 foreach ($all_data as $line) {
498 498
                     $data = array();
499
-                    $data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
499
+                    $data['datetime'] = date('Y-m-d H:i:s', $line['uti']);
500 500
                     $data['hex'] = $line['hex']; // hex
501 501
                     $data['ident'] = $line['fli']; // ident
502 502
                     $data['altitude'] = $line['alt']; // altitude
@@ -531,11 +531,11 @@  discard block
 block discarded – undo
531 531
 	    )
532 532
 	) {
533 533
 	    date_default_timezone_set('CET');
534
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
534
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
535 535
 	    date_default_timezone_set('UTC');
536 536
 	    if ($buffer != '') $reset = 0;
537
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
538
-	    $buffer = explode('\n',$buffer);
537
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
538
+	    $buffer = explode('\n', $buffer);
539 539
 	    foreach ($buffer as $line) {
540 540
 		if ($line != '') {
541 541
 		    //echo "'".$line."'\n";
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 		    $ais_data = $AIS->parse_line(trim($line));
544 544
 		    $data = array();
545 545
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
546
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
546
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
547 547
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
548 548
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
549 549
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
556 556
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
557 557
 		    if (isset($ais_data['timestamp'])) {
558
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
558
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
559 559
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
560 560
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
561 561
 			    $add = true;
@@ -578,21 +578,21 @@  discard block
 block discarded – undo
578 578
 	    $w = $e = null;
579 579
 	    
580 580
 	    if (isset($arr[$id])) {
581
-		$nn = stream_select($arr,$w,$e,$timeout);
581
+		$nn = stream_select($arr, $w, $e, $timeout);
582 582
 		if ($nn > 0) {
583 583
 		    foreach ($httpfeeds as $feed) {
584
-			$buffer = stream_get_line($feed,2000,"\n");
584
+			$buffer = stream_get_line($feed, 2000, "\n");
585 585
 			if ($buffer === FALSE) {
586 586
 			    connect_all($globalSources);
587 587
 			}
588
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
589
-			$buffer = explode('\n',$buffer);
588
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
589
+			$buffer = explode('\n', $buffer);
590 590
 			foreach ($buffer as $line) {
591 591
 			    if ($line != '') {
592 592
 				$ais_data = $AIS->parse_line(trim($line));
593 593
 				$data = array();
594 594
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
595
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
595
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
596 596
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
597 597
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
598 598
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -604,9 +604,9 @@  discard block
 block discarded – undo
604 604
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
605 605
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
606 606
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
607
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
607
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
608 608
 				if (isset($ais_data['timestamp'])) {
609
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
609
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
610 610
 				} else {
611 611
 				    $data['datetime'] = date('Y-m-d H:i:s');
612 612
 				}
@@ -638,10 +638,10 @@  discard block
 block discarded – undo
638 638
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
639 639
 	    )
640 640
 	) {
641
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
641
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
642 642
 	    if ($buffer != '') {
643 643
 		//echo $buffer;
644
-		$all_data = json_decode($buffer,true);
644
+		$all_data = json_decode($buffer, true);
645 645
 		//print_r($all_data);
646 646
 		if (isset($all_data[0]['DATA'])) {
647 647
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 			    $data['ident'] = $line['NAME'];
651 651
 			    $data['mmsi'] = $line['MMSI'];
652 652
 			    if (strlen($data['mmsi']) > 9) {
653
-				$data['mmsi'] = substr($data['mmsi'],-9);
653
+				$data['mmsi'] = substr($data['mmsi'], -9);
654 654
 			    }
655 655
 			    $data['speed'] = $line['SOG'];
656 656
 			    $data['heading'] = $line['COG'];
@@ -660,8 +660,8 @@  discard block
 block discarded – undo
660 660
 			    //$data['type_id'] = $line['TYPE'];
661 661
 			    $data['imo'] = $line['IMO'];
662 662
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
663
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
664
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
663
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
664
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
665 665
 			    $data['format_source'] = 'myshiptracking';
666 666
 			    $data['id_source'] = $id_source;
667 667
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -678,16 +678,16 @@  discard block
 block discarded – undo
678 678
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
679 679
 	    )
680 680
 	) {
681
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
681
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
682 682
 	    if ($buffer != '') {
683
-		$all_data = json_decode($buffer,true);
683
+		$all_data = json_decode($buffer, true);
684 684
 		if (isset($all_data[0]['mmsi'])) {
685 685
 		    foreach ($all_data as $line) {
686 686
 			if ($line != '') {
687 687
 			    $data = array();
688 688
 			    $data['ident'] = $line['shipname'];
689 689
 			    $data['callsign'] = $line['callsign'];
690
-			    $data['mmsi'] = substr($line['mmsi'],-9);
690
+			    $data['mmsi'] = substr($line['mmsi'], -9);
691 691
 			    $data['speed'] = $line['sog'];
692 692
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
693 693
 			    $data['latitude'] = $line['latitude'];
@@ -714,14 +714,14 @@  discard block
 block discarded – undo
714 714
 	) {
715 715
 	    $buffer = $Common->getData($value['host']);
716 716
 	    if ($buffer != '') {
717
-		$all_data = json_decode($buffer,true);
717
+		$all_data = json_decode($buffer, true);
718 718
 		if (isset($all_data['features'][0]['id'])) {
719 719
 		    foreach ($all_data['features'] as $line) {
720 720
 			print_r($line);
721 721
 			$data = array();
722 722
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
723 723
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
724
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
724
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
725 725
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
726 726
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
727 727
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -748,31 +748,31 @@  discard block
 block discarded – undo
748 748
 	    )
749 749
 	) {
750 750
 	    if ($globalDebug) echo 'download...';
751
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
751
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
752 752
 	    if ($globalDebug) echo 'done !'."\n";
753 753
 	    // FIXME: Need more work
754 754
 	    if ($buffer != '') $reset = 0;
755
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
756
-	    $buffer = explode('\n',$buffer);
755
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
756
+	    $buffer = explode('\n', $buffer);
757 757
 	    foreach ($buffer as $line) {
758 758
 		if ($line != '') {
759 759
 		    $data = array();
760 760
 		    //echo $line."\n";
761
-		    $data['mmsi'] = (int)substr($line,0,9);
762
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
763
-		    $data['status_id'] = substr($line,21,2);
764
-		    $data['type_id'] = substr($line,24,3);
765
-		    $data['latitude'] = substr($line,29,9);
766
-		    $data['longitude'] = substr($line,41,9);
767
-		    $data['speed'] = round(substr($line,51,5));
761
+		    $data['mmsi'] = (int) substr($line, 0, 9);
762
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
763
+		    $data['status_id'] = substr($line, 21, 2);
764
+		    $data['type_id'] = substr($line, 24, 3);
765
+		    $data['latitude'] = substr($line, 29, 9);
766
+		    $data['longitude'] = substr($line, 41, 9);
767
+		    $data['speed'] = round(substr($line, 51, 5));
768 768
 		    //$data['course'] = substr($line,57,5);
769
-		    $data['heading'] = round(substr($line,63,3));
769
+		    $data['heading'] = round(substr($line, 63, 3));
770 770
 		    //$data['draft'] = substr($line,67,4);
771 771
 		    //$data['length'] = substr($line,72,3);
772 772
 		    //$data['beam'] = substr($line,76,2);
773
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
773
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
774 774
 		    //$data['callsign'] = trim(substr($line,100,7);
775
-		    $data['arrival_code'] = substr($line,108,20);
775
+		    $data['arrival_code'] = substr($line, 108, 20);
776 776
 		    //$data['etaDate'] = substr($line,129,5);
777 777
 		    //$data['etaTime'] = substr($line,135,5);
778 778
 		    $data['format_source'] = 'shipplotter';
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 	    )
792 792
 	) {
793 793
 	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
794
-		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
794
+		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl', 'post', array('submitlogin' => 'Login', 'email' => $globalSailaway['email'], 'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'), '', '', '', '', '', false, false, true);
795 795
 		//echo $authsailaway;
796 796
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
797 797
 		if (isset($setcookie[1][0])) {
@@ -800,19 +800,19 @@  discard block
 block discarded – undo
800 800
 	    }
801 801
 
802 802
 	    if ($globalDebug) echo '! Download... ';
803
-	    for ($i =0; $i <= 1; $i++) {
803
+	    for ($i = 0; $i <= 1; $i++) {
804 804
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
805 805
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
806 806
 	    if ($globalDebug) echo 'done'."\n";
807 807
 	    if ($buffer != '') {
808
-		$all_data = json_decode($buffer,true);
808
+		$all_data = json_decode($buffer, true);
809 809
 		if (isset($all_data['missions'])) {
810 810
 			foreach ($all_data['missions'] as $mission) {
811 811
 				$mission_user = $mission['usrname'];
812
-				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
813
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
812
+				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']));
813
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
814 814
 					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') {
815
-						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
815
+						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie);
816 816
 						sleep(30);
817 817
 					} else $racebuffer = '';
818 818
 					$bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
@@ -821,19 +821,19 @@  discard block
 block discarded – undo
821 821
 					$racebuffer = '';
822 822
 				}
823 823
 				if ($racebuffer != '') {
824
-					$race_data = json_decode($racebuffer,true);
824
+					$race_data = json_decode($racebuffer, true);
825 825
 					//print_r($race_data);
826 826
 					unset($racebuffer);
827 827
 					if (isset($race_data['mission'])) {
828 828
 					    $datar = array();
829 829
 					    $datar['id'] = $mission['misnr'];
830 830
 					    $datar['desc'] = $race_data['mission']['misdescr'];
831
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
832
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
831
+					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname'])));
832
+					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle'])));
833 833
 					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
834 834
 					    $markers = array();
835 835
 					    foreach ($race_data['mission']['course'] as $course) {
836
-						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
836
+						$markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']);
837 837
 					    }
838 838
 					    $datar['markers'] = json_encode($markers);
839 839
 					    //print_r($datar);
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 					}
842 842
 				}
843 843
 				if ($bufferm != '') {
844
-					$mission_data = json_decode($bufferm,true);
844
+					$mission_data = json_decode($bufferm, true);
845 845
 					unset($bufferm);
846 846
 					if (isset($mission_data['leaderboard'][0]['results'])) {
847 847
 						foreach ($mission_data['leaderboard'][0]['results'] as $sail) {
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 								//$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr'];
855 855
 								$data['id'] = $sail['misnr'].'-'.$sail['usrnr'];
856 856
 								$data['datetime'] = date('Y-m-d H:i:s');
857
-								$data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart']));
857
+								$data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart']));
858 858
 								$data['last_update'] = date('Y-m-d H:i:s');
859 859
 								$data['status'] = $sail['status'];
860 860
 								$data['type'] = $sail['btptype'];
@@ -865,16 +865,16 @@  discard block
 block discarded – undo
865 865
 									$data['longitude'] = $pos['longitude'];
866 866
 								}
867 867
 								if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') {
868
-									$resultdescr = explode(',',$sail['resultdescr']);
868
+									$resultdescr = explode(',', $sail['resultdescr']);
869 869
 									if (count($resultdescr) > 2) {
870
-										$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2);
871
-										$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1]));
870
+										$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2);
871
+										$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1]));
872 872
 										if (isset($resultdescr[3])) {
873
-											$data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3);
873
+											$data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3);
874 874
 										}
875 875
 									}
876 876
 								}
877
-								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
877
+								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
878 878
 								$data['captain_id'] = $sail['usrnr'];
879 879
 								$data['captain_name'] = $sail['usrname'];
880 880
 								$data['race_id'] = $sail['misnr'];
@@ -924,8 +924,8 @@  discard block
 block discarded – undo
924 924
 	) {
925 925
 	    //$buffer = $Common->getData($hosts[$id]);
926 926
 	    $buffer = $Common->getData($value['host']);
927
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
928
-	    $buffer = explode('\n',$buffer);
927
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
928
+	    $buffer = explode('\n', $buffer);
929 929
 	    $reset = 0;
930 930
 	    foreach ($buffer as $line) {
931 931
     		if ($line != '') {
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
937 937
 			$data['pilot_id'] = $line[1];
938 938
 			$data['pilot_name'] = $line[2];
939
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
939
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
940 940
 			$data['ident'] = $line[0]; // ident
941 941
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
942 942
 			$data['speed'] = $line[8]; // speed
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
953 953
 			//if (isset($line[37])) $data['last_update'] = $line[37];
954 954
 		        $data['departure_airport_icao'] = $line[11];
955
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
955
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
956 956
 		        $data['arrival_airport_icao'] = $line[13];
957 957
 			$data['frequency'] = $line[4];
958 958
 			$data['type'] = $line[18];
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
     			$data['id_source'] = $id_source;
962 962
 	    		//$data['arrival_airport_time'] = ;
963 963
 	    		if ($line[9] != '') {
964
-	    		    $aircraft_data = explode('/',$line[9]);
964
+	    		    $aircraft_data = explode('/', $line[9]);
965 965
 	    		    if (isset($aircraft_data[1])) {
966 966
 	    			$data['aircraft_icao'] = $aircraft_data[1];
967 967
 	    		    }
@@ -976,9 +976,9 @@  discard block
 block discarded – undo
976 976
     			if ($line[3] === 'PILOT') $SI->add($data);
977 977
 			elseif ($line[3] === 'ATC') {
978 978
 				//print_r($data);
979
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
980
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
981
-				$typec = substr($data['ident'],-3);
979
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
980
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
981
+				$typec = substr($data['ident'], -3);
982 982
 				if ($typec === 'APP') $data['type'] = 'Approach';
983 983
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
984 984
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -990,8 +990,8 @@  discard block
 block discarded – undo
990 990
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
991 991
 				if (!isset($data['source_name'])) $data['source_name'] = '';
992 992
 				if (isset($ATC)) {
993
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($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']);
994
-					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']);
993
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($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']);
994
+					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']);
995 995
 				}
996 996
 			}
997 997
     			unset($data);
@@ -1007,24 +1007,24 @@  discard block
 block discarded – undo
1007 1007
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1008 1008
     	    )
1009 1009
     	) {
1010
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1010
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
1011 1011
 	    if ($buffer != '') {
1012 1012
 		$all_data = simplexml_load_string($buffer);
1013
-		foreach($all_data->children() as $childdata) {
1013
+		foreach ($all_data->children() as $childdata) {
1014 1014
 			$data = array();
1015 1015
 			$line = $childdata;
1016 1016
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
1017
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
1018
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1019
-			$data['latitude'] = (float)$line['pktLatitude'];
1020
-			$data['longitude'] = (float)$line['pktLongitude'];
1021
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1022
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1023
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1017
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
1018
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
1019
+			$data['latitude'] = (float) $line['pktLatitude'];
1020
+			$data['longitude'] = (float) $line['pktLongitude'];
1021
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
1022
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
1023
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
1024 1024
 			$data['altitude_relative'] = 'AMSL';
1025
-			$data['pilot_id'] = (int)$line['pktPilotID'];
1025
+			$data['pilot_id'] = (int) $line['pktPilotID'];
1026 1026
 			$data['aircraft_icao'] = 'PARAGLIDER';
1027
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1027
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1028 1028
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1029 1029
 			$data['format_source'] = $value['format'];
1030 1030
 			$SI->add($data);
@@ -1032,22 +1032,22 @@  discard block
 block discarded – undo
1032 1032
 		}
1033 1033
 	    }
1034 1034
 	    $Source->deleteOldLocationByType('gs');
1035
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1035
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
1036 1036
 	    if ($buffer != '') {
1037 1037
 		$all_data = simplexml_load_string($buffer);
1038
-		foreach($all_data->children() as $childdata) {
1038
+		foreach ($all_data->children() as $childdata) {
1039 1039
 			$data = array();
1040 1040
 			$line = $childdata;
1041
-			$data['id'] = (int)$line['gsID'];
1042
-			$data['latitude'] = (float)$line['gsLatitude'];
1043
-			$data['longitude'] = (float)$line['gsLongitude'];
1044
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
1041
+			$data['id'] = (int) $line['gsID'];
1042
+			$data['latitude'] = (float) $line['gsLatitude'];
1043
+			$data['longitude'] = (float) $line['gsLongitude'];
1044
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
1045 1045
 			$data['altitude_relative'] = 'AMSL';
1046
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
1046
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
1047 1047
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
1048
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1048
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1049 1049
 			} else {
1050
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1050
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1051 1051
 			}
1052 1052
 			unset($data);
1053 1053
 		}
@@ -1065,9 +1065,9 @@  discard block
 block discarded – undo
1065 1065
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1066 1066
 	    )
1067 1067
 	) {
1068
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1068
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1069 1069
 	    if ($buffer != '') {
1070
-	        $all_data = json_decode($buffer,true);
1070
+	        $all_data = json_decode($buffer, true);
1071 1071
 		if (isset($all_data['acList'])) {
1072 1072
 		    $reset = 0;
1073 1073
 		    foreach ($all_data['acList'] as $line) {
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1084 1084
 			$data['emergency'] = ''; // emergency
1085 1085
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1086
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1086
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1087 1087
 			else $data['datetime'] = date('Y-m-d H:i:s');
1088 1088
 			//$data['datetime'] = date('Y-m-d H:i:s');
1089 1089
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1109 1109
 			$data['squawk'] = $line['squawk']; // squawk
1110 1110
 			$data['emergency'] = ''; // emergency
1111
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1111
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1112 1112
 			else $data['datetime'] = date('Y-m-d H:i:s');
1113 1113
 			$data['format_source'] = 'aircraftlistjson';
1114 1114
 			$data['id_source'] = $id_source;
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
     	    )
1130 1130
     	) {
1131 1131
 	    $buffer = $Common->getData($value['host']);
1132
-	    $all_data = json_decode($buffer,true);
1132
+	    $all_data = json_decode($buffer, true);
1133 1133
 	    if (isset($all_data['planes'])) {
1134 1134
 		$reset = 0;
1135 1135
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1146,12 +1146,12 @@  discard block
 block discarded – undo
1146 1146
 		    $data['emergency'] = ''; // emergency
1147 1147
 		    $data['registration'] = $line[2];
1148 1148
 		    $data['aircraft_icao'] = $line[0];
1149
-		    $deparr = explode('-',$line[1]);
1149
+		    $deparr = explode('-', $line[1]);
1150 1150
 		    if (count($deparr) === 2) {
1151 1151
 			$data['departure_airport_icao'] = $deparr[0];
1152 1152
 			$data['arrival_airport_icao'] = $deparr[1];
1153 1153
 		    }
1154
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1154
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1155 1155
 	    	    $data['format_source'] = 'planeupdatefaa';
1156 1156
     		    $data['id_source'] = $id_source;
1157 1157
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 	    )
1170 1170
 	) {
1171 1171
 	    $buffer = $Common->getData($value['host']);
1172
-	    $all_data = json_decode($buffer,true);
1172
+	    $all_data = json_decode($buffer, true);
1173 1173
 	    if (isset($all_data['states'])) {
1174 1174
 		$reset = 0;
1175 1175
 		foreach ($all_data['states'] as $key => $line) {
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 		    //$data['emergency'] = ''; // emergency
1187 1187
 		    //$data['registration'] = $line[2];
1188 1188
 		    //$data['aircraft_icao'] = $line[0];
1189
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1189
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1190 1190
 		    $data['format_source'] = 'opensky';
1191 1191
 		    $data['id_source'] = $id_source;
1192 1192
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1203,8 +1203,8 @@  discard block
 block discarded – undo
1203 1203
 	    )
1204 1204
 	) {
1205 1205
 	    $buffer = $Common->getData($value['host']);
1206
-	    $all_data = json_decode($buffer,true);
1207
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1206
+	    $all_data = json_decode($buffer, true);
1207
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1208 1208
 		$reset = 0;
1209 1209
 		foreach ($all_data['aircraft'] as $key => $line) {
1210 1210
 		    $data = array();
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 	    )
1243 1243
 	) {
1244 1244
 	    $buffer = $Common->getData($value['host']);
1245
-	    $all_data = json_decode($buffer,true);
1245
+	    $all_data = json_decode($buffer, true);
1246 1246
 	    if (isset($all_data['aircraft'])) {
1247 1247
 		$reset = 0;
1248 1248
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
 		    //$data['emergency'] = ''; // emergency
1260 1260
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1261 1261
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1262
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1262
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1263 1263
 		    $data['format_source'] = 'planefinderclient';
1264 1264
 		    $data['id_source'] = $id_source;
1265 1265
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 	) {
1279 1279
 	    //$buffer = $Common->getData($hosts[$id]);
1280 1280
 	    $buffer = $Common->getData($value['host']);
1281
-	    $all_data = json_decode($buffer,true);
1281
+	    $all_data = json_decode($buffer, true);
1282 1282
 	    if (!empty($all_data)) $reset = 0;
1283 1283
 	    foreach ($all_data as $key => $line) {
1284 1284
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1316,11 +1316,11 @@  discard block
 block discarded – undo
1316 1316
 	    )
1317 1317
 	) {
1318 1318
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1319
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1319
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1320 1320
 	    //echo $buffer;
1321
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1322
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1323
-	    $all_data = json_decode($buffer,true);
1321
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1322
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1323
+	    $all_data = json_decode($buffer, true);
1324 1324
 	    if (json_last_error() != JSON_ERROR_NONE) {
1325 1325
 		die(json_last_error_msg());
1326 1326
 	    }
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
 			//$data['departure_airport_iata'] = $line[11];
1344 1344
 			//$data['arrival_airport_iata'] = $line[12];
1345 1345
 	    		//$data['emergency'] = ''; // emergency
1346
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1346
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1347 1347
 	    		$data['format_source'] = 'radarvirtueljson';
1348 1348
     			$data['id_source'] = $id_source;
1349 1349
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1364,14 +1364,14 @@  discard block
 block discarded – undo
1364 1364
 	) {
1365 1365
 	    //$buffer = $Common->getData($hosts[$id]);
1366 1366
 	    $buffer = $Common->getData($value['host'].'?'.time());
1367
-	    $all_data = json_decode(utf8_encode($buffer),true);
1367
+	    $all_data = json_decode(utf8_encode($buffer), true);
1368 1368
 	    
1369 1369
 	    if (isset($all_data['pireps'])) {
1370 1370
 		$reset = 0;
1371 1371
 	        foreach ($all_data['pireps'] as $line) {
1372 1372
 		    $data = array();
1373 1373
 		    $data['id'] = $line['id'];
1374
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1374
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1375 1375
 		    $data['ident'] = $line['callsign']; // ident
1376 1376
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1377 1377
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1401,9 +1401,9 @@  discard block
 block discarded – undo
1401 1401
 			$SI->add($data);
1402 1402
 		    //    print_r($data);
1403 1403
     		    } elseif ($line['icon'] === 'ct') {
1404
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1405
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1406
-			$typec = substr($data['ident'],-3);
1404
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1405
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1406
+			$typec = substr($data['ident'], -3);
1407 1407
 			$data['type'] = '';
1408 1408
 			if ($typec === 'APP') $data['type'] = 'Approach';
1409 1409
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1415 1415
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1416 1416
 			else $data['type'] = 'Observer';
1417
-			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']);
1417
+			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']);
1418 1418
 		    }
1419 1419
 		    unset($data);
1420 1420
 		}
@@ -1431,14 +1431,14 @@  discard block
 block discarded – undo
1431 1431
 	    //$buffer = $Common->getData($hosts[$id]);
1432 1432
 	    if ($globalDebug) echo 'Get Data...'."\n";
1433 1433
 	    $buffer = $Common->getData($value['host']);
1434
-	    $all_data = json_decode($buffer,true);
1434
+	    $all_data = json_decode($buffer, true);
1435 1435
 	    if ($buffer != '' && is_array($all_data)) {
1436 1436
 		$reset = 0;
1437 1437
 		foreach ($all_data as $line) {
1438 1438
 	    	    $data = array();
1439 1439
 	    	    //$data['id'] = $line['id']; // id not usable
1440 1440
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1441
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1441
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1442 1442
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1443 1443
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1444 1444
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1453,7 +1453,7 @@  discard block
 block discarded – undo
1453 1453
 	    	    //$data['datetime'] = $line['lastupdate'];
1454 1454
 	    	    //$data['last_update'] = $line['lastupdate'];
1455 1455
 	    	    if (isset($value['timezone'])) {
1456
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1456
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1457 1457
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1458 1458
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1459 1459
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1469,14 +1469,14 @@  discard block
 block discarded – undo
1469 1469
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1470 1470
 		    if (isset($line['aircraftname'])) {
1471 1471
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1472
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1473
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1472
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1473
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1474 1474
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1475 1475
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1476 1476
 	    		else {
1477
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1478
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1479
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1477
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1478
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1479
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1480 1480
 	    		}
1481 1481
 	    	    }
1482 1482
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1501,7 +1501,7 @@  discard block
 block discarded – undo
1501 1501
 	    //$buffer = $Common->getData($hosts[$id]);
1502 1502
 	    if ($globalDebug) echo 'Get Data...'."\n";
1503 1503
 	    $buffer = $Common->getData($value['host']);
1504
-	    $all_data = json_decode($buffer,true);
1504
+	    $all_data = json_decode($buffer, true);
1505 1505
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1506 1506
 		$reset = 0;
1507 1507
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1513 1513
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1514 1514
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1515
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1515
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1516 1516
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1517 1517
 	    	    $data['altitude'] = $line['altitude']; // altitude
1518 1518
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
 	    	    //$data['squawk'] = ''; // squawk
1524 1524
 	    	    //$data['emergency'] = ''; // emergency
1525 1525
 	    	    if (isset($value['timezone'])) {
1526
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1526
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1527 1527
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1528 1528
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1529 1529
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1559,14 +1559,14 @@  discard block
 block discarded – undo
1559 1559
 	    //$buffer = $Common->getData($hosts[$id]);
1560 1560
 	    if ($globalDebug) echo 'Get Data...'."\n";
1561 1561
 	    $buffer = $Common->getData($value['host']);
1562
-	    $all_data = json_decode($buffer,true);
1562
+	    $all_data = json_decode($buffer, true);
1563 1563
 	    if ($buffer != '' && is_array($all_data)) {
1564 1564
 		$reset = 0;
1565 1565
 		foreach ($all_data as $line) {
1566 1566
 	    	    $data = array();
1567 1567
 	    	    //$data['id'] = $line['id']; // id not usable
1568 1568
 	    	    $data['id'] = trim($line['flight_id']);
1569
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1569
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1570 1570
 	    	    $data['pilot_name'] = $line['pilot_name'];
1571 1571
 	    	    $data['pilot_id'] = $line['pilot_id'];
1572 1572
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1610,24 +1610,24 @@  discard block
 block discarded – undo
1610 1610
 	    //$buffer = $Common->getData($hosts[$id]);
1611 1611
 	    if ($globalDebug) echo 'Get Data...'."\n";
1612 1612
 	    $buffer = $Common->getData($value['host']);
1613
-	    $all_data = json_decode($buffer,true);
1613
+	    $all_data = json_decode($buffer, true);
1614 1614
 	    if ($buffer != '') {
1615 1615
 		$Source->deleteLocationBySource('blitzortung');
1616
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1617
-		$buffer = explode('\n',$buffer);
1616
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1617
+		$buffer = explode('\n', $buffer);
1618 1618
 		foreach ($buffer as $buffer_line) {
1619
-		    $line = json_decode($buffer_line,true);
1619
+		    $line = json_decode($buffer_line, true);
1620 1620
 		    if (isset($line['time'])) {
1621 1621
 			$data = array();
1622 1622
 			$data['altitude'] = $line['alt']; // altitude
1623 1623
 			$data['latitude'] = $line['lat']; // lat
1624 1624
 			$data['longitude'] = $line['lon']; // long
1625
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1625
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1626 1626
 			$data['id_source'] = $id_source;
1627 1627
 			$data['format_source'] = 'blitzortung';
1628 1628
 			$SI->add($data);
1629 1629
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1630
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1630
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1631 1631
 			unset($data);
1632 1632
 		    }
1633 1633
 		}
@@ -1639,15 +1639,15 @@  discard block
 block discarded – undo
1639 1639
         $arr = $httpfeeds;
1640 1640
         $w = $e = null;
1641 1641
         if (isset($arr[$id])) {
1642
-            $nn = stream_select($arr,$w,$e,$timeout);
1642
+            $nn = stream_select($arr, $w, $e, $timeout);
1643 1643
             if ($nn > 0) {
1644 1644
                 foreach ($httpfeeds as $feed) {
1645
-                    $buffer = stream_get_line($feed,2000,"\n");
1645
+                    $buffer = stream_get_line($feed, 2000, "\n");
1646 1646
                     if ($buffer === FALSE) {
1647 1647
                         connect_all($globalSources);
1648 1648
                     }
1649
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1650
-                    $buffer = explode('\n',$buffer);
1649
+                    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1650
+                    $buffer = explode('\n', $buffer);
1651 1651
                     foreach ($buffer as $line) {
1652 1652
                         if ($line != '') {
1653 1653
                             $line = json_decode($line, true);
@@ -1687,11 +1687,11 @@  discard block
 block discarded – undo
1687 1687
 		    //$value = $formats[$nb];
1688 1688
 		    $format = $globalSources[$nb]['format'];
1689 1689
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1690
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1690
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1691 1691
 		    } elseif ($format === 'vrstcp') {
1692 1692
 			$buffer = @socket_read($r, 6000);
1693 1693
 		    } else {
1694
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1694
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1695 1695
 		    }
1696 1696
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1697 1697
 		    //echo $buffer."\n";
@@ -1701,8 +1701,8 @@  discard block
 block discarded – undo
1701 1701
 		    //$SI::del();
1702 1702
 		    if ($buffer !== FALSE) {
1703 1703
 			if ($format === 'vrstcp') {
1704
-			    $buffer = explode('},{',$buffer);
1705
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1704
+			    $buffer = explode('},{', $buffer);
1705
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1706 1706
 		    }
1707 1707
 		    // SBS format is CSV format
1708 1708
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1729,7 +1729,7 @@  discard block
 block discarded – undo
1729 1729
 			    $ais_data = $AIS->parse_line(trim($buffer));
1730 1730
 			    $data = array();
1731 1731
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1732
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1732
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1733 1733
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1734 1734
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1735 1735
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1740,13 +1740,13 @@  discard block
 block discarded – undo
1740 1740
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1741 1741
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1742 1742
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1743
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1743
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1744 1744
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1745 1745
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1746 1746
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1747 1747
 
1748 1748
 			    if (isset($ais_data['timestamp'])) {
1749
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1749
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1750 1750
 			    } else {
1751 1751
 				$data['datetime'] = date('Y-m-d H:i:s');
1752 1752
 			    }
@@ -1757,10 +1757,10 @@  discard block
 block discarded – undo
1757 1757
                         } elseif ($format === 'flightgearsp') {
1758 1758
                     	    //echo $buffer."\n";
1759 1759
                     	    if (strlen($buffer) > 5) {
1760
-				$line = explode(',',$buffer);
1760
+				$line = explode(',', $buffer);
1761 1761
 				$data = array();
1762 1762
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1763
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1763
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1764 1764
 				$data['ident'] = $line[6];
1765 1765
 				$data['aircraft_name'] = $line[7];
1766 1766
 				$data['longitude'] = $line[1];
@@ -1777,25 +1777,25 @@  discard block
 block discarded – undo
1777 1777
                         } elseif ($format === 'acars') {
1778 1778
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1779 1779
 			    $ACARS->add(trim($buffer));
1780
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1780
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1781 1781
 			    $ACARS->deleteLiveAcarsData();
1782 1782
 			} elseif ($format === 'acarsjsonudp') {
1783 1783
 			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1784 1784
                             $line = json_decode(trim($buffer), true);
1785 1785
                             if (!empty($line)) {
1786
-				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line);
1786
+				$line = array_merge(array('text' => '', 'tail' => '', 'label' => '', 'block_id' => '', 'flight' => '', 'msgno' => ''), $line);
1787 1787
                                 $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1788 1788
                                 $ACARS->deleteLiveAcarsData();
1789 1789
                             }
1790
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1790
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1791 1791
 			} elseif ($format === 'flightgearmp') {
1792
-			    if (substr($buffer,0,1) != '#') {
1792
+			    if (substr($buffer, 0, 1) != '#') {
1793 1793
 				$data = array();
1794 1794
 				//echo $buffer."\n";
1795
-				$line = explode(' ',$buffer);
1795
+				$line = explode(' ', $buffer);
1796 1796
 				if (count($line) === 11) {
1797
-				    $userserver = explode('@',$line[0]);
1798
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1797
+				    $userserver = explode('@', $line[0]);
1798
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1799 1799
 				    $data['ident'] = $userserver[0];
1800 1800
 				    $data['registration'] = $userserver[0];
1801 1801
 				    $data['latitude'] = $line[4];
@@ -1803,8 +1803,8 @@  discard block
 block discarded – undo
1803 1803
 				    $data['altitude'] = $line[6];
1804 1804
 				    $data['datetime'] = date('Y-m-d H:i:s');
1805 1805
 				    $aircraft_type = $line[10];
1806
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1807
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1806
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1807
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1808 1808
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1809 1809
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1810 1810
 				}
@@ -1813,8 +1813,8 @@  discard block
 block discarded – undo
1813 1813
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1814 1814
 			    die;
1815 1815
 			} elseif ($format === 'vrstcp') {
1816
-			    foreach($buffer as $all_data) {
1817
-				$line = json_decode('{'.$all_data.'}',true);
1816
+			    foreach ($buffer as $all_data) {
1817
+				$line = json_decode('{'.$all_data.'}', true);
1818 1818
 				$data = array();
1819 1819
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1820 1820
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1840,16 +1840,16 @@  discard block
 block discarded – undo
1840 1840
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1841 1841
 				unset($data);
1842 1842
 			    }
1843
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1843
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1844 1844
 			    $line = explode("\t", $buffer);
1845
-			    for($k = 0; $k < count($line); $k=$k+2) {
1845
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1846 1846
 				$key = $line[$k];
1847
-			        $lined[$key] = $line[$k+1];
1847
+			        $lined[$key] = $line[$k + 1];
1848 1848
 			    }
1849 1849
     			    if (count($lined) > 3) {
1850 1850
     				$data['hex'] = $lined['hexid'];
1851 1851
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1852
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1852
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1853 1853
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1854 1854
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1855 1855
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1868,23 +1868,23 @@  discard block
 block discarded – undo
1868 1868
     			    } else $error = true;
1869 1869
 			} elseif ($format === 'aprs' && $use_aprs) {
1870 1870
 			    if ($aprs_connect === 0) {
1871
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1871
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1872 1872
 				$aprs_connect = 1;
1873 1873
 			    }
1874 1874
 			    
1875
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1875
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1876 1876
 				$aprs_last_tx = time();
1877 1877
 				$data_aprs = "# Keep alive";
1878
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1878
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1879 1879
 			    }
1880 1880
 			    
1881 1881
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1882 1882
 			    //echo 'APRS data : '.$buffer."\n";
1883
-			    $buffer = str_replace('APRS <- ','',$buffer);
1884
-			    $buffer = str_replace('APRS -> ','',$buffer);
1883
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1884
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1885 1885
 			    //echo $buffer."\n";
1886 1886
 			    date_default_timezone_set('UTC');
1887
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1887
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1888 1888
 				$line = $APRS->parse($buffer);
1889 1889
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1890 1890
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1899,7 +1899,7 @@  discard block
 block discarded – undo
1899 1899
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1900 1900
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1901 1901
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1902
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1902
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1903 1903
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1904 1904
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1905 1905
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1987,29 +1987,29 @@  discard block
 block discarded – undo
1987 1987
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1988 1988
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1989 1989
 					$Source->deleteOldLocationByType('gs');
1990
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1991
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1990
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1991
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1992 1992
 					} else {
1993
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1993
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1994 1994
 					}
1995 1995
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1996 1996
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1997 1997
 					if ($globalDebug) echo '# Weather Station added'."\n";
1998 1998
 					$Source->deleteOldLocationByType('wx');
1999 1999
 					$weather_data = json_encode($line);
2000
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
2001
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2000
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
2001
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2002 2002
 					} else {
2003
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2003
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2004 2004
 					}
2005 2005
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2006 2006
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2007 2007
 					if ($globalDebug) echo '☈ Lightning added'."\n";
2008 2008
 					$Source->deleteOldLocationByType('lightning');
2009
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
2010
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2009
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
2010
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2011 2011
 					} else {
2012
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2012
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2013 2013
 					}
2014 2014
 				    } elseif ($globalDebug) {
2015 2015
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -2018,7 +2018,7 @@  discard block
 block discarded – undo
2018 2018
 				    unset($data);
2019 2019
 				}
2020 2020
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2021
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2021
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
2022 2022
 				}
2023 2023
 				/*
2024 2024
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) {
@@ -2027,7 +2027,7 @@  discard block
 block discarded – undo
2027 2027
 				*/
2028 2028
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2029 2029
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2030
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2030
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
2031 2031
 					$Source->deleteOldLocationByType('lightning');
2032 2032
 					$Source->deleteOldLocationByType('wx');
2033 2033
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2114,7 +2114,7 @@  discard block
 block discarded – undo
2114 2114
 				connect_all($sourceee);
2115 2115
 				$sourceee = array();
2116 2116
 				//connect_all($globalSources);
2117
-				$tt[$format]=0;
2117
+				$tt[$format] = 0;
2118 2118
 				break;
2119 2119
 			    } 
2120 2120
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2124,14 +2124,14 @@  discard block
 block discarded – undo
2124 2124
 	    } else {
2125 2125
 		$error = socket_strerror(socket_last_error());
2126 2126
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2127
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2127
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2128 2128
 			if (isset($globalDebug)) echo "Restarting...\n";
2129 2129
 			// Restart the script if possible
2130 2130
 			if (is_array($sockets)) {
2131 2131
 			    if ($globalDebug) echo "Shutdown all sockets...";
2132 2132
 			    
2133 2133
 			    foreach ($sockets as $sock) {
2134
-				@socket_shutdown($sock,2);
2134
+				@socket_shutdown($sock, 2);
2135 2135
 				@socket_close($sock);
2136 2136
 			    }
2137 2137
 			    
Please login to merge, or discard this patch.