Completed
Push — master ( bc1889...67b374 )
by Yannick
31:00
created
scripts/daemon-spotter.php 3 patches
Indentation   +1016 added lines, -1016 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 57
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 if (isset($options['idsource'])) $id_source = $options['idsource'];
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
106
+	if ($globalDebug) echo "Using Server Mode\n";
107
+	$SI=new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
117
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
117
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 119
 }
120 120
 
121 121
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
122 122
 if (isset($globalMarine) && $globalMarine) {
123
-    $AIS = new AIS();
124
-    $MI = new MarineImport($Connection->db);
123
+	$AIS = new AIS();
124
+	$MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127 127
 $SBS=new SBS();
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
138
-        global $sockets;
139
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
-        die("Bye!\n");
141
-    });
142
-    pcntl_signal_dispatch();
137
+	pcntl_signal(SIGINT,  function() {
138
+		global $sockets;
139
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
+		die("Bye!\n");
141
+	});
142
+	pcntl_signal_dispatch();
143 143
 }
144 144
 
145 145
 // let's try and connect
@@ -149,36 +149,36 @@  discard block
 block discarded – undo
149 149
 $reset = 0;
150 150
 
151 151
 function connect_all($hosts) {
152
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
-    $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
156
-    foreach ($hosts as $id => $value) {
152
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
+	$reset++;
155
+	if ($globalDebug) echo 'Connect to all...'."\n";
156
+	foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160 160
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
162
-        	//$formats[$id] = 'deltadbtxt';
163
-        	$globalSources[$id]['format'] = 'deltadbtxt';
164
-        	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
-        	//$formats[$id] = 'vatsimtxt';
168
-        	$globalSources[$id]['format'] = 'vatsimtxt';
169
-        	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172
-        	//$formats[$id] = 'aircraftlistjson';
173
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
174
-        	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/opensky/i',$host)) {
177
-        	//$formats[$id] = 'aircraftlistjson';
178
-        	$globalSources[$id]['format'] = 'opensky';
179
-        	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
181
-    	    /*
161
+			if (preg_match('/deltadb.txt$/i',$host)) {
162
+			//$formats[$id] = 'deltadbtxt';
163
+			$globalSources[$id]['format'] = 'deltadbtxt';
164
+			//$last_exec['deltadbtxt'] = 0;
165
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
+			//$formats[$id] = 'vatsimtxt';
168
+			$globalSources[$id]['format'] = 'vatsimtxt';
169
+			//$last_exec['vatsimtxt'] = 0;
170
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
172
+			//$formats[$id] = 'aircraftlistjson';
173
+			$globalSources[$id]['format'] = 'aircraftlistjson';
174
+			//$last_exec['aircraftlistjson'] = 0;
175
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
+			} else if (preg_match('/opensky/i',$host)) {
177
+			//$formats[$id] = 'aircraftlistjson';
178
+			$globalSources[$id]['format'] = 'opensky';
179
+			//$last_exec['aircraftlistjson'] = 0;
180
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
181
+			/*
182 182
     	    // Disabled for now, site change source format
183 183
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
184 184
         	//$formats[$id] = 'radarvirtueljson';
@@ -190,125 +190,125 @@  discard block
 block discarded – undo
190 190
         	    exit(0);
191 191
         	}
192 192
     	    */
193
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
194
-        	//$formats[$id] = 'planeupdatefaa';
195
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
196
-        	//$last_exec['planeupdatefaa'] = 0;
197
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
198
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
199
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200
-        	    exit(0);
201
-        	}
202
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
203
-        	//$formats[$id] = 'phpvmacars';
204
-        	$globalSources[$id]['format'] = 'phpvmacars';
205
-        	//$last_exec['phpvmacars'] = 0;
206
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
207
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
208
-        	//$formats[$id] = 'phpvmacars';
209
-        	$globalSources[$id]['format'] = 'vaos';
210
-        	//$last_exec['phpvmacars'] = 0;
211
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
212
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
213
-        	//$formats[$id] = 'phpvmacars';
214
-        	$globalSources[$id]['format'] = 'vam';
215
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
216
-            } else if (preg_match('/whazzup/i',$host)) {
217
-        	//$formats[$id] = 'whazzup';
218
-        	$globalSources[$id]['format'] = 'whazzup';
219
-        	//$last_exec['whazzup'] = 0;
220
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
221
-            } else if (preg_match('/blitzortung/i',$host)) {
222
-        	$globalSources[$id]['format'] = 'blitzortung';
223
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
224
-            } else if (preg_match('/airwhere/i',$host)) {
225
-        	$globalSources[$id]['format'] = 'airwhere';
226
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
227
-            } else if (preg_match('/recentpireps/i',$host)) {
228
-        	//$formats[$id] = 'pirepsjson';
229
-        	$globalSources[$id]['format'] = 'pirepsjson';
230
-        	//$last_exec['pirepsjson'] = 0;
231
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
232
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
233
-        	//$formats[$id] = 'fr24json';
234
-        	$globalSources[$id]['format'] = 'fr24json';
235
-        	//$last_exec['fr24json'] = 0;
236
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
237
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
238
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
239
-        	    exit(0);
240
-        	}
241
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
242
-        	//$formats[$id] = 'fr24json';
243
-        	$globalSources[$id]['format'] = 'myshiptracking';
244
-        	//$last_exec['fr24json'] = 0;
245
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
246
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
247
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
248
-        	    exit(0);
249
-        	}
250
-            //} else if (preg_match('/10001/',$host)) {
251
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
252
-        	//$formats[$id] = 'tsv';
253
-        	$globalSources[$id]['format'] = 'tsv';
254
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
255
-            }
256
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
257
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
258
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
259
-    		    if ($idf !== false) {
260
-    			$httpfeeds[$id] = $idf;
261
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
262
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
263
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
264
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
265
-	    $hostport = explode(':',$host);
266
-	    if (isset($hostport[1])) {
193
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
194
+			//$formats[$id] = 'planeupdatefaa';
195
+			$globalSources[$id]['format'] = 'planeupdatefaa';
196
+			//$last_exec['planeupdatefaa'] = 0;
197
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
198
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
199
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200
+				exit(0);
201
+			}
202
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
203
+			//$formats[$id] = 'phpvmacars';
204
+			$globalSources[$id]['format'] = 'phpvmacars';
205
+			//$last_exec['phpvmacars'] = 0;
206
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
207
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
208
+			//$formats[$id] = 'phpvmacars';
209
+			$globalSources[$id]['format'] = 'vaos';
210
+			//$last_exec['phpvmacars'] = 0;
211
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
212
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
213
+			//$formats[$id] = 'phpvmacars';
214
+			$globalSources[$id]['format'] = 'vam';
215
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
216
+			} else if (preg_match('/whazzup/i',$host)) {
217
+			//$formats[$id] = 'whazzup';
218
+			$globalSources[$id]['format'] = 'whazzup';
219
+			//$last_exec['whazzup'] = 0;
220
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
221
+			} else if (preg_match('/blitzortung/i',$host)) {
222
+			$globalSources[$id]['format'] = 'blitzortung';
223
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
224
+			} else if (preg_match('/airwhere/i',$host)) {
225
+			$globalSources[$id]['format'] = 'airwhere';
226
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
227
+			} else if (preg_match('/recentpireps/i',$host)) {
228
+			//$formats[$id] = 'pirepsjson';
229
+			$globalSources[$id]['format'] = 'pirepsjson';
230
+			//$last_exec['pirepsjson'] = 0;
231
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
232
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
233
+			//$formats[$id] = 'fr24json';
234
+			$globalSources[$id]['format'] = 'fr24json';
235
+			//$last_exec['fr24json'] = 0;
236
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
237
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
238
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
239
+				exit(0);
240
+			}
241
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
242
+			//$formats[$id] = 'fr24json';
243
+			$globalSources[$id]['format'] = 'myshiptracking';
244
+			//$last_exec['fr24json'] = 0;
245
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
246
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
247
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
248
+				exit(0);
249
+			}
250
+			//} else if (preg_match('/10001/',$host)) {
251
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
252
+			//$formats[$id] = 'tsv';
253
+			$globalSources[$id]['format'] = 'tsv';
254
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
255
+			}
256
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
257
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
258
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
259
+				if ($idf !== false) {
260
+				$httpfeeds[$id] = $idf;
261
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
262
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
263
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
264
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
265
+		$hostport = explode(':',$host);
266
+		if (isset($hostport[1])) {
267 267
 		$port = $hostport[1];
268 268
 		$hostn = $hostport[0];
269
-	    } else {
269
+		} else {
270 270
 		$port = $globalSources[$id]['port'];
271 271
 		$hostn = $globalSources[$id]['host'];
272
-	    }
273
-	    $Common = new Common();
274
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
275
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
276
-    	    } else {
277
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
278
-	    }
279
-	    if ($s) {
280
-    	        $sockets[$id] = $s;
281
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
282
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
272
+		}
273
+		$Common = new Common();
274
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
275
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
276
+			} else {
277
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
278
+		}
279
+		if ($s) {
280
+				$sockets[$id] = $s;
281
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
282
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
283 283
 			//$formats[$id] = 'aprs';
284 284
 			$globalSources[$id]['format'] = 'aprs';
285 285
 			//$aprs_connect = 0;
286 286
 			//$use_aprs = true;
287
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
287
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
288 288
 			$globalSources[$id]['format'] = 'vrstcp';
289
-    		    } elseif ($port == '10001') {
290
-        		//$formats[$id] = 'tsv';
291
-        		$globalSources[$id]['format'] = 'tsv';
292
-		    } elseif ($port == '30002') {
293
-        		//$formats[$id] = 'raw';
294
-        		$globalSources[$id]['format'] = 'raw';
295
-		    } elseif ($port == '5001') {
296
-        		//$formats[$id] = 'raw';
297
-        		$globalSources[$id]['format'] = 'flightgearmp';
298
-		    } elseif ($port == '30005') {
289
+				} elseif ($port == '10001') {
290
+				//$formats[$id] = 'tsv';
291
+				$globalSources[$id]['format'] = 'tsv';
292
+			} elseif ($port == '30002') {
293
+				//$formats[$id] = 'raw';
294
+				$globalSources[$id]['format'] = 'raw';
295
+			} elseif ($port == '5001') {
296
+				//$formats[$id] = 'raw';
297
+				$globalSources[$id]['format'] = 'flightgearmp';
298
+			} elseif ($port == '30005') {
299 299
 			// Not yet supported
300
-        		//$formats[$id] = 'beast';
301
-        		$globalSources[$id]['format'] = 'beast';
302
-		    //} else $formats[$id] = 'sbs';
303
-		    } else $globalSources[$id]['format'] = 'sbs';
304
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
300
+				//$formats[$id] = 'beast';
301
+				$globalSources[$id]['format'] = 'beast';
302
+			//} else $formats[$id] = 'sbs';
303
+			} else $globalSources[$id]['format'] = 'sbs';
304
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
305 305
 		}
306 306
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
307
-            } else {
307
+			} else {
308 308
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
309
-    	    }
310
-        }
311
-    }
309
+			}
310
+		}
311
+	}
312 312
 }
313 313
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
314 314
 
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 //connect_all($globalSources);
332 332
 
333 333
 if (isset($globalProxy) && $globalProxy) {
334
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
334
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
335 335
 } else {
336
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
336
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
337 337
 }
338 338
 
339 339
 // APRS Configuration
@@ -342,21 +342,21 @@  discard block
 block discarded – undo
342 342
 	die;
343 343
 }
344 344
 foreach ($globalSources as $key => $source) {
345
-    if (!isset($source['format'])) {
346
-        $globalSources[$key]['format'] = 'auto';
347
-    }
348
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
349
-        unset($globalSources[$key]);
350
-    }
345
+	if (!isset($source['format'])) {
346
+		$globalSources[$key]['format'] = 'auto';
347
+	}
348
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
349
+		unset($globalSources[$key]);
350
+	}
351 351
 }
352 352
 connect_all($globalSources);
353 353
 foreach ($globalSources as $key => $source) {
354
-    if (isset($source['format']) && $source['format'] == 'aprs') {
354
+	if (isset($source['format']) && $source['format'] == 'aprs') {
355 355
 	$aprs_connect = 0;
356 356
 	$use_aprs = true;
357 357
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
358 358
 	break;
359
-    }
359
+	}
360 360
 }
361 361
 
362 362
 if ($use_aprs) {
@@ -397,129 +397,129 @@  discard block
 block discarded – undo
397 397
 
398 398
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
399 399
 while ($i > 0) {
400
-    if (!$globalDaemon) $i = $endtime-time();
401
-    // Delete old ATC
402
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
400
+	if (!$globalDaemon) $i = $endtime-time();
401
+	// Delete old ATC
402
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
403 403
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
404
-        $ATC->deleteOldATC();
405
-    }
404
+		$ATC->deleteOldATC();
405
+	}
406 406
     
407
-    if (count($last_exec) == count($globalSources)) {
407
+	if (count($last_exec) == count($globalSources)) {
408 408
 	$max = $globalMinFetch;
409 409
 	foreach ($last_exec as $last) {
410
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
410
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
411 411
 	}
412 412
 	if ($max != $globalMinFetch) {
413
-	    if ($globalDebug) echo 'Sleeping...'."\n";
414
-	    sleep($globalMinFetch-$max+2);
413
+		if ($globalDebug) echo 'Sleeping...'."\n";
414
+		sleep($globalMinFetch-$max+2);
415
+	}
415 416
 	}
416
-    }
417 417
 
418 418
     
419
-    //foreach ($formats as $id => $value) {
420
-    foreach ($globalSources as $id => $value) {
419
+	//foreach ($formats as $id => $value) {
420
+	foreach ($globalSources as $id => $value) {
421 421
 	date_default_timezone_set('UTC');
422 422
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
423 423
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
424 424
 	if ($value['format'] == 'deltadbtxt' && 
425
-	    (
425
+		(
426 426
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
427 427
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
428
-	    )
428
+		)
429 429
 	) {
430
-	    //$buffer = $Common->getData($hosts[$id]);
431
-	    $buffer = $Common->getData($value['host']);
432
-	    if ($buffer != '') $reset = 0;
433
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434
-	    $buffer = explode('\n',$buffer);
435
-	    foreach ($buffer as $line) {
436
-    		if ($line != '' && count($line) > 7) {
437
-    		    $line = explode(',', $line);
438
-	            $data = array();
439
-	            $data['hex'] = $line[1]; // hex
440
-	            $data['ident'] = $line[2]; // ident
441
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
442
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
443
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
444
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
445
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
446
-	            $data['verticalrate'] = ''; // vertical rate
447
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
448
-	            $data['emergency'] = ''; // emergency
449
-		    $data['datetime'] = date('Y-m-d H:i:s');
450
-		    $data['format_source'] = 'deltadbtxt';
451
-    		    $data['id_source'] = $id_source;
452
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
453
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
454
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
455
-    		    $SI->add($data);
456
-		    unset($data);
457
-    		}
458
-    	    }
459
-    	    $last_exec[$id]['last'] = time();
430
+		//$buffer = $Common->getData($hosts[$id]);
431
+		$buffer = $Common->getData($value['host']);
432
+		if ($buffer != '') $reset = 0;
433
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434
+		$buffer = explode('\n',$buffer);
435
+		foreach ($buffer as $line) {
436
+			if ($line != '' && count($line) > 7) {
437
+				$line = explode(',', $line);
438
+				$data = array();
439
+				$data['hex'] = $line[1]; // hex
440
+				$data['ident'] = $line[2]; // ident
441
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
442
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
443
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
444
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
445
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
446
+				$data['verticalrate'] = ''; // vertical rate
447
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
448
+				$data['emergency'] = ''; // emergency
449
+			$data['datetime'] = date('Y-m-d H:i:s');
450
+			$data['format_source'] = 'deltadbtxt';
451
+				$data['id_source'] = $id_source;
452
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
453
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
454
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
455
+				$SI->add($data);
456
+			unset($data);
457
+			}
458
+			}
459
+			$last_exec[$id]['last'] = time();
460 460
 	} elseif ($value['format'] == 'aisnmeatxt' && 
461
-	    (
461
+		(
462 462
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
463 463
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
464
-	    )
464
+		)
465 465
 	) {
466
-	    date_default_timezone_set('CET');
467
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
468
-	    date_default_timezone_set('UTC');
469
-	    if ($buffer != '') $reset = 0;
470
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
471
-	    $buffer = explode('\n',$buffer);
472
-	    foreach ($buffer as $line) {
466
+		date_default_timezone_set('CET');
467
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
468
+		date_default_timezone_set('UTC');
469
+		if ($buffer != '') $reset = 0;
470
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
471
+		$buffer = explode('\n',$buffer);
472
+		foreach ($buffer as $line) {
473 473
 		if ($line != '') {
474
-		    //echo "'".$line."'\n";
475
-		    $add = false;
476
-		    $ais_data = $AIS->parse_line(trim($line));
477
-		    $data = array();
478
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
479
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
480
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
481
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
482
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
483
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
484
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
485
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
486
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
487
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
488
-		    if (isset($ais_data['timestamp'])) {
474
+			//echo "'".$line."'\n";
475
+			$add = false;
476
+			$ais_data = $AIS->parse_line(trim($line));
477
+			$data = array();
478
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
479
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
480
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
481
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
482
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
483
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
484
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
485
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
486
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
487
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
488
+			if (isset($ais_data['timestamp'])) {
489 489
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
490 490
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
491
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
492
-			    $add = true;
491
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
492
+				$add = true;
493 493
 			}
494
-		    } else {
494
+			} else {
495 495
 			$data['datetime'] = date('Y-m-d H:i:s');
496 496
 			$add = true;
497
-		    }
498
-		    $data['format_source'] = 'aisnmeatxt';
499
-    		    $data['id_source'] = $id_source;
500
-		    //print_r($data);
501
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
502
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
503
-		    unset($data);
497
+			}
498
+			$data['format_source'] = 'aisnmeatxt';
499
+				$data['id_source'] = $id_source;
500
+			//print_r($data);
501
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
502
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
503
+			unset($data);
504 504
 		}
505
-    	    }
506
-    	    $last_exec[$id]['last'] = time();
505
+			}
506
+			$last_exec[$id]['last'] = time();
507 507
 	} elseif ($value['format'] == 'aisnmeahttp') {
508
-	    $arr = $httpfeeds;
509
-	    $w = $e = null;
508
+		$arr = $httpfeeds;
509
+		$w = $e = null;
510 510
 	    
511
-	    if (isset($arr[$id])) {
511
+		if (isset($arr[$id])) {
512 512
 		$nn = stream_select($arr,$w,$e,$timeout);
513 513
 		if ($nn > 0) {
514
-		    foreach ($httpfeeds as $feed) {
514
+			foreach ($httpfeeds as $feed) {
515 515
 			$buffer = stream_get_line($feed,2000,"\n");
516 516
 			if ($buffer === FALSE) {
517
-			    connect_all($globalSources);
517
+				connect_all($globalSources);
518 518
 			}
519 519
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
520 520
 			$buffer = explode('\n',$buffer);
521 521
 			foreach ($buffer as $line) {
522
-			    if ($line != '') {
522
+				if ($line != '') {
523 523
 				$ais_data = $AIS->parse_line(trim($line));
524 524
 				$data = array();
525 525
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -537,115 +537,115 @@  discard block
 block discarded – undo
537 537
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
538 538
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
539 539
 				if (isset($ais_data['timestamp'])) {
540
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
540
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
541 541
 				} else {
542
-				    $data['datetime'] = date('Y-m-d H:i:s');
542
+					$data['datetime'] = date('Y-m-d H:i:s');
543 543
 				}
544 544
 				$data['format_source'] = 'aisnmeahttp';
545 545
 				$data['id_source'] = $id_source;
546 546
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
547 547
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
548 548
 				unset($data);
549
-			    }
549
+				}
550
+			}
550 551
 			}
551
-		    }
552 552
 		} else {
553
-		    $format = $value['format'];
554
-		    if (isset($tt[$format])) $tt[$format]++;
555
-		    else $tt[$format] = 0;
556
-		    if ($tt[$format] > 30) {
553
+			$format = $value['format'];
554
+			if (isset($tt[$format])) $tt[$format]++;
555
+			else $tt[$format] = 0;
556
+			if ($tt[$format] > 30) {
557 557
 			if ($globalDebug) echo 'Reconnect...'."\n";
558 558
 			sleep(2);
559 559
 			//$sourceeen[] = $value;
560 560
 			//connect_all($sourceeen);
561 561
 			//$sourceeen = array();
562 562
 			connect_all($globalSources);
563
-		    }
563
+			}
564
+		}
564 565
 		}
565
-	    }
566 566
 	} elseif ($value['format'] == 'myshiptracking' && 
567
-	    (
567
+		(
568 568
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
569 569
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
570
-	    )
570
+		)
571 571
 	) {
572
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
573
-	    if ($buffer != '') {
572
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
573
+		if ($buffer != '') {
574 574
 		//echo $buffer;
575 575
 		$all_data = json_decode($buffer,true);
576 576
 		//print_r($all_data);
577 577
 		if (isset($all_data[0]['DATA'])) {
578
-		    foreach ($all_data[0]['DATA'] as $line) {
578
+			foreach ($all_data[0]['DATA'] as $line) {
579 579
 			if ($line != '') {
580
-			    $data = array();
581
-			    $data['ident'] = $line['NAME'];
582
-			    $data['mmsi'] = $line['MMSI'];
583
-			    if (strlen($data['mmsi']) > 9) {
580
+				$data = array();
581
+				$data['ident'] = $line['NAME'];
582
+				$data['mmsi'] = $line['MMSI'];
583
+				if (strlen($data['mmsi']) > 9) {
584 584
 				$data['mmsi'] = substr($data['mmsi'],-9);
585
-			    }
586
-			    $data['speed'] = $line['SOG'];
587
-			    $data['heading'] = $line['COG'];
588
-			    $data['latitude'] = $line['LAT'];
589
-			    $data['longitude'] = $line['LNG'];
590
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
591
-			    $data['imo'] = $line['IMO'];
592
-			    //$data['arrival_code'] = $ais_data['destination'];
593
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
594
-			    $data['format_source'] = 'myshiptracking';
595
-			    $data['id_source'] = $id_source;
596
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
597
-			    $MI->add($data);
598
-			    unset($data);
585
+				}
586
+				$data['speed'] = $line['SOG'];
587
+				$data['heading'] = $line['COG'];
588
+				$data['latitude'] = $line['LAT'];
589
+				$data['longitude'] = $line['LNG'];
590
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
591
+				$data['imo'] = $line['IMO'];
592
+				//$data['arrival_code'] = $ais_data['destination'];
593
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
594
+				$data['format_source'] = 'myshiptracking';
595
+				$data['id_source'] = $id_source;
596
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
597
+				$MI->add($data);
598
+				unset($data);
599
+			}
599 600
 			}
600
-		    }
601 601
 		}
602
-	    }
603
-	    $last_exec[$id]['last'] = time();
602
+		}
603
+		$last_exec[$id]['last'] = time();
604 604
 	} elseif ($value['format'] == 'boatbeaconapp' && 
605
-	    (
605
+		(
606 606
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
607 607
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
608
-	    )
608
+		)
609 609
 	) {
610
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
611
-	    if ($buffer != '') {
610
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
611
+		if ($buffer != '') {
612 612
 		$all_data = json_decode($buffer,true);
613 613
 		if (isset($all_data[0]['mmsi'])) {
614
-		    foreach ($all_data as $line) {
614
+			foreach ($all_data as $line) {
615 615
 			if ($line != '') {
616
-			    $data = array();
617
-			    $data['ident'] = $line['shipname'];
618
-			    $data['callsign'] = $line['callsign'];
619
-			    $data['mmsi'] = $line['mmsi'];
620
-			    $data['speed'] = $line['sog'];
621
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
622
-			    $data['latitude'] = $line['latitude'];
623
-			    $data['longitude'] = $line['longitude'];
624
-			    $data['type_id'] = $line['shiptype'];
625
-			    $data['arrival_code'] = $line['destination'];
626
-			    $data['datetime'] = $line['time'];
627
-			    $data['format_source'] = 'boatbeaconapp';
628
-			    $data['id_source'] = $id_source;
629
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
630
-			    $MI->add($data);
631
-			    unset($data);
616
+				$data = array();
617
+				$data['ident'] = $line['shipname'];
618
+				$data['callsign'] = $line['callsign'];
619
+				$data['mmsi'] = $line['mmsi'];
620
+				$data['speed'] = $line['sog'];
621
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
622
+				$data['latitude'] = $line['latitude'];
623
+				$data['longitude'] = $line['longitude'];
624
+				$data['type_id'] = $line['shiptype'];
625
+				$data['arrival_code'] = $line['destination'];
626
+				$data['datetime'] = $line['time'];
627
+				$data['format_source'] = 'boatbeaconapp';
628
+				$data['id_source'] = $id_source;
629
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
630
+				$MI->add($data);
631
+				unset($data);
632
+			}
632 633
 			}
633
-		    }
634 634
 		}
635 635
 		
636
-	    }
637
-    	    $last_exec[$id]['last'] = time();
636
+		}
637
+			$last_exec[$id]['last'] = time();
638 638
 	} elseif ($value['format'] == 'boatnerd' && 
639
-	    (
639
+		(
640 640
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
641 641
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
642
-	    )
642
+		)
643 643
 	) {
644
-	    $buffer = $Common->getData($value['host']);
645
-	    if ($buffer != '') {
644
+		$buffer = $Common->getData($value['host']);
645
+		if ($buffer != '') {
646 646
 		$all_data = json_decode($buffer,true);
647 647
 		if (isset($all_data['features'][0]['id'])) {
648
-		    foreach ($all_data['features'] as $line) {
648
+			foreach ($all_data['features'] as $line) {
649 649
 			$data = array();
650 650
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
651 651
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -664,78 +664,78 @@  discard block
 block discarded – undo
664 664
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
665 665
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
666 666
 			unset($data);
667
-		    }
667
+			}
668 668
 		}
669 669
 		
670
-	    }
671
-    	    $last_exec[$id]['last'] = time();
670
+		}
671
+			$last_exec[$id]['last'] = time();
672 672
 	} elseif ($value['format'] == 'shipplotter' && 
673
-	    (
673
+		(
674 674
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
675 675
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
676
-	    )
676
+		)
677 677
 	) {
678
-	    echo 'download...';
679
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
680
-	    echo 'done !'."\n";
681
-	    if ($buffer != '') $reset = 0;
682
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
683
-	    $buffer = explode('\n',$buffer);
684
-	    foreach ($buffer as $line) {
678
+		echo 'download...';
679
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
680
+		echo 'done !'."\n";
681
+		if ($buffer != '') $reset = 0;
682
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
683
+		$buffer = explode('\n',$buffer);
684
+		foreach ($buffer as $line) {
685 685
 		if ($line != '') {
686
-		    $data = array();
687
-		    $data['mmsi'] = (int)substr($line,0,9);
688
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
689
-		    //$data['status'] = substr($line,21,2);
690
-		    //$data['type'] = substr($line,24,3);
691
-		    $data['latitude'] = substr($line,29,9);
692
-		    $data['longitude'] = substr($line,41,9);
693
-		    $data['speed'] = round(substr($line,51,5));
694
-		    //$data['course'] = substr($line,57,5);
695
-		    $data['heading'] = round(substr($line,63,3));
696
-		    //$data['draft'] = substr($line,67,4);
697
-		    //$data['length'] = substr($line,72,3);
698
-		    //$data['beam'] = substr($line,76,2);
699
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
700
-		    //$data['callsign'] = trim(substr($line,100,7);
701
-		    //$data['dest'] = substr($line,108,20);
702
-		    //$data['etaDate'] = substr($line,129,5);
703
-		    //$data['etaTime'] = substr($line,135,5);
704
-		    $data['format_source'] = 'shipplotter';
705
-    		    $data['id_source'] = $id_source;
706
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
707
-		    //print_r($data);
708
-		    echo 'Add...'."\n";
709
-		    $MI->add($data);
710
-		    unset($data);
686
+			$data = array();
687
+			$data['mmsi'] = (int)substr($line,0,9);
688
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
689
+			//$data['status'] = substr($line,21,2);
690
+			//$data['type'] = substr($line,24,3);
691
+			$data['latitude'] = substr($line,29,9);
692
+			$data['longitude'] = substr($line,41,9);
693
+			$data['speed'] = round(substr($line,51,5));
694
+			//$data['course'] = substr($line,57,5);
695
+			$data['heading'] = round(substr($line,63,3));
696
+			//$data['draft'] = substr($line,67,4);
697
+			//$data['length'] = substr($line,72,3);
698
+			//$data['beam'] = substr($line,76,2);
699
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
700
+			//$data['callsign'] = trim(substr($line,100,7);
701
+			//$data['dest'] = substr($line,108,20);
702
+			//$data['etaDate'] = substr($line,129,5);
703
+			//$data['etaTime'] = substr($line,135,5);
704
+			$data['format_source'] = 'shipplotter';
705
+				$data['id_source'] = $id_source;
706
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
707
+			//print_r($data);
708
+			echo 'Add...'."\n";
709
+			$MI->add($data);
710
+			unset($data);
711 711
 		}
712
-    	    }
713
-    	    $last_exec[$id]['last'] = time();
712
+			}
713
+			$last_exec[$id]['last'] = time();
714 714
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
715 715
 	} elseif (
716
-	    (
716
+		(
717 717
 		$value['format'] == 'whazzup' && 
718 718
 		(
719
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
720
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
719
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
720
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
721 721
 		)
722
-	    ) || (
722
+		) || (
723 723
 		$value['format'] == 'vatsimtxt' && 
724 724
 		(
725
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
726
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
725
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
726
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
727
+		)
727 728
 		)
728
-	    )
729 729
 	) {
730
-	    //$buffer = $Common->getData($hosts[$id]);
731
-	    $buffer = $Common->getData($value['host']);
732
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
733
-	    $buffer = explode('\n',$buffer);
734
-	    $reset = 0;
735
-	    foreach ($buffer as $line) {
736
-    		if ($line != '') {
737
-    		    $line = explode(':', $line);
738
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
730
+		//$buffer = $Common->getData($hosts[$id]);
731
+		$buffer = $Common->getData($value['host']);
732
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
733
+		$buffer = explode('\n',$buffer);
734
+		$reset = 0;
735
+		foreach ($buffer as $line) {
736
+			if ($line != '') {
737
+				$line = explode(':', $line);
738
+				if (count($line) > 30 && $line[0] != 'callsign') {
739 739
 			$data = array();
740 740
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
741 741
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -748,37 +748,37 @@  discard block
 block discarded – undo
748 748
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
749 749
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
750 750
 			$data['latitude'] = $line[5]; // lat
751
-	        	$data['longitude'] = $line[6]; // long
752
-	        	$data['verticalrate'] = ''; // vertical rate
753
-	        	$data['squawk'] = ''; // squawk
754
-	        	$data['emergency'] = ''; // emergency
755
-	        	$data['waypoints'] = $line[30];
751
+				$data['longitude'] = $line[6]; // long
752
+				$data['verticalrate'] = ''; // vertical rate
753
+				$data['squawk'] = ''; // squawk
754
+				$data['emergency'] = ''; // emergency
755
+				$data['waypoints'] = $line[30];
756 756
 			$data['datetime'] = date('Y-m-d H:i:s');
757 757
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
758 758
 			//if (isset($line[37])) $data['last_update'] = $line[37];
759
-		        $data['departure_airport_icao'] = $line[11];
760
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
761
-		        $data['arrival_airport_icao'] = $line[13];
759
+				$data['departure_airport_icao'] = $line[11];
760
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
761
+				$data['arrival_airport_icao'] = $line[13];
762 762
 			$data['frequency'] = $line[4];
763 763
 			$data['type'] = $line[18];
764 764
 			$data['range'] = $line[19];
765 765
 			if (isset($line[35])) $data['info'] = $line[35];
766
-    			$data['id_source'] = $id_source;
767
-	    		//$data['arrival_airport_time'] = ;
768
-	    		if ($line[9] != '') {
769
-	    		    $aircraft_data = explode('/',$line[9]);
770
-	    		    if (isset($aircraft_data[1])) {
771
-	    			$data['aircraft_icao'] = $aircraft_data[1];
772
-	    		    }
773
-        		}
774
-	    		/*
766
+				$data['id_source'] = $id_source;
767
+				//$data['arrival_airport_time'] = ;
768
+				if ($line[9] != '') {
769
+					$aircraft_data = explode('/',$line[9]);
770
+					if (isset($aircraft_data[1])) {
771
+					$data['aircraft_icao'] = $aircraft_data[1];
772
+					}
773
+				}
774
+				/*
775 775
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
776 776
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
777 777
 	    		*/
778
-	    		$data['format_source'] = $value['format'];
778
+				$data['format_source'] = $value['format'];
779 779
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
780 780
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
781
-    			if ($line[3] == 'PILOT') $SI->add($data);
781
+				if ($line[3] == 'PILOT') $SI->add($data);
782 782
 			elseif ($line[3] == 'ATC') {
783 783
 				//print_r($data);
784 784
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -799,21 +799,21 @@  discard block
 block discarded – undo
799 799
 					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']);
800 800
 				}
801 801
 			}
802
-    			unset($data);
803
-    		    }
804
-    		}
805
-    	    }
806
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
807
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
808
-    	    $last_exec[$id]['last'] = time();
809
-    	} elseif ($value['format'] == 'airwhere' && 
810
-    	    (
811
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
812
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
813
-    	    )
814
-    	) {
815
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
816
-	    if ($buffer != '') {
802
+				unset($data);
803
+				}
804
+			}
805
+			}
806
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
807
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
808
+			$last_exec[$id]['last'] = time();
809
+		} elseif ($value['format'] == 'airwhere' && 
810
+			(
811
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
812
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
813
+			)
814
+		) {
815
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
816
+		if ($buffer != '') {
817 817
 		$all_data = simplexml_load_string($buffer);
818 818
 		foreach($all_data->children() as $childdata) {
819 819
 			$data = array();
@@ -835,10 +835,10 @@  discard block
 block discarded – undo
835 835
 			$SI->add($data);
836 836
 			unset($data);
837 837
 		}
838
-	    }
839
-	    $Source->deleteOldLocationByType('gs');
840
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
841
-	    if ($buffer != '') {
838
+		}
839
+		$Source->deleteOldLocationByType('gs');
840
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
841
+		if ($buffer != '') {
842 842
 		$all_data = simplexml_load_string($buffer);
843 843
 		foreach($all_data->children() as $childdata) {
844 844
 			$data = array();
@@ -856,8 +856,8 @@  discard block
 block discarded – undo
856 856
 			}
857 857
 			unset($data);
858 858
 		}
859
-	    }
860
-	    $last_exec[$id]['last'] = time();
859
+		}
860
+		$last_exec[$id]['last'] = time();
861 861
 	/*
862 862
 	} if ($value['format'] == 'aircraftlistjson') {
863 863
 	    print_r($globalSources);
@@ -865,17 +865,17 @@  discard block
 block discarded – undo
865 865
 	    echo $globalMinFetch;
866 866
 	*/
867 867
 	} elseif ($value['format'] == 'aircraftlistjson' && 
868
-	    (
868
+		(
869 869
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
870 870
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
871
-	    )
871
+		)
872 872
 	) {
873
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
874
-	    if ($buffer != '') {
875
-	        $all_data = json_decode($buffer,true);
873
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
874
+		if ($buffer != '') {
875
+			$all_data = json_decode($buffer,true);
876 876
 		if (isset($all_data['acList'])) {
877
-		    $reset = 0;
878
-		    foreach ($all_data['acList'] as $line) {
877
+			$reset = 0;
878
+			foreach ($all_data['acList'] as $line) {
879 879
 			$data = array();
880 880
 			$data['hex'] = $line['Icao']; // hex
881 881
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -898,10 +898,10 @@  discard block
 block discarded – undo
898 898
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
899 899
 			if (isset($data['latitude'])) $SI->add($data);
900 900
 			unset($data);
901
-		    }
901
+			}
902 902
 		} elseif (is_array($all_data)) {
903
-		    $reset = 0;
904
-		    foreach ($all_data as $line) {
903
+			$reset = 0;
904
+			foreach ($all_data as $line) {
905 905
 			$data = array();
906 906
 			$data['hex'] = $line['hex']; // hex
907 907
 			$data['ident'] = $line['flight']; // ident
@@ -921,218 +921,218 @@  discard block
 block discarded – undo
921 921
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
922 922
 			$SI->add($data);
923 923
 			unset($data);
924
-		    }
924
+			}
925 925
 		}
926
-	    } elseif ($globalDebug) echo 'No data'."\n";
927
-    	    //$last_exec['aircraftlistjson'] = time();
928
-    	    $last_exec[$id]['last'] = time();
929
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
930
-    	} elseif ($value['format'] == 'planeupdatefaa' && 
931
-    	    (
932
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
933
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
934
-    	    )
935
-    	) {
936
-	    $buffer = $Common->getData($value['host']);
937
-	    $all_data = json_decode($buffer,true);
938
-	    if (isset($all_data['planes'])) {
926
+		} elseif ($globalDebug) echo 'No data'."\n";
927
+			//$last_exec['aircraftlistjson'] = time();
928
+			$last_exec[$id]['last'] = time();
929
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
930
+		} elseif ($value['format'] == 'planeupdatefaa' && 
931
+			(
932
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
933
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
934
+			)
935
+		) {
936
+		$buffer = $Common->getData($value['host']);
937
+		$all_data = json_decode($buffer,true);
938
+		if (isset($all_data['planes'])) {
939 939
 		$reset = 0;
940 940
 		foreach ($all_data['planes'] as $key => $line) {
941
-		    $data = array();
942
-		    $data['hex'] = $key; // hex
943
-		    $data['ident'] = $line[3]; // ident
944
-		    $data['altitude'] = $line[6]; // altitude
945
-		    $data['speed'] = $line[8]; // speed
946
-		    $data['heading'] = $line[7]; // heading
947
-		    $data['latitude'] = $line[4]; // lat
948
-		    $data['longitude'] = $line[5]; // long
949
-		    //$data['verticalrate'] = $line[]; // verticale rate
950
-		    $data['squawk'] = $line[10]; // squawk
951
-		    $data['emergency'] = ''; // emergency
952
-		    $data['registration'] = $line[2];
953
-		    $data['aircraft_icao'] = $line[0];
954
-		    $deparr = explode('-',$line[1]);
955
-		    if (count($deparr) == 2) {
941
+			$data = array();
942
+			$data['hex'] = $key; // hex
943
+			$data['ident'] = $line[3]; // ident
944
+			$data['altitude'] = $line[6]; // altitude
945
+			$data['speed'] = $line[8]; // speed
946
+			$data['heading'] = $line[7]; // heading
947
+			$data['latitude'] = $line[4]; // lat
948
+			$data['longitude'] = $line[5]; // long
949
+			//$data['verticalrate'] = $line[]; // verticale rate
950
+			$data['squawk'] = $line[10]; // squawk
951
+			$data['emergency'] = ''; // emergency
952
+			$data['registration'] = $line[2];
953
+			$data['aircraft_icao'] = $line[0];
954
+			$deparr = explode('-',$line[1]);
955
+			if (count($deparr) == 2) {
956 956
 			$data['departure_airport_icao'] = $deparr[0];
957 957
 			$data['arrival_airport_icao'] = $deparr[1];
958
-		    }
959
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
960
-	    	    $data['format_source'] = 'planeupdatefaa';
961
-    		    $data['id_source'] = $id_source;
962
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
963
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
964
-		    $SI->add($data);
965
-		    unset($data);
958
+			}
959
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
960
+				$data['format_source'] = 'planeupdatefaa';
961
+				$data['id_source'] = $id_source;
962
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
963
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
964
+			$SI->add($data);
965
+			unset($data);
966
+		}
966 967
 		}
967
-	    }
968
-	    //$last_exec['planeupdatefaa'] = time();
969
-	    $last_exec[$id]['last'] = time();
968
+		//$last_exec['planeupdatefaa'] = time();
969
+		$last_exec[$id]['last'] = time();
970 970
 	} elseif ($value['format'] == 'opensky' && 
971
-	    (
971
+		(
972 972
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
973 973
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
974
-	    )
974
+		)
975 975
 	) {
976
-	    $buffer = $Common->getData($value['host']);
977
-	    $all_data = json_decode($buffer,true);
978
-	    if (isset($all_data['states'])) {
976
+		$buffer = $Common->getData($value['host']);
977
+		$all_data = json_decode($buffer,true);
978
+		if (isset($all_data['states'])) {
979 979
 		$reset = 0;
980 980
 		foreach ($all_data['states'] as $key => $line) {
981
-		    $data = array();
982
-		    $data['hex'] = $line[0]; // hex
983
-		    $data['ident'] = trim($line[1]); // ident
984
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
985
-		    $data['speed'] = round($line[9]*1.94384); // speed
986
-		    $data['heading'] = round($line[10]); // heading
987
-		    $data['latitude'] = $line[6]; // lat
988
-		    $data['longitude'] = $line[5]; // long
989
-		    $data['verticalrate'] = $line[11]; // verticale rate
990
-		    //$data['squawk'] = $line[10]; // squawk
991
-		    //$data['emergency'] = ''; // emergency
992
-		    //$data['registration'] = $line[2];
993
-		    //$data['aircraft_icao'] = $line[0];
994
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
995
-		    $data['format_source'] = 'opensky';
996
-		    $data['id_source'] = $id_source;
997
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
998
-		    $SI->add($data);
999
-		    unset($data);
981
+			$data = array();
982
+			$data['hex'] = $line[0]; // hex
983
+			$data['ident'] = trim($line[1]); // ident
984
+			$data['altitude'] = round($line[7]*3.28084); // altitude
985
+			$data['speed'] = round($line[9]*1.94384); // speed
986
+			$data['heading'] = round($line[10]); // heading
987
+			$data['latitude'] = $line[6]; // lat
988
+			$data['longitude'] = $line[5]; // long
989
+			$data['verticalrate'] = $line[11]; // verticale rate
990
+			//$data['squawk'] = $line[10]; // squawk
991
+			//$data['emergency'] = ''; // emergency
992
+			//$data['registration'] = $line[2];
993
+			//$data['aircraft_icao'] = $line[0];
994
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
995
+			$data['format_source'] = 'opensky';
996
+			$data['id_source'] = $id_source;
997
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
998
+			$SI->add($data);
999
+			unset($data);
1000
+		}
1000 1001
 		}
1001
-	    }
1002
-	    //$last_exec['planeupdatefaa'] = time();
1003
-	    $last_exec[$id]['last'] = time();
1002
+		//$last_exec['planeupdatefaa'] = time();
1003
+		$last_exec[$id]['last'] = time();
1004 1004
 	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1005 1005
 	} elseif ($value['format'] == 'fr24json' && 
1006
-	    (
1006
+		(
1007 1007
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1008 1008
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1009
-	    )
1009
+		)
1010 1010
 	) {
1011
-	    //$buffer = $Common->getData($hosts[$id]);
1012
-	    $buffer = $Common->getData($value['host']);
1013
-	    $all_data = json_decode($buffer,true);
1014
-	    if (!empty($all_data)) $reset = 0;
1015
-	    foreach ($all_data as $key => $line) {
1011
+		//$buffer = $Common->getData($hosts[$id]);
1012
+		$buffer = $Common->getData($value['host']);
1013
+		$all_data = json_decode($buffer,true);
1014
+		if (!empty($all_data)) $reset = 0;
1015
+		foreach ($all_data as $key => $line) {
1016 1016
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1017
-		    $data = array();
1018
-		    $data['hex'] = $line[0];
1019
-		    $data['ident'] = $line[16]; //$line[13]
1020
-	    	    $data['altitude'] = $line[4]; // altitude
1021
-	    	    $data['speed'] = $line[5]; // speed
1022
-	    	    $data['heading'] = $line[3]; // heading
1023
-	    	    $data['latitude'] = $line[1]; // lat
1024
-	    	    $data['longitude'] = $line[2]; // long
1025
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1026
-	    	    $data['squawk'] = $line[6]; // squawk
1027
-	    	    $data['aircraft_icao'] = $line[8];
1028
-	    	    $data['registration'] = $line[9];
1029
-		    $data['departure_airport_iata'] = $line[11];
1030
-		    $data['arrival_airport_iata'] = $line[12];
1031
-	    	    $data['emergency'] = ''; // emergency
1032
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1033
-	    	    $data['format_source'] = 'fr24json';
1034
-    		    $data['id_source'] = $id_source;
1035
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1036
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1037
-		    $SI->add($data);
1038
-		    unset($data);
1017
+			$data = array();
1018
+			$data['hex'] = $line[0];
1019
+			$data['ident'] = $line[16]; //$line[13]
1020
+				$data['altitude'] = $line[4]; // altitude
1021
+				$data['speed'] = $line[5]; // speed
1022
+				$data['heading'] = $line[3]; // heading
1023
+				$data['latitude'] = $line[1]; // lat
1024
+				$data['longitude'] = $line[2]; // long
1025
+				$data['verticalrate'] = $line[15]; // verticale rate
1026
+				$data['squawk'] = $line[6]; // squawk
1027
+				$data['aircraft_icao'] = $line[8];
1028
+				$data['registration'] = $line[9];
1029
+			$data['departure_airport_iata'] = $line[11];
1030
+			$data['arrival_airport_iata'] = $line[12];
1031
+				$data['emergency'] = ''; // emergency
1032
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1033
+				$data['format_source'] = 'fr24json';
1034
+				$data['id_source'] = $id_source;
1035
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1036
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1037
+			$SI->add($data);
1038
+			unset($data);
1039 1039
 		}
1040
-	    }
1041
-	    //$last_exec['fr24json'] = time();
1042
-	    $last_exec[$id]['last'] = time();
1040
+		}
1041
+		//$last_exec['fr24json'] = time();
1042
+		$last_exec[$id]['last'] = time();
1043 1043
 	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1044 1044
 	} elseif ($value['format'] == 'radarvirtueljson' && 
1045
-	    (
1045
+		(
1046 1046
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1047 1047
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1048
-	    )
1048
+		)
1049 1049
 	) {
1050
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1051
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1052
-	    //echo $buffer;
1053
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1054
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1055
-	    $all_data = json_decode($buffer,true);
1056
-	    if (json_last_error() != JSON_ERROR_NONE) {
1050
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1051
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1052
+		//echo $buffer;
1053
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1054
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1055
+		$all_data = json_decode($buffer,true);
1056
+		if (json_last_error() != JSON_ERROR_NONE) {
1057 1057
 		die(json_last_error_msg());
1058
-	    }
1059
-	    if (isset($all_data['mrkrs'])) {
1058
+		}
1059
+		if (isset($all_data['mrkrs'])) {
1060 1060
 		$reset = 0;
1061 1061
 		foreach ($all_data['mrkrs'] as $key => $line) {
1062
-		    if (isset($line['inf'])) {
1062
+			if (isset($line['inf'])) {
1063 1063
 			$data = array();
1064 1064
 			$data['hex'] = $line['inf']['ia'];
1065 1065
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1066
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1067
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1068
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1069
-	    		$data['latitude'] = $line['pt'][0]; // lat
1070
-	    		$data['longitude'] = $line['pt'][1]; // long
1071
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1072
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1073
-	    		//$data['aircraft_icao'] = $line[8];
1074
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1066
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1067
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1068
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1069
+				$data['latitude'] = $line['pt'][0]; // lat
1070
+				$data['longitude'] = $line['pt'][1]; // long
1071
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1072
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1073
+				//$data['aircraft_icao'] = $line[8];
1074
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1075 1075
 			//$data['departure_airport_iata'] = $line[11];
1076 1076
 			//$data['arrival_airport_iata'] = $line[12];
1077
-	    		//$data['emergency'] = ''; // emergency
1077
+				//$data['emergency'] = ''; // emergency
1078 1078
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1079
-	    		$data['format_source'] = 'radarvirtueljson';
1080
-    			$data['id_source'] = $id_source;
1079
+				$data['format_source'] = 'radarvirtueljson';
1080
+				$data['id_source'] = $id_source;
1081 1081
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1082 1082
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1083 1083
 			$SI->add($data);
1084 1084
 			unset($data);
1085
-		    }
1085
+			}
1086 1086
 		}
1087
-	    }
1088
-	    //$last_exec['radarvirtueljson'] = time();
1089
-	    $last_exec[$id]['last'] = time();
1087
+		}
1088
+		//$last_exec['radarvirtueljson'] = time();
1089
+		$last_exec[$id]['last'] = time();
1090 1090
 	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1091 1091
 	} elseif ($value['format'] == 'pirepsjson' && 
1092
-	    (
1092
+		(
1093 1093
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1094 1094
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1095
-	    )
1095
+		)
1096 1096
 	) {
1097
-	    //$buffer = $Common->getData($hosts[$id]);
1098
-	    $buffer = $Common->getData($value['host'].'?'.time());
1099
-	    $all_data = json_decode(utf8_encode($buffer),true);
1097
+		//$buffer = $Common->getData($hosts[$id]);
1098
+		$buffer = $Common->getData($value['host'].'?'.time());
1099
+		$all_data = json_decode(utf8_encode($buffer),true);
1100 1100
 	    
1101
-	    if (isset($all_data['pireps'])) {
1101
+		if (isset($all_data['pireps'])) {
1102 1102
 		$reset = 0;
1103
-	        foreach ($all_data['pireps'] as $line) {
1104
-		    $data = array();
1105
-		    $data['id'] = $line['id'];
1106
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1107
-		    $data['ident'] = $line['callsign']; // ident
1108
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1109
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1110
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1111
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1112
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1113
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1114
-		    $data['latitude'] = $line['lat']; // lat
1115
-		    $data['longitude'] = $line['lon']; // long
1116
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1117
-		    //$data['squawk'] = $line['squawk']; // squawk
1118
-		    //$data['emergency'] = ''; // emergency
1119
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1120
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1121
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1122
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1123
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1124
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1125
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1126
-		    else $data['info'] = '';
1127
-		    $data['format_source'] = 'pireps';
1128
-    		    $data['id_source'] = $id_source;
1129
-		    $data['datetime'] = date('Y-m-d H:i:s');
1130
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1131
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1132
-		    if ($line['icon'] == 'plane') {
1103
+			foreach ($all_data['pireps'] as $line) {
1104
+			$data = array();
1105
+			$data['id'] = $line['id'];
1106
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1107
+			$data['ident'] = $line['callsign']; // ident
1108
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1109
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1110
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1111
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1112
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1113
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1114
+			$data['latitude'] = $line['lat']; // lat
1115
+			$data['longitude'] = $line['lon']; // long
1116
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1117
+			//$data['squawk'] = $line['squawk']; // squawk
1118
+			//$data['emergency'] = ''; // emergency
1119
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1120
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1121
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1122
+			//$data['arrival_airport_time'] = $line['arrtime'];
1123
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1124
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1125
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1126
+			else $data['info'] = '';
1127
+			$data['format_source'] = 'pireps';
1128
+				$data['id_source'] = $id_source;
1129
+			$data['datetime'] = date('Y-m-d H:i:s');
1130
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1131
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1132
+			if ($line['icon'] == 'plane') {
1133 1133
 			$SI->add($data);
1134
-		    //    print_r($data);
1135
-    		    } elseif ($line['icon'] == 'ct') {
1134
+			//    print_r($data);
1135
+				} elseif ($line['icon'] == 'ct') {
1136 1136
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1137 1137
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1138 1138
 			$typec = substr($data['ident'],-3);
@@ -1147,209 +1147,209 @@  discard block
 block discarded – undo
1147 1147
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1148 1148
 			else $data['type'] = 'Observer';
1149 1149
 			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']);
1150
-		    }
1151
-		    unset($data);
1150
+			}
1151
+			unset($data);
1152
+		}
1152 1153
 		}
1153
-	    }
1154
-	    //$last_exec['pirepsjson'] = time();
1155
-	    $last_exec[$id]['last'] = time();
1154
+		//$last_exec['pirepsjson'] = time();
1155
+		$last_exec[$id]['last'] = time();
1156 1156
 	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1157 1157
 	} elseif ($value['format'] == 'phpvmacars' && 
1158
-	    (
1158
+		(
1159 1159
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1160 1160
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1161
-	    )
1161
+		)
1162 1162
 	) {
1163
-	    //$buffer = $Common->getData($hosts[$id]);
1164
-	    if ($globalDebug) echo 'Get Data...'."\n";
1165
-	    $buffer = $Common->getData($value['host']);
1166
-	    $all_data = json_decode($buffer,true);
1167
-	    if ($buffer != '' && is_array($all_data)) {
1163
+		//$buffer = $Common->getData($hosts[$id]);
1164
+		if ($globalDebug) echo 'Get Data...'."\n";
1165
+		$buffer = $Common->getData($value['host']);
1166
+		$all_data = json_decode($buffer,true);
1167
+		if ($buffer != '' && is_array($all_data)) {
1168 1168
 		$reset = 0;
1169 1169
 		foreach ($all_data as $line) {
1170
-	    	    $data = array();
1171
-	    	    //$data['id'] = $line['id']; // id not usable
1172
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1173
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1174
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1175
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1176
-	    	    $data['ident'] = $line['flightnum']; // ident
1177
-	    	    $data['altitude'] = $line['alt']; // altitude
1178
-	    	    $data['speed'] = $line['gs']; // speed
1179
-	    	    $data['heading'] = $line['heading']; // heading
1180
-	    	    $data['latitude'] = $line['lat']; // lat
1181
-	    	    $data['longitude'] = $line['lng']; // long
1182
-	    	    $data['verticalrate'] = ''; // verticale rate
1183
-	    	    $data['squawk'] = ''; // squawk
1184
-	    	    $data['emergency'] = ''; // emergency
1185
-	    	    //$data['datetime'] = $line['lastupdate'];
1186
-	    	    //$data['last_update'] = $line['lastupdate'];
1187
-	    	    if (isset($value['timezone'])) {
1188
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1189
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1190
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1191
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1192
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1193
-	    	    $data['departure_airport_time'] = $line['deptime'];
1194
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1195
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1196
-    		    if (isset($line['registration'])) {
1197
-    			$data['registration'] = $line['registration'];
1198
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1199
-    		    } else $data['registration'] = $line['aircraft'];
1200
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1201
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1202
-		    if (isset($line['aircraftname'])) {
1170
+				$data = array();
1171
+				//$data['id'] = $line['id']; // id not usable
1172
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1173
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1174
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1175
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1176
+				$data['ident'] = $line['flightnum']; // ident
1177
+				$data['altitude'] = $line['alt']; // altitude
1178
+				$data['speed'] = $line['gs']; // speed
1179
+				$data['heading'] = $line['heading']; // heading
1180
+				$data['latitude'] = $line['lat']; // lat
1181
+				$data['longitude'] = $line['lng']; // long
1182
+				$data['verticalrate'] = ''; // verticale rate
1183
+				$data['squawk'] = ''; // squawk
1184
+				$data['emergency'] = ''; // emergency
1185
+				//$data['datetime'] = $line['lastupdate'];
1186
+				//$data['last_update'] = $line['lastupdate'];
1187
+				if (isset($value['timezone'])) {
1188
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1189
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1190
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1191
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1192
+				$data['departure_airport_icao'] = $line['depicao'];
1193
+				$data['departure_airport_time'] = $line['deptime'];
1194
+				$data['arrival_airport_icao'] = $line['arricao'];
1195
+				$data['arrival_airport_time'] = $line['arrtime'];
1196
+				if (isset($line['registration'])) {
1197
+				$data['registration'] = $line['registration'];
1198
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1199
+				} else $data['registration'] = $line['aircraft'];
1200
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1201
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1202
+			if (isset($line['aircraftname'])) {
1203 1203
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1204 1204
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1205
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1206
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1207
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1208
-	    		else {
1209
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1210
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1211
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1212
-	    		}
1213
-	    	    }
1214
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1215
-    		    $data['id_source'] = $id_source;
1216
-	    	    $data['format_source'] = 'phpvmacars';
1217
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1218
-		    $SI->add($data);
1219
-		    unset($data);
1205
+				$aircraft_data = explode('-',$line['aircraftname']);
1206
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1207
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1208
+				else {
1209
+					$aircraft_data = explode(' ',$line['aircraftname']);
1210
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1211
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1212
+				}
1213
+				}
1214
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1215
+				$data['id_source'] = $id_source;
1216
+				$data['format_source'] = 'phpvmacars';
1217
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1218
+			$SI->add($data);
1219
+			unset($data);
1220 1220
 		}
1221 1221
 		if ($globalDebug) echo 'No more data...'."\n";
1222 1222
 		unset($buffer);
1223 1223
 		unset($all_data);
1224
-	    }
1225
-	    //$last_exec['phpvmacars'] = time();
1226
-	    $last_exec[$id]['last'] = time();
1224
+		}
1225
+		//$last_exec['phpvmacars'] = time();
1226
+		$last_exec[$id]['last'] = time();
1227 1227
 	} elseif ($value['format'] == 'vaos' && 
1228
-	    (
1228
+		(
1229 1229
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1230 1230
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1231
-	    )
1231
+		)
1232 1232
 	) {
1233
-	    //$buffer = $Common->getData($hosts[$id]);
1234
-	    if ($globalDebug) echo 'Get Data...'."\n";
1235
-	    $buffer = $Common->getData($value['host']);
1236
-	    $all_data = json_decode($buffer,true);
1237
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1233
+		//$buffer = $Common->getData($hosts[$id]);
1234
+		if ($globalDebug) echo 'Get Data...'."\n";
1235
+		$buffer = $Common->getData($value['host']);
1236
+		$all_data = json_decode($buffer,true);
1237
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1238 1238
 		$reset = 0;
1239 1239
 		foreach ($all_data['ACARSData'] as $line) {
1240
-		    //print_r($line);
1241
-	    	    $data = array();
1242
-	    	    //$data['id'] = $line['id']; // id not usable
1243
-	    	    $data['id'] = $line['id'];
1244
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1245
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1246
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1247
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1248
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1249
-	    	    $data['altitude'] = $line['altitude']; // altitude
1250
-	    	    $data['speed'] = $line['groundspeed']; // speed
1251
-	    	    $data['heading'] = $line['heading']; // heading
1252
-	    	    $data['latitude'] = $line['lat']; // lat
1253
-	    	    $data['longitude'] = $line['lon']; // long
1254
-	    	    //$data['verticalrate'] = ''; // verticale rate
1255
-	    	    //$data['squawk'] = ''; // squawk
1256
-	    	    //$data['emergency'] = ''; // emergency
1257
-	    	    if (isset($value['timezone'])) {
1258
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1259
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1260
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1261
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1240
+			//print_r($line);
1241
+				$data = array();
1242
+				//$data['id'] = $line['id']; // id not usable
1243
+				$data['id'] = $line['id'];
1244
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1245
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1246
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1247
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1248
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1249
+				$data['altitude'] = $line['altitude']; // altitude
1250
+				$data['speed'] = $line['groundspeed']; // speed
1251
+				$data['heading'] = $line['heading']; // heading
1252
+				$data['latitude'] = $line['lat']; // lat
1253
+				$data['longitude'] = $line['lon']; // long
1254
+				//$data['verticalrate'] = ''; // verticale rate
1255
+				//$data['squawk'] = ''; // squawk
1256
+				//$data['emergency'] = ''; // emergency
1257
+				if (isset($value['timezone'])) {
1258
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1259
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1260
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1261
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1262 1262
 	    	    
1263
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1264
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1265
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1266
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1267
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1263
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1264
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1265
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1266
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1267
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1268 1268
 
1269
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1270
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1271
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1269
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1270
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1271
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1272 1272
 
1273
-    		    $data['id_source'] = $id_source;
1274
-	    	    $data['format_source'] = 'vaos';
1275
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1276
-		    $SI->add($data);
1277
-		    unset($data);
1273
+				$data['id_source'] = $id_source;
1274
+				$data['format_source'] = 'vaos';
1275
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1276
+			$SI->add($data);
1277
+			unset($data);
1278 1278
 		}
1279 1279
 		if ($globalDebug) echo 'No more data...'."\n";
1280 1280
 		unset($buffer);
1281 1281
 		unset($all_data);
1282
-	    }
1283
-	    //$last_exec['phpvmacars'] = time();
1284
-	    $last_exec[$id]['last'] = time();
1282
+		}
1283
+		//$last_exec['phpvmacars'] = time();
1284
+		$last_exec[$id]['last'] = time();
1285 1285
 	} elseif ($value['format'] == 'vam' && 
1286
-	    (
1286
+		(
1287 1287
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1288 1288
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1289
-	    )
1289
+		)
1290 1290
 	) {
1291
-	    //$buffer = $Common->getData($hosts[$id]);
1292
-	    if ($globalDebug) echo 'Get Data...'."\n";
1293
-	    $buffer = $Common->getData($value['host']);
1294
-	    $all_data = json_decode($buffer,true);
1295
-	    if ($buffer != '' && is_array($all_data)) {
1291
+		//$buffer = $Common->getData($hosts[$id]);
1292
+		if ($globalDebug) echo 'Get Data...'."\n";
1293
+		$buffer = $Common->getData($value['host']);
1294
+		$all_data = json_decode($buffer,true);
1295
+		if ($buffer != '' && is_array($all_data)) {
1296 1296
 		$reset = 0;
1297 1297
 		foreach ($all_data as $line) {
1298
-	    	    $data = array();
1299
-	    	    //$data['id'] = $line['id']; // id not usable
1300
-	    	    $data['id'] = trim($line['flight_id']);
1301
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1302
-	    	    $data['pilot_name'] = $line['pilot_name'];
1303
-	    	    $data['pilot_id'] = $line['pilot_id'];
1304
-	    	    $data['ident'] = trim($line['callsign']); // ident
1305
-	    	    $data['altitude'] = $line['altitude']; // altitude
1306
-	    	    $data['speed'] = $line['gs']; // speed
1307
-	    	    $data['heading'] = $line['heading']; // heading
1308
-	    	    $data['latitude'] = $line['latitude']; // lat
1309
-	    	    $data['longitude'] = $line['longitude']; // long
1310
-	    	    $data['verticalrate'] = ''; // verticale rate
1311
-	    	    $data['squawk'] = ''; // squawk
1312
-	    	    $data['emergency'] = ''; // emergency
1313
-	    	    //$data['datetime'] = $line['lastupdate'];
1314
-	    	    $data['last_update'] = $line['last_update'];
1315
-		    $data['datetime'] = date('Y-m-d H:i:s');
1316
-	    	    $data['departure_airport_icao'] = $line['departure'];
1317
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1318
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1319
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1320
-    		    //$data['registration'] = $line['aircraft'];
1321
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1322
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1323
-    		    $data['id_source'] = $id_source;
1324
-	    	    $data['format_source'] = 'vam';
1325
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1326
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1327
-		    $SI->add($data);
1328
-		    unset($data);
1298
+				$data = array();
1299
+				//$data['id'] = $line['id']; // id not usable
1300
+				$data['id'] = trim($line['flight_id']);
1301
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1302
+				$data['pilot_name'] = $line['pilot_name'];
1303
+				$data['pilot_id'] = $line['pilot_id'];
1304
+				$data['ident'] = trim($line['callsign']); // ident
1305
+				$data['altitude'] = $line['altitude']; // altitude
1306
+				$data['speed'] = $line['gs']; // speed
1307
+				$data['heading'] = $line['heading']; // heading
1308
+				$data['latitude'] = $line['latitude']; // lat
1309
+				$data['longitude'] = $line['longitude']; // long
1310
+				$data['verticalrate'] = ''; // verticale rate
1311
+				$data['squawk'] = ''; // squawk
1312
+				$data['emergency'] = ''; // emergency
1313
+				//$data['datetime'] = $line['lastupdate'];
1314
+				$data['last_update'] = $line['last_update'];
1315
+			$data['datetime'] = date('Y-m-d H:i:s');
1316
+				$data['departure_airport_icao'] = $line['departure'];
1317
+				//$data['departure_airport_time'] = $line['departure_time'];
1318
+				$data['arrival_airport_icao'] = $line['arrival'];
1319
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1320
+				//$data['registration'] = $line['aircraft'];
1321
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1322
+				$data['aircraft_icao'] = $line['plane_type'];
1323
+				$data['id_source'] = $id_source;
1324
+				$data['format_source'] = 'vam';
1325
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1326
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1327
+			$SI->add($data);
1328
+			unset($data);
1329 1329
 		}
1330 1330
 		if ($globalDebug) echo 'No more data...'."\n";
1331 1331
 		unset($buffer);
1332 1332
 		unset($all_data);
1333
-	    }
1334
-	    //$last_exec['phpvmacars'] = time();
1335
-	    $last_exec[$id]['last'] = time();
1333
+		}
1334
+		//$last_exec['phpvmacars'] = time();
1335
+		$last_exec[$id]['last'] = time();
1336 1336
 	} elseif ($value['format'] == 'blitzortung' && 
1337
-	    (
1337
+		(
1338 1338
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1339 1339
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1340
-	    )
1340
+		)
1341 1341
 	) {
1342
-	    //$buffer = $Common->getData($hosts[$id]);
1343
-	    if ($globalDebug) echo 'Get Data...'."\n";
1344
-	    $buffer = $Common->getData($value['host']);
1345
-	    $all_data = json_decode($buffer,true);
1346
-	    if ($buffer != '') {
1342
+		//$buffer = $Common->getData($hosts[$id]);
1343
+		if ($globalDebug) echo 'Get Data...'."\n";
1344
+		$buffer = $Common->getData($value['host']);
1345
+		$all_data = json_decode($buffer,true);
1346
+		if ($buffer != '') {
1347 1347
 		$Source->deleteLocationBySource('blitzortung');
1348 1348
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1349 1349
 		$buffer = explode('\n',$buffer);
1350 1350
 		foreach ($buffer as $buffer_line) {
1351
-		    $line = json_decode($buffer_line,true);
1352
-		    if (isset($line['time'])) {
1351
+			$line = json_decode($buffer_line,true);
1352
+			if (isset($line['time'])) {
1353 1353
 			$data = array();
1354 1354
 			$data['altitude'] = $line['alt']; // altitude
1355 1355
 			$data['latitude'] = $line['lat']; // lat
@@ -1361,96 +1361,96 @@  discard block
 block discarded – undo
1361 1361
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1362 1362
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1363 1363
 			unset($data);
1364
-		    }
1364
+			}
1365 1365
 		}
1366 1366
 		if ($globalDebug) echo 'No more data...'."\n";
1367 1367
 		unset($buffer);
1368
-	    }
1369
-	    $last_exec[$id]['last'] = time();
1368
+		}
1369
+		$last_exec[$id]['last'] = time();
1370 1370
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1371 1371
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1372
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1373
-    	    //$last_exec[$id]['last'] = time();
1372
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1373
+			//$last_exec[$id]['last'] = time();
1374 1374
 
1375
-	    //$read = array( $sockets[$id] );
1376
-	    $read = $sockets;
1377
-	    $write = NULL;
1378
-	    $e = NULL;
1379
-	    $n = socket_select($read, $write, $e, $timeout);
1380
-	    if ($e != NULL) var_dump($e);
1381
-	    if ($n > 0) {
1375
+		//$read = array( $sockets[$id] );
1376
+		$read = $sockets;
1377
+		$write = NULL;
1378
+		$e = NULL;
1379
+		$n = socket_select($read, $write, $e, $timeout);
1380
+		if ($e != NULL) var_dump($e);
1381
+		if ($n > 0) {
1382 1382
 		$reset = 0;
1383 1383
 		foreach ($read as $nb => $r) {
1384
-		    //$value = $formats[$nb];
1385
-		    $format = $globalSources[$nb]['format'];
1386
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1384
+			//$value = $formats[$nb];
1385
+			$format = $globalSources[$nb]['format'];
1386
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1387 1387
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1388
-		    } elseif ($format == 'vrstcp') {
1388
+			} elseif ($format == 'vrstcp') {
1389 1389
 			$buffer = @socket_read($r, 6000);
1390
-		    } else {
1390
+			} else {
1391 1391
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1392
-		    }
1393
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1394
-		    //echo $buffer."\n";
1395
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1396
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1397
-		    $error = false;
1398
-		    //$SI::del();
1399
-		    if ($buffer !== FALSE) {
1392
+			}
1393
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1394
+			//echo $buffer."\n";
1395
+			// lets play nice and handle signals such as ctrl-c/kill properly
1396
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1397
+			$error = false;
1398
+			//$SI::del();
1399
+			if ($buffer !== FALSE) {
1400 1400
 			if ($format == 'vrstcp') {
1401
-			    $buffer = explode('},{',$buffer);
1401
+				$buffer = explode('},{',$buffer);
1402 1402
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1403
-		    }
1404
-		    // SBS format is CSV format
1405
-		    if ($buffer !== FALSE && $buffer !== '') {
1403
+			}
1404
+			// SBS format is CSV format
1405
+			if ($buffer !== FALSE && $buffer !== '') {
1406 1406
 			$tt[$format] = 0;
1407 1407
 			if ($format == 'acarssbs3') {
1408
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1409
-			    $ACARS->add(trim($buffer));
1410
-			    $ACARS->deleteLiveAcarsData();
1408
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1409
+				$ACARS->add(trim($buffer));
1410
+				$ACARS->deleteLiveAcarsData();
1411 1411
 			} elseif ($format == 'raw') {
1412
-			    // AVR format
1413
-			    $data = $SBS->parse($buffer);
1414
-			    if (is_array($data)) {
1412
+				// AVR format
1413
+				$data = $SBS->parse($buffer);
1414
+				if (is_array($data)) {
1415 1415
 				$data['datetime'] = date('Y-m-d H:i:s');
1416 1416
 				$data['format_source'] = 'raw';
1417 1417
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1418 1418
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1419 1419
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1420 1420
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1421
-			    }
1421
+				}
1422 1422
 			} elseif ($format == 'ais') {
1423
-			    $ais_data = $AIS->parse_line(trim($buffer));
1424
-			    $data = array();
1425
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1426
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1427
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1428
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1429
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1430
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1431
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1432
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1433
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1434
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1435
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1436
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1437
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1438
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1439
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1440
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1423
+				$ais_data = $AIS->parse_line(trim($buffer));
1424
+				$data = array();
1425
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1426
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1427
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1428
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1429
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1430
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1431
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1432
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1433
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1434
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1435
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1436
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1437
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1438
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1439
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1440
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1441 1441
 
1442
-			    if (isset($ais_data['timestamp'])) {
1442
+				if (isset($ais_data['timestamp'])) {
1443 1443
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1444
-			    } else {
1444
+				} else {
1445 1445
 				$data['datetime'] = date('Y-m-d H:i:s');
1446
-			    }
1447
-			    $data['format_source'] = 'aisnmea';
1448
-    			    $data['id_source'] = $id_source;
1449
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1450
-			    unset($data);
1451
-                        } elseif ($format == 'flightgearsp') {
1452
-                    	    //echo $buffer."\n";
1453
-                    	    if (strlen($buffer) > 5) {
1446
+				}
1447
+				$data['format_source'] = 'aisnmea';
1448
+					$data['id_source'] = $id_source;
1449
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1450
+				unset($data);
1451
+						} elseif ($format == 'flightgearsp') {
1452
+							//echo $buffer."\n";
1453
+							if (strlen($buffer) > 5) {
1454 1454
 				$line = explode(',',$buffer);
1455 1455
 				$data = array();
1456 1456
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1467,38 +1467,38 @@  discard block
 block discarded – undo
1467 1467
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1468 1468
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1469 1469
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1470
-			    }
1471
-                        } elseif ($format == 'acars') {
1472
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1473
-			    $ACARS->add(trim($buffer));
1474
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1475
-			    $ACARS->deleteLiveAcarsData();
1470
+				}
1471
+						} elseif ($format == 'acars') {
1472
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1473
+				$ACARS->add(trim($buffer));
1474
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1475
+				$ACARS->deleteLiveAcarsData();
1476 1476
 			} elseif ($format == 'flightgearmp') {
1477
-			    if (substr($buffer,0,1) != '#') {
1477
+				if (substr($buffer,0,1) != '#') {
1478 1478
 				$data = array();
1479 1479
 				//echo $buffer."\n";
1480 1480
 				$line = explode(' ',$buffer);
1481 1481
 				if (count($line) == 11) {
1482
-				    $userserver = explode('@',$line[0]);
1483
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1484
-				    $data['ident'] = $userserver[0];
1485
-				    $data['registration'] = $userserver[0];
1486
-				    $data['latitude'] = $line[4];
1487
-				    $data['longitude'] = $line[5];
1488
-				    $data['altitude'] = $line[6];
1489
-				    $data['datetime'] = date('Y-m-d H:i:s');
1490
-				    $aircraft_type = $line[10];
1491
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1492
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1493
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1494
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1482
+					$userserver = explode('@',$line[0]);
1483
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1484
+					$data['ident'] = $userserver[0];
1485
+					$data['registration'] = $userserver[0];
1486
+					$data['latitude'] = $line[4];
1487
+					$data['longitude'] = $line[5];
1488
+					$data['altitude'] = $line[6];
1489
+					$data['datetime'] = date('Y-m-d H:i:s');
1490
+					$aircraft_type = $line[10];
1491
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1492
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1493
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1494
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1495
+				}
1495 1496
 				}
1496
-			    }
1497 1497
 			} elseif ($format == 'beast') {
1498
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1499
-			    die;
1498
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1499
+				die;
1500 1500
 			} elseif ($format == 'vrstcp') {
1501
-			    foreach($buffer as $all_data) {
1501
+				foreach($buffer as $all_data) {
1502 1502
 				$line = json_decode('{'.$all_data.'}',true);
1503 1503
 				$data = array();
1504 1504
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1518,153 +1518,153 @@  discard block
 block discarded – undo
1518 1518
 				*/
1519 1519
 				$data['datetime'] = date('Y-m-d H:i:s');
1520 1520
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1521
-		    		$data['format_source'] = 'vrstcp';
1521
+					$data['format_source'] = 'vrstcp';
1522 1522
 				$data['id_source'] = $id_source;
1523 1523
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1524 1524
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1525 1525
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1526 1526
 				unset($data);
1527
-			    }
1527
+				}
1528 1528
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1529
-			    $line = explode("\t", $buffer);
1530
-			    for($k = 0; $k < count($line); $k=$k+2) {
1529
+				$line = explode("\t", $buffer);
1530
+				for($k = 0; $k < count($line); $k=$k+2) {
1531 1531
 				$key = $line[$k];
1532
-			        $lined[$key] = $line[$k+1];
1533
-			    }
1534
-    			    if (count($lined) > 3) {
1535
-    				$data['hex'] = $lined['hexid'];
1536
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1537
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1538
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1539
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1540
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1541
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1542
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1543
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1544
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1545
-    				$data['id_source'] = $id_source;
1546
-    				$data['format_source'] = 'tsv';
1547
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1548
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1532
+					$lined[$key] = $line[$k+1];
1533
+				}
1534
+					if (count($lined) > 3) {
1535
+					$data['hex'] = $lined['hexid'];
1536
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1537
+					$data['datetime'] = date('Y-m-d H:i:s');;
1538
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1539
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1540
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1541
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1542
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1543
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1544
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1545
+					$data['id_source'] = $id_source;
1546
+					$data['format_source'] = 'tsv';
1547
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1548
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1549 1549
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1550
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1551
-    				unset($lined);
1552
-    				unset($data);
1553
-    			    } else $error = true;
1550
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1551
+					unset($lined);
1552
+					unset($data);
1553
+					} else $error = true;
1554 1554
 			} elseif ($format == 'aprs' && $use_aprs) {
1555
-			    if ($aprs_connect == 0) {
1555
+				if ($aprs_connect == 0) {
1556 1556
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1557 1557
 				$aprs_connect = 1;
1558
-			    }
1558
+				}
1559 1559
 			    
1560
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1560
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1561 1561
 				$aprs_last_tx = time();
1562 1562
 				$data_aprs = "# Keep alive";
1563 1563
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1564
-			    }
1564
+				}
1565 1565
 			    
1566
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1567
-			    //echo 'APRS data : '.$buffer."\n";
1568
-			    $buffer = str_replace('APRS <- ','',$buffer);
1569
-			    $buffer = str_replace('APRS -> ','',$buffer);
1570
-			    //echo $buffer."\n";
1571
-			    date_default_timezone_set('UTC');
1572
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1566
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1567
+				//echo 'APRS data : '.$buffer."\n";
1568
+				$buffer = str_replace('APRS <- ','',$buffer);
1569
+				$buffer = str_replace('APRS -> ','',$buffer);
1570
+				//echo $buffer."\n";
1571
+				date_default_timezone_set('UTC');
1572
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1573 1573
 				$line = $APRS->parse($buffer);
1574 1574
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1575 1575
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1576
-				    $aprs_last_tx = time();
1577
-				    $data = array();
1578
-				    //print_r($line);
1579
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1580
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1581
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1582
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1583
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1584
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1585
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1586
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1587
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1588
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1589
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1590
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1591
-				    $data['latitude'] = $line['latitude'];
1592
-				    $data['longitude'] = $line['longitude'];
1593
-				    //$data['verticalrate'] = $line[16];
1594
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1595
-				    //else $data['speed'] = 0;
1596
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1597
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1598
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1599
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1576
+					$aprs_last_tx = time();
1577
+					$data = array();
1578
+					//print_r($line);
1579
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1580
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1581
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1582
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1583
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1584
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1585
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1586
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1587
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1588
+					else $data['datetime'] = date('Y-m-d H:i:s');
1589
+					//$data['datetime'] = date('Y-m-d H:i:s');
1590
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1591
+					$data['latitude'] = $line['latitude'];
1592
+					$data['longitude'] = $line['longitude'];
1593
+					//$data['verticalrate'] = $line[16];
1594
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1595
+					//else $data['speed'] = 0;
1596
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1597
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1598
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1599
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1600 1600
 				    
1601
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1602
-				    //else echo 'No heading...'."\n";
1603
-				    //else $data['heading'] = 0;
1604
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1605
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1606
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1607
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1608
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1609
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1610
-    				    $data['id_source'] = $id_source;
1611
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1612
-				    else $data['format_source'] = 'aprs';
1613
-				    $data['source_name'] = $line['source'];
1614
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1615
-				    else $data['source_type'] = 'flarm';
1616
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1617
-				    $currentdate = date('Y-m-d H:i:s');
1618
-				    $aprsdate = strtotime($data['datetime']);
1619
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1620
-				    // Accept data if time <= system time + 20s
1621
-				    //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'])))) {
1622
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1601
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1602
+					//else echo 'No heading...'."\n";
1603
+					//else $data['heading'] = 0;
1604
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1605
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1606
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1607
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1608
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1609
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1610
+						$data['id_source'] = $id_source;
1611
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1612
+					else $data['format_source'] = 'aprs';
1613
+					$data['source_name'] = $line['source'];
1614
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1615
+					else $data['source_type'] = 'flarm';
1616
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1617
+					$currentdate = date('Y-m-d H:i:s');
1618
+					$aprsdate = strtotime($data['datetime']);
1619
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1620
+					// Accept data if time <= system time + 20s
1621
+					//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'])))) {
1622
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1623 1623
 					$send = $SI->add($data);
1624
-				    } elseif ($data['source_type'] == 'ais') {
1624
+					} elseif ($data['source_type'] == 'ais') {
1625 1625
 					$data['type'] = '';
1626 1626
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1627
-				    } elseif (isset($line['stealth'])) {
1627
+					} elseif (isset($line['stealth'])) {
1628 1628
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1629 1629
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1630
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1631
-					    //$line['symbol'] == 'Balloon' ||
1632
-					    $line['symbol'] == 'Glider' || 
1633
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1634
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1635
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1636
-					    $send = $SI->add($data);
1637
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1638
-					    $line['symbol'] == 'Yacht (Sail)' || 
1639
-					    $line['symbol'] == 'Ship (Power Boat)')) {
1640
-					    $send = $MI->add($data);
1641
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1642
-					    $line['symbol'] == 'Car' || 
1643
-					    $line['symbol'] == 'Ambulance' || 
1644
-					    $line['symbol'] == 'Van' || 
1645
-					    $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1646
-					    $line['symbol'] == 'Motorcycle' || 
1647
-					    $line['symbol'] == 'Tractor' || 
1648
-					    $line['symbol'] == 'Police' || 
1649
-					    $line['symbol'] == 'Bike' || 
1650
-					    $line['symbol'] == 'Jogger' || 
1651
-					    $line['symbol'] == 'Horse' || 
1652
-					    $line['symbol'] == 'Bus' || 
1653
-					    $line['symbol'] == 'Jeep' || 
1654
-					    $line['symbol'] == 'Recreational Vehicle' || 
1655
-					    $line['symbol'] == 'Yacht (Sail)' || 
1656
-					    $line['symbol'] == 'Ship (Power Boat)' || 
1657
-					    $line['symbol'] == 'Firetruck' || 
1658
-					    $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1659
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1660
-					    $line['symbol'] == 'SUV' ||
1661
-					    $line['symbol'] == 'Snowmobile' ||
1662
-					    $line['symbol'] == 'Mobile Satellite Station')) {
1663
-				    //} 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') {
1630
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1631
+						//$line['symbol'] == 'Balloon' ||
1632
+						$line['symbol'] == 'Glider' || 
1633
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1634
+						if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1635
+						if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1636
+						$send = $SI->add($data);
1637
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1638
+						$line['symbol'] == 'Yacht (Sail)' || 
1639
+						$line['symbol'] == 'Ship (Power Boat)')) {
1640
+						$send = $MI->add($data);
1641
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1642
+						$line['symbol'] == 'Car' || 
1643
+						$line['symbol'] == 'Ambulance' || 
1644
+						$line['symbol'] == 'Van' || 
1645
+						$line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1646
+						$line['symbol'] == 'Motorcycle' || 
1647
+						$line['symbol'] == 'Tractor' || 
1648
+						$line['symbol'] == 'Police' || 
1649
+						$line['symbol'] == 'Bike' || 
1650
+						$line['symbol'] == 'Jogger' || 
1651
+						$line['symbol'] == 'Horse' || 
1652
+						$line['symbol'] == 'Bus' || 
1653
+						$line['symbol'] == 'Jeep' || 
1654
+						$line['symbol'] == 'Recreational Vehicle' || 
1655
+						$line['symbol'] == 'Yacht (Sail)' || 
1656
+						$line['symbol'] == 'Ship (Power Boat)' || 
1657
+						$line['symbol'] == 'Firetruck' || 
1658
+						$line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1659
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1660
+						$line['symbol'] == 'SUV' ||
1661
+						$line['symbol'] == 'Snowmobile' ||
1662
+						$line['symbol'] == 'Mobile Satellite Station')) {
1663
+					//} 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') {
1664 1664
 				//    } 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') {
1665 1665
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1666 1666
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1667
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1667
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1668 1668
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1669 1669
 					$Source->deleteOldLocationByType('gs');
1670 1670
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1672,7 +1672,7 @@  discard block
 block discarded – undo
1672 1672
 					} else {
1673 1673
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1674 1674
 					}
1675
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1675
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1676 1676
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1677 1677
 					if ($globalDebug) echo '# Weather Station added'."\n";
1678 1678
 					$Source->deleteOldLocationByType('wx');
@@ -1682,7 +1682,7 @@  discard block
 block discarded – undo
1682 1682
 					} else {
1683 1683
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1684 1684
 					}
1685
-				    } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1685
+					} elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1686 1686
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1687 1687
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1688 1688
 					$Source->deleteOldLocationByType('lightning');
@@ -1691,11 +1691,11 @@  discard block
 block discarded – undo
1691 1691
 					} else {
1692 1692
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1693 1693
 					}
1694
-				    } elseif ($globalDebug) {
1695
-				    	echo '/!\ Not added: '.$buffer."\n";
1696
-				    	print_r($line);
1697
-				    }
1698
-				    unset($data);
1694
+					} elseif ($globalDebug) {
1695
+						echo '/!\ Not added: '.$buffer."\n";
1696
+						print_r($line);
1697
+					}
1698
+					unset($data);
1699 1699
 				}
1700 1700
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1701 1701
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1714,12 +1714,12 @@  discard block
 block discarded – undo
1714 1714
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1715 1715
 					$globalSources[$nb]['last_weather_clean'] = time();
1716 1716
 				}
1717
-			    }
1717
+				}
1718 1718
 			} else {
1719
-			    $line = explode(',', $buffer);
1720
-    			    if (count($line) > 20) {
1721
-    			    	$data['hex'] = $line[4];
1722
-    				/*
1719
+				$line = explode(',', $buffer);
1720
+					if (count($line) > 20) {
1721
+						$data['hex'] = $line[4];
1722
+					/*
1723 1723
     				$data['datetime'] = $line[6].' '.$line[7];
1724 1724
     					date_default_timezone_set($globalTimezone);
1725 1725
     					$datetime = new DateTime($data['datetime']);
@@ -1727,30 +1727,30 @@  discard block
 block discarded – undo
1727 1727
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1728 1728
     					date_default_timezone_set('UTC');
1729 1729
     				*/
1730
-    				// Force datetime to current UTC datetime
1731
-    				date_default_timezone_set('UTC');
1732
-    				$data['datetime'] = date('Y-m-d H:i:s');
1733
-    				$data['ident'] = trim($line[10]);
1734
-    				$data['latitude'] = $line[14];
1735
-    				$data['longitude'] = $line[15];
1736
-    				$data['verticalrate'] = $line[16];
1737
-    				$data['emergency'] = $line[20];
1738
-    				$data['speed'] = $line[12];
1739
-    				$data['squawk'] = $line[17];
1740
-    				$data['altitude'] = $line[11];
1741
-    				$data['heading'] = $line[13];
1742
-    				$data['ground'] = $line[21];
1743
-    				$data['emergency'] = $line[19];
1744
-    				$data['format_source'] = 'sbs';
1730
+					// Force datetime to current UTC datetime
1731
+					date_default_timezone_set('UTC');
1732
+					$data['datetime'] = date('Y-m-d H:i:s');
1733
+					$data['ident'] = trim($line[10]);
1734
+					$data['latitude'] = $line[14];
1735
+					$data['longitude'] = $line[15];
1736
+					$data['verticalrate'] = $line[16];
1737
+					$data['emergency'] = $line[20];
1738
+					$data['speed'] = $line[12];
1739
+					$data['squawk'] = $line[17];
1740
+					$data['altitude'] = $line[11];
1741
+					$data['heading'] = $line[13];
1742
+					$data['ground'] = $line[21];
1743
+					$data['emergency'] = $line[19];
1744
+					$data['format_source'] = 'sbs';
1745 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'];
1746
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1747 1747
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1748
-    				$data['id_source'] = $id_source;
1749
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1750
-    				else $error = true;
1751
-    				unset($data);
1752
-    			    } else $error = true;
1753
-			    if ($error) {
1748
+					$data['id_source'] = $id_source;
1749
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1750
+					else $error = true;
1751
+					unset($data);
1752
+					} else $error = true;
1753
+				if ($error) {
1754 1754
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1755 1755
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1756 1756
 				} else {
@@ -1766,13 +1766,13 @@  discard block
 block discarded – undo
1766 1766
 					connect_all($sourceer);
1767 1767
 					$sourceer = array();
1768 1768
 				}
1769
-			    }
1769
+				}
1770 1770
 			}
1771 1771
 			// Sleep for xxx microseconds
1772 1772
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1773
-		    } else {
1773
+			} else {
1774 1774
 			if ($format == 'flightgearmp') {
1775
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1775
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1776 1776
 				//@socket_close($r);
1777 1777
 				sleep($globalMinFetch);
1778 1778
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1781,9 +1781,9 @@  discard block
 block discarded – undo
1781 1781
 				break;
1782 1782
 				
1783 1783
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1784
-			    if (isset($tt[$format])) $tt[$format]++;
1785
-			    else $tt[$format] = 0;
1786
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
1784
+				if (isset($tt[$format])) $tt[$format]++;
1785
+				else $tt[$format] = 0;
1786
+				if ($tt[$format] > 30 || $buffer === FALSE) {
1787 1787
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1788 1788
 				//@socket_close($r);
1789 1789
 				sleep(2);
@@ -1794,24 +1794,24 @@  discard block
 block discarded – undo
1794 1794
 				//connect_all($globalSources);
1795 1795
 				$tt[$format]=0;
1796 1796
 				break;
1797
-			    } 
1798
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1797
+				} 
1798
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1799
+			}
1799 1800
 			}
1800
-		    }
1801 1801
 		}
1802
-	    } else {
1802
+		} else {
1803 1803
 		$error = socket_strerror(socket_last_error());
1804 1804
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1805 1805
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1806 1806
 			if (isset($globalDebug)) echo "Restarting...\n";
1807 1807
 			// Restart the script if possible
1808 1808
 			if (is_array($sockets)) {
1809
-			    if ($globalDebug) echo "Shutdown all sockets...";
1809
+				if ($globalDebug) echo "Shutdown all sockets...";
1810 1810
 			    
1811
-			    foreach ($sockets as $sock) {
1811
+				foreach ($sockets as $sock) {
1812 1812
 				@socket_shutdown($sock,2);
1813 1813
 				@socket_close($sock);
1814
-			    }
1814
+				}
1815 1815
 			    
1816 1816
 			}
1817 1817
 			if ($globalDebug) echo "Waiting...";
@@ -1826,15 +1826,15 @@  discard block
 block discarded – undo
1826 1826
 			if ($globalDebug) echo "Restart all connections...";
1827 1827
 			connect_all($globalSources);
1828 1828
 		}
1829
-	    }
1829
+		}
1830 1830
 	}
1831 1831
 	if ($globalDaemon === false) {
1832
-	    if ($globalDebug) echo 'Check all...'."\n";
1833
-	    if (isset($SI)) $SI->checkAll();
1834
-	    if (isset($TI)) $TI->checkAll();
1835
-	    if (isset($MI)) $MI->checkAll();
1832
+		if ($globalDebug) echo 'Check all...'."\n";
1833
+		if (isset($SI)) $SI->checkAll();
1834
+		if (isset($TI)) $TI->checkAll();
1835
+		if (isset($MI)) $MI->checkAll();
1836
+	}
1836 1837
 	}
1837
-    }
1838 1838
 }
1839 1839
 
1840 1840
 ?>
Please login to merge, or discard this patch.
Spacing   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
 	    die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
53
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
54 54
     }
55 55
 }
56 56
 
57
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
57
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65 65
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
66
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
67 67
     else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106 106
     if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
107
+    $SI = new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
111 111
     $SI->connect();
112 112
 */
113
-} else $SI=new SpotterImport($Connection->db);
113
+} else $SI = new SpotterImport($Connection->db);
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
     $MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127
-$SBS=new SBS();
127
+$SBS = new SBS();
128 128
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
129
-	$ACARS=new ACARS($Connection->db,true);
130
-	$Source=new Source($Connection->db);
129
+	$ACARS = new ACARS($Connection->db, true);
130
+	$Source = new Source($Connection->db);
131 131
 }
132
-$Common=new Common();
132
+$Common = new Common();
133 133
 date_default_timezone_set('UTC');
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
137
+    pcntl_signal(SIGINT, function() {
138 138
         global $sockets;
139 139
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140 140
         die("Bye!\n");
@@ -150,30 +150,30 @@  discard block
 block discarded – undo
150 150
 
151 151
 function connect_all($hosts) {
152 152
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
153
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
154 154
     $reset++;
155 155
     if ($globalDebug) echo 'Connect to all...'."\n";
156 156
     foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
160
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
+            if (preg_match('/deltadb.txt$/i', $host)) {
162 162
         	//$formats[$id] = 'deltadbtxt';
163 163
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 164
         	//$last_exec['deltadbtxt'] = 0;
165 165
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
166
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
167 167
         	//$formats[$id] = 'vatsimtxt';
168 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 169
         	//$last_exec['vatsimtxt'] = 0;
170 170
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
171
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
172 172
         	//$formats[$id] = 'aircraftlistjson';
173 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 174
         	//$last_exec['aircraftlistjson'] = 0;
175 175
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/opensky/i',$host)) {
176
+    	    } else if (preg_match('/opensky/i', $host)) {
177 177
         	//$formats[$id] = 'aircraftlistjson';
178 178
         	$globalSources[$id]['format'] = 'opensky';
179 179
         	//$last_exec['aircraftlistjson'] = 0;
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
         	    exit(0);
191 191
         	}
192 192
     	    */
193
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
193
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
194 194
         	//$formats[$id] = 'planeupdatefaa';
195 195
         	$globalSources[$id]['format'] = 'planeupdatefaa';
196 196
         	//$last_exec['planeupdatefaa'] = 0;
@@ -199,37 +199,37 @@  discard block
 block discarded – undo
199 199
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200 200
         	    exit(0);
201 201
         	}
202
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
202
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
203 203
         	//$formats[$id] = 'phpvmacars';
204 204
         	$globalSources[$id]['format'] = 'phpvmacars';
205 205
         	//$last_exec['phpvmacars'] = 0;
206 206
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
207
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
207
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
208 208
         	//$formats[$id] = 'phpvmacars';
209 209
         	$globalSources[$id]['format'] = 'vaos';
210 210
         	//$last_exec['phpvmacars'] = 0;
211 211
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
212
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
212
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
213 213
         	//$formats[$id] = 'phpvmacars';
214 214
         	$globalSources[$id]['format'] = 'vam';
215 215
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
216
-            } else if (preg_match('/whazzup/i',$host)) {
216
+            } else if (preg_match('/whazzup/i', $host)) {
217 217
         	//$formats[$id] = 'whazzup';
218 218
         	$globalSources[$id]['format'] = 'whazzup';
219 219
         	//$last_exec['whazzup'] = 0;
220 220
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
221
-            } else if (preg_match('/blitzortung/i',$host)) {
221
+            } else if (preg_match('/blitzortung/i', $host)) {
222 222
         	$globalSources[$id]['format'] = 'blitzortung';
223 223
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
224
-            } else if (preg_match('/airwhere/i',$host)) {
224
+            } else if (preg_match('/airwhere/i', $host)) {
225 225
         	$globalSources[$id]['format'] = 'airwhere';
226 226
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
227
-            } else if (preg_match('/recentpireps/i',$host)) {
227
+            } else if (preg_match('/recentpireps/i', $host)) {
228 228
         	//$formats[$id] = 'pirepsjson';
229 229
         	$globalSources[$id]['format'] = 'pirepsjson';
230 230
         	//$last_exec['pirepsjson'] = 0;
231 231
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
232
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
232
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
233 233
         	//$formats[$id] = 'fr24json';
234 234
         	$globalSources[$id]['format'] = 'fr24json';
235 235
         	//$last_exec['fr24json'] = 0;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
239 239
         	    exit(0);
240 240
         	}
241
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
241
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
242 242
         	//$formats[$id] = 'fr24json';
243 243
         	$globalSources[$id]['format'] = 'myshiptracking';
244 244
         	//$last_exec['fr24json'] = 0;
@@ -248,21 +248,21 @@  discard block
 block discarded – undo
248 248
         	    exit(0);
249 249
         	}
250 250
             //} else if (preg_match('/10001/',$host)) {
251
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
251
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
252 252
         	//$formats[$id] = 'tsv';
253 253
         	$globalSources[$id]['format'] = 'tsv';
254 254
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
255 255
             }
256
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
256
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
257 257
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
258
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
258
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
259 259
     		    if ($idf !== false) {
260 260
     			$httpfeeds[$id] = $idf;
261 261
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
262 262
     		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
263 263
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
264
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
265
-	    $hostport = explode(':',$host);
264
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
265
+	    $hostport = explode(':', $host);
266 266
 	    if (isset($hostport[1])) {
267 267
 		$port = $hostport[1];
268 268
 		$hostn = $hostport[0];
@@ -272,19 +272,19 @@  discard block
 block discarded – undo
272 272
 	    }
273 273
 	    $Common = new Common();
274 274
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
275
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
275
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
276 276
     	    } else {
277
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
277
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
278 278
 	    }
279 279
 	    if ($s) {
280 280
     	        $sockets[$id] = $s;
281 281
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
282
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
282
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
283 283
 			//$formats[$id] = 'aprs';
284 284
 			$globalSources[$id]['format'] = 'aprs';
285 285
 			//$aprs_connect = 0;
286 286
 			//$use_aprs = true;
287
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
287
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
288 288
 			$globalSources[$id]['format'] = 'vrstcp';
289 289
     		    } elseif ($port == '10001') {
290 290
         		//$formats[$id] = 'tsv';
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
324 324
 else $timeout = 20;
325 325
 $errno = '';
326
-$errstr='';
326
+$errstr = '';
327 327
 
328 328
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
329 329
 /* Initiate connections to all the hosts simultaneously */
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 //connect_all($globalSources);
332 332
 
333 333
 if (isset($globalProxy) && $globalProxy) {
334
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
334
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
335 335
 } else {
336 336
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
337 337
 }
@@ -361,16 +361,16 @@  discard block
 block discarded – undo
361 361
 
362 362
 if ($use_aprs) {
363 363
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
364
-	$APRS=new APRS();
364
+	$APRS = new APRS();
365 365
 	$aprs_connect = 0;
366 366
 	$aprs_keep = 120;
367 367
 	$aprs_last_tx = time();
368 368
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
369
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
369
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
370 370
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
371
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
371
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
372 372
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
373
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
373
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
374 374
 	if ($aprs_full) $aprs_filter = '';
375 375
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
376 376
 	else $aprs_pass = '-1';
@@ -384,12 +384,12 @@  discard block
 block discarded – undo
384 384
 sleep(1);
385 385
 if ($globalDebug) echo "SCAN MODE \n\n";
386 386
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
387
-$endtime = time()+$globalCronEnd;
387
+$endtime = time() + $globalCronEnd;
388 388
 $i = 1;
389 389
 $tt = array();
390 390
 // Delete all ATC
391 391
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
392
-	$ATC=new ATC($Connection->db);
392
+	$ATC = new ATC($Connection->db);
393 393
 }
394 394
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
395 395
 	$ATC->deleteAll();
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 
398 398
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
399 399
 while ($i > 0) {
400
-    if (!$globalDaemon) $i = $endtime-time();
400
+    if (!$globalDaemon) $i = $endtime - time();
401 401
     // Delete old ATC
402 402
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
403 403
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 	}
412 412
 	if ($max != $globalMinFetch) {
413 413
 	    if ($globalDebug) echo 'Sleeping...'."\n";
414
-	    sleep($globalMinFetch-$max+2);
414
+	    sleep($globalMinFetch - $max + 2);
415 415
 	}
416 416
     }
417 417
 
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
 	    //$buffer = $Common->getData($hosts[$id]);
431 431
 	    $buffer = $Common->getData($value['host']);
432 432
 	    if ($buffer != '') $reset = 0;
433
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434
-	    $buffer = explode('\n',$buffer);
433
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
434
+	    $buffer = explode('\n', $buffer);
435 435
 	    foreach ($buffer as $line) {
436 436
     		if ($line != '' && count($line) > 7) {
437 437
     		    $line = explode(',', $line);
@@ -464,11 +464,11 @@  discard block
 block discarded – undo
464 464
 	    )
465 465
 	) {
466 466
 	    date_default_timezone_set('CET');
467
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
467
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
468 468
 	    date_default_timezone_set('UTC');
469 469
 	    if ($buffer != '') $reset = 0;
470
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
471
-	    $buffer = explode('\n',$buffer);
470
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
471
+	    $buffer = explode('\n', $buffer);
472 472
 	    foreach ($buffer as $line) {
473 473
 		if ($line != '') {
474 474
 		    //echo "'".$line."'\n";
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
487 487
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
488 488
 		    if (isset($ais_data['timestamp'])) {
489
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
489
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
490 490
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
491 491
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
492 492
 			    $add = true;
@@ -509,15 +509,15 @@  discard block
 block discarded – undo
509 509
 	    $w = $e = null;
510 510
 	    
511 511
 	    if (isset($arr[$id])) {
512
-		$nn = stream_select($arr,$w,$e,$timeout);
512
+		$nn = stream_select($arr, $w, $e, $timeout);
513 513
 		if ($nn > 0) {
514 514
 		    foreach ($httpfeeds as $feed) {
515
-			$buffer = stream_get_line($feed,2000,"\n");
515
+			$buffer = stream_get_line($feed, 2000, "\n");
516 516
 			if ($buffer === FALSE) {
517 517
 			    connect_all($globalSources);
518 518
 			}
519
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
520
-			$buffer = explode('\n',$buffer);
519
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
520
+			$buffer = explode('\n', $buffer);
521 521
 			foreach ($buffer as $line) {
522 522
 			    if ($line != '') {
523 523
 				$ais_data = $AIS->parse_line(trim($line));
@@ -535,9 +535,9 @@  discard block
 block discarded – undo
535 535
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
536 536
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
537 537
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
538
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
538
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
539 539
 				if (isset($ais_data['timestamp'])) {
540
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
540
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
541 541
 				} else {
542 542
 				    $data['datetime'] = date('Y-m-d H:i:s');
543 543
 				}
@@ -569,10 +569,10 @@  discard block
 block discarded – undo
569 569
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
570 570
 	    )
571 571
 	) {
572
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
572
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
573 573
 	    if ($buffer != '') {
574 574
 		//echo $buffer;
575
-		$all_data = json_decode($buffer,true);
575
+		$all_data = json_decode($buffer, true);
576 576
 		//print_r($all_data);
577 577
 		if (isset($all_data[0]['DATA'])) {
578 578
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 			    $data['ident'] = $line['NAME'];
582 582
 			    $data['mmsi'] = $line['MMSI'];
583 583
 			    if (strlen($data['mmsi']) > 9) {
584
-				$data['mmsi'] = substr($data['mmsi'],-9);
584
+				$data['mmsi'] = substr($data['mmsi'], -9);
585 585
 			    }
586 586
 			    $data['speed'] = $line['SOG'];
587 587
 			    $data['heading'] = $line['COG'];
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
591 591
 			    $data['imo'] = $line['IMO'];
592 592
 			    //$data['arrival_code'] = $ais_data['destination'];
593
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
593
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
594 594
 			    $data['format_source'] = 'myshiptracking';
595 595
 			    $data['id_source'] = $id_source;
596 596
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -607,9 +607,9 @@  discard block
 block discarded – undo
607 607
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
608 608
 	    )
609 609
 	) {
610
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
610
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
611 611
 	    if ($buffer != '') {
612
-		$all_data = json_decode($buffer,true);
612
+		$all_data = json_decode($buffer, true);
613 613
 		if (isset($all_data[0]['mmsi'])) {
614 614
 		    foreach ($all_data as $line) {
615 615
 			if ($line != '') {
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 	) {
644 644
 	    $buffer = $Common->getData($value['host']);
645 645
 	    if ($buffer != '') {
646
-		$all_data = json_decode($buffer,true);
646
+		$all_data = json_decode($buffer, true);
647 647
 		if (isset($all_data['features'][0]['id'])) {
648 648
 		    foreach ($all_data['features'] as $line) {
649 649
 			$data = array();
@@ -676,27 +676,27 @@  discard block
 block discarded – undo
676 676
 	    )
677 677
 	) {
678 678
 	    echo 'download...';
679
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
679
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
680 680
 	    echo 'done !'."\n";
681 681
 	    if ($buffer != '') $reset = 0;
682
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
683
-	    $buffer = explode('\n',$buffer);
682
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
683
+	    $buffer = explode('\n', $buffer);
684 684
 	    foreach ($buffer as $line) {
685 685
 		if ($line != '') {
686 686
 		    $data = array();
687
-		    $data['mmsi'] = (int)substr($line,0,9);
688
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
687
+		    $data['mmsi'] = (int) substr($line, 0, 9);
688
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
689 689
 		    //$data['status'] = substr($line,21,2);
690 690
 		    //$data['type'] = substr($line,24,3);
691
-		    $data['latitude'] = substr($line,29,9);
692
-		    $data['longitude'] = substr($line,41,9);
693
-		    $data['speed'] = round(substr($line,51,5));
691
+		    $data['latitude'] = substr($line, 29, 9);
692
+		    $data['longitude'] = substr($line, 41, 9);
693
+		    $data['speed'] = round(substr($line, 51, 5));
694 694
 		    //$data['course'] = substr($line,57,5);
695
-		    $data['heading'] = round(substr($line,63,3));
695
+		    $data['heading'] = round(substr($line, 63, 3));
696 696
 		    //$data['draft'] = substr($line,67,4);
697 697
 		    //$data['length'] = substr($line,72,3);
698 698
 		    //$data['beam'] = substr($line,76,2);
699
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
699
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
700 700
 		    //$data['callsign'] = trim(substr($line,100,7);
701 701
 		    //$data['dest'] = substr($line,108,20);
702 702
 		    //$data['etaDate'] = substr($line,129,5);
@@ -729,8 +729,8 @@  discard block
 block discarded – undo
729 729
 	) {
730 730
 	    //$buffer = $Common->getData($hosts[$id]);
731 731
 	    $buffer = $Common->getData($value['host']);
732
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
733
-	    $buffer = explode('\n',$buffer);
732
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
733
+	    $buffer = explode('\n', $buffer);
734 734
 	    $reset = 0;
735 735
 	    foreach ($buffer as $line) {
736 736
     		if ($line != '') {
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
742 742
 			$data['pilot_id'] = $line[1];
743 743
 			$data['pilot_name'] = $line[2];
744
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
744
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
745 745
 			$data['ident'] = $line[0]; // ident
746 746
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
747 747
 			$data['speed'] = $line[8]; // speed
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
758 758
 			//if (isset($line[37])) $data['last_update'] = $line[37];
759 759
 		        $data['departure_airport_icao'] = $line[11];
760
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
760
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
761 761
 		        $data['arrival_airport_icao'] = $line[13];
762 762
 			$data['frequency'] = $line[4];
763 763
 			$data['type'] = $line[18];
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
     			$data['id_source'] = $id_source;
767 767
 	    		//$data['arrival_airport_time'] = ;
768 768
 	    		if ($line[9] != '') {
769
-	    		    $aircraft_data = explode('/',$line[9]);
769
+	    		    $aircraft_data = explode('/', $line[9]);
770 770
 	    		    if (isset($aircraft_data[1])) {
771 771
 	    			$data['aircraft_icao'] = $aircraft_data[1];
772 772
 	    		    }
@@ -781,9 +781,9 @@  discard block
 block discarded – undo
781 781
     			if ($line[3] == 'PILOT') $SI->add($data);
782 782
 			elseif ($line[3] == 'ATC') {
783 783
 				//print_r($data);
784
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
785
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
786
-				$typec = substr($data['ident'],-3);
784
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
785
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
786
+				$typec = substr($data['ident'], -3);
787 787
 				if ($typec == 'APP') $data['type'] = 'Approach';
788 788
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
789 789
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -795,8 +795,8 @@  discard block
 block discarded – undo
795 795
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
796 796
 				if (!isset($data['source_name'])) $data['source_name'] = '';
797 797
 				if (isset($ATC)) {
798
-					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']);
799
-					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']);
798
+					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']);
799
+					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']);
800 800
 				}
801 801
 			}
802 802
     			unset($data);
@@ -812,24 +812,24 @@  discard block
 block discarded – undo
812 812
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
813 813
     	    )
814 814
     	) {
815
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
815
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
816 816
 	    if ($buffer != '') {
817 817
 		$all_data = simplexml_load_string($buffer);
818
-		foreach($all_data->children() as $childdata) {
818
+		foreach ($all_data->children() as $childdata) {
819 819
 			$data = array();
820 820
 			$line = $childdata;
821 821
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
822
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
823
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
824
-			$data['latitude'] = (float)$line['pktLatitude'];
825
-			$data['longitude'] = (float)$line['pktLongitude'];
826
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
827
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
828
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
822
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
823
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
824
+			$data['latitude'] = (float) $line['pktLatitude'];
825
+			$data['longitude'] = (float) $line['pktLongitude'];
826
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
827
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
828
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
829 829
 			$data['altitude_relative'] = 'AMSL';
830
-			$data['pilot_id'] = (int)$line['pktPilotID'];
830
+			$data['pilot_id'] = (int) $line['pktPilotID'];
831 831
 			$data['aircraft_icao'] = 'PARAGLIDER';
832
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
832
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
833 833
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
834 834
 			$data['format_source'] = $value['format'];
835 835
 			$SI->add($data);
@@ -837,22 +837,22 @@  discard block
 block discarded – undo
837 837
 		}
838 838
 	    }
839 839
 	    $Source->deleteOldLocationByType('gs');
840
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
840
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
841 841
 	    if ($buffer != '') {
842 842
 		$all_data = simplexml_load_string($buffer);
843
-		foreach($all_data->children() as $childdata) {
843
+		foreach ($all_data->children() as $childdata) {
844 844
 			$data = array();
845 845
 			$line = $childdata;
846
-			$data['id'] = (int)$line['gsID'];
847
-			$data['latitude'] = (float)$line['gsLatitude'];
848
-			$data['longitude'] = (float)$line['gsLongitude'];
849
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
846
+			$data['id'] = (int) $line['gsID'];
847
+			$data['latitude'] = (float) $line['gsLatitude'];
848
+			$data['longitude'] = (float) $line['gsLongitude'];
849
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
850 850
 			$data['altitude_relative'] = 'AMSL';
851
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
851
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
852 852
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
853
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
853
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
854 854
 			} else {
855
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
855
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
856 856
 			}
857 857
 			unset($data);
858 858
 		}
@@ -870,9 +870,9 @@  discard block
 block discarded – undo
870 870
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
871 871
 	    )
872 872
 	) {
873
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
873
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
874 874
 	    if ($buffer != '') {
875
-	        $all_data = json_decode($buffer,true);
875
+	        $all_data = json_decode($buffer, true);
876 876
 		if (isset($all_data['acList'])) {
877 877
 		    $reset = 0;
878 878
 		    foreach ($all_data['acList'] as $line) {
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
889 889
 			$data['emergency'] = ''; // emergency
890 890
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
891
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
891
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
892 892
 			else $data['datetime'] = date('Y-m-d H:i:s');
893 893
 			//$data['datetime'] = date('Y-m-d H:i:s');
894 894
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
 			$data['verticalrate'] = $line['vrt']; // verticale rate
914 914
 			$data['squawk'] = $line['squawk']; // squawk
915 915
 			$data['emergency'] = ''; // emergency
916
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
916
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
917 917
 			else $data['datetime'] = date('Y-m-d H:i:s');
918 918
 			$data['format_source'] = 'aircraftlistjson';
919 919
 			$data['id_source'] = $id_source;
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
     	    )
935 935
     	) {
936 936
 	    $buffer = $Common->getData($value['host']);
937
-	    $all_data = json_decode($buffer,true);
937
+	    $all_data = json_decode($buffer, true);
938 938
 	    if (isset($all_data['planes'])) {
939 939
 		$reset = 0;
940 940
 		foreach ($all_data['planes'] as $key => $line) {
@@ -951,12 +951,12 @@  discard block
 block discarded – undo
951 951
 		    $data['emergency'] = ''; // emergency
952 952
 		    $data['registration'] = $line[2];
953 953
 		    $data['aircraft_icao'] = $line[0];
954
-		    $deparr = explode('-',$line[1]);
954
+		    $deparr = explode('-', $line[1]);
955 955
 		    if (count($deparr) == 2) {
956 956
 			$data['departure_airport_icao'] = $deparr[0];
957 957
 			$data['arrival_airport_icao'] = $deparr[1];
958 958
 		    }
959
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
959
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
960 960
 	    	    $data['format_source'] = 'planeupdatefaa';
961 961
     		    $data['id_source'] = $id_source;
962 962
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 	    )
975 975
 	) {
976 976
 	    $buffer = $Common->getData($value['host']);
977
-	    $all_data = json_decode($buffer,true);
977
+	    $all_data = json_decode($buffer, true);
978 978
 	    if (isset($all_data['states'])) {
979 979
 		$reset = 0;
980 980
 		foreach ($all_data['states'] as $key => $line) {
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 		    //$data['emergency'] = ''; // emergency
992 992
 		    //$data['registration'] = $line[2];
993 993
 		    //$data['aircraft_icao'] = $line[0];
994
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
994
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
995 995
 		    $data['format_source'] = 'opensky';
996 996
 		    $data['id_source'] = $id_source;
997 997
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 	) {
1011 1011
 	    //$buffer = $Common->getData($hosts[$id]);
1012 1012
 	    $buffer = $Common->getData($value['host']);
1013
-	    $all_data = json_decode($buffer,true);
1013
+	    $all_data = json_decode($buffer, true);
1014 1014
 	    if (!empty($all_data)) $reset = 0;
1015 1015
 	    foreach ($all_data as $key => $line) {
1016 1016
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1048,11 +1048,11 @@  discard block
 block discarded – undo
1048 1048
 	    )
1049 1049
 	) {
1050 1050
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1051
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1051
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1052 1052
 	    //echo $buffer;
1053
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1054
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1055
-	    $all_data = json_decode($buffer,true);
1053
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1054
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1055
+	    $all_data = json_decode($buffer, true);
1056 1056
 	    if (json_last_error() != JSON_ERROR_NONE) {
1057 1057
 		die(json_last_error_msg());
1058 1058
 	    }
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
 			//$data['departure_airport_iata'] = $line[11];
1076 1076
 			//$data['arrival_airport_iata'] = $line[12];
1077 1077
 	    		//$data['emergency'] = ''; // emergency
1078
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1078
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1079 1079
 	    		$data['format_source'] = 'radarvirtueljson';
1080 1080
     			$data['id_source'] = $id_source;
1081 1081
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1096,14 +1096,14 @@  discard block
 block discarded – undo
1096 1096
 	) {
1097 1097
 	    //$buffer = $Common->getData($hosts[$id]);
1098 1098
 	    $buffer = $Common->getData($value['host'].'?'.time());
1099
-	    $all_data = json_decode(utf8_encode($buffer),true);
1099
+	    $all_data = json_decode(utf8_encode($buffer), true);
1100 1100
 	    
1101 1101
 	    if (isset($all_data['pireps'])) {
1102 1102
 		$reset = 0;
1103 1103
 	        foreach ($all_data['pireps'] as $line) {
1104 1104
 		    $data = array();
1105 1105
 		    $data['id'] = $line['id'];
1106
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1106
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1107 1107
 		    $data['ident'] = $line['callsign']; // ident
1108 1108
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1109 1109
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1133,9 +1133,9 @@  discard block
 block discarded – undo
1133 1133
 			$SI->add($data);
1134 1134
 		    //    print_r($data);
1135 1135
     		    } elseif ($line['icon'] == 'ct') {
1136
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1137
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1138
-			$typec = substr($data['ident'],-3);
1136
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1137
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1138
+			$typec = substr($data['ident'], -3);
1139 1139
 			$data['type'] = '';
1140 1140
 			if ($typec == 'APP') $data['type'] = 'Approach';
1141 1141
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1147 1147
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1148 1148
 			else $data['type'] = 'Observer';
1149
-			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']);
1149
+			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']);
1150 1150
 		    }
1151 1151
 		    unset($data);
1152 1152
 		}
@@ -1163,14 +1163,14 @@  discard block
 block discarded – undo
1163 1163
 	    //$buffer = $Common->getData($hosts[$id]);
1164 1164
 	    if ($globalDebug) echo 'Get Data...'."\n";
1165 1165
 	    $buffer = $Common->getData($value['host']);
1166
-	    $all_data = json_decode($buffer,true);
1166
+	    $all_data = json_decode($buffer, true);
1167 1167
 	    if ($buffer != '' && is_array($all_data)) {
1168 1168
 		$reset = 0;
1169 1169
 		foreach ($all_data as $line) {
1170 1170
 	    	    $data = array();
1171 1171
 	    	    //$data['id'] = $line['id']; // id not usable
1172 1172
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1173
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1173
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1174 1174
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1175 1175
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1176 1176
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1185,7 +1185,7 @@  discard block
 block discarded – undo
1185 1185
 	    	    //$data['datetime'] = $line['lastupdate'];
1186 1186
 	    	    //$data['last_update'] = $line['lastupdate'];
1187 1187
 	    	    if (isset($value['timezone'])) {
1188
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1188
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1189 1189
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1190 1190
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1191 1191
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1201,14 +1201,14 @@  discard block
 block discarded – undo
1201 1201
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1202 1202
 		    if (isset($line['aircraftname'])) {
1203 1203
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1204
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1205
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1204
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1205
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1206 1206
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1207 1207
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1208 1208
 	    		else {
1209
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1210
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1211
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1209
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1210
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1211
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1212 1212
 	    		}
1213 1213
 	    	    }
1214 1214
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 	    //$buffer = $Common->getData($hosts[$id]);
1234 1234
 	    if ($globalDebug) echo 'Get Data...'."\n";
1235 1235
 	    $buffer = $Common->getData($value['host']);
1236
-	    $all_data = json_decode($buffer,true);
1236
+	    $all_data = json_decode($buffer, true);
1237 1237
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1238 1238
 		$reset = 0;
1239 1239
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1245 1245
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1246 1246
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1247
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1247
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1248 1248
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1249 1249
 	    	    $data['altitude'] = $line['altitude']; // altitude
1250 1250
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 	    	    //$data['squawk'] = ''; // squawk
1256 1256
 	    	    //$data['emergency'] = ''; // emergency
1257 1257
 	    	    if (isset($value['timezone'])) {
1258
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1258
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1259 1259
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1260 1260
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1261 1261
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1291,14 +1291,14 @@  discard block
 block discarded – undo
1291 1291
 	    //$buffer = $Common->getData($hosts[$id]);
1292 1292
 	    if ($globalDebug) echo 'Get Data...'."\n";
1293 1293
 	    $buffer = $Common->getData($value['host']);
1294
-	    $all_data = json_decode($buffer,true);
1294
+	    $all_data = json_decode($buffer, true);
1295 1295
 	    if ($buffer != '' && is_array($all_data)) {
1296 1296
 		$reset = 0;
1297 1297
 		foreach ($all_data as $line) {
1298 1298
 	    	    $data = array();
1299 1299
 	    	    //$data['id'] = $line['id']; // id not usable
1300 1300
 	    	    $data['id'] = trim($line['flight_id']);
1301
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1301
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1302 1302
 	    	    $data['pilot_name'] = $line['pilot_name'];
1303 1303
 	    	    $data['pilot_id'] = $line['pilot_id'];
1304 1304
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1342,24 +1342,24 @@  discard block
 block discarded – undo
1342 1342
 	    //$buffer = $Common->getData($hosts[$id]);
1343 1343
 	    if ($globalDebug) echo 'Get Data...'."\n";
1344 1344
 	    $buffer = $Common->getData($value['host']);
1345
-	    $all_data = json_decode($buffer,true);
1345
+	    $all_data = json_decode($buffer, true);
1346 1346
 	    if ($buffer != '') {
1347 1347
 		$Source->deleteLocationBySource('blitzortung');
1348
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1349
-		$buffer = explode('\n',$buffer);
1348
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1349
+		$buffer = explode('\n', $buffer);
1350 1350
 		foreach ($buffer as $buffer_line) {
1351
-		    $line = json_decode($buffer_line,true);
1351
+		    $line = json_decode($buffer_line, true);
1352 1352
 		    if (isset($line['time'])) {
1353 1353
 			$data = array();
1354 1354
 			$data['altitude'] = $line['alt']; // altitude
1355 1355
 			$data['latitude'] = $line['lat']; // lat
1356 1356
 			$data['longitude'] = $line['lon']; // long
1357
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1357
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1358 1358
 			$data['id_source'] = $id_source;
1359 1359
 			$data['format_source'] = 'blitzortung';
1360 1360
 			$SI->add($data);
1361 1361
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1362
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1362
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1363 1363
 			unset($data);
1364 1364
 		    }
1365 1365
 		}
@@ -1384,11 +1384,11 @@  discard block
 block discarded – undo
1384 1384
 		    //$value = $formats[$nb];
1385 1385
 		    $format = $globalSources[$nb]['format'];
1386 1386
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1387
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1387
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1388 1388
 		    } elseif ($format == 'vrstcp') {
1389 1389
 			$buffer = @socket_read($r, 6000);
1390 1390
 		    } else {
1391
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1391
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1392 1392
 		    }
1393 1393
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1394 1394
 		    //echo $buffer."\n";
@@ -1398,8 +1398,8 @@  discard block
 block discarded – undo
1398 1398
 		    //$SI::del();
1399 1399
 		    if ($buffer !== FALSE) {
1400 1400
 			if ($format == 'vrstcp') {
1401
-			    $buffer = explode('},{',$buffer);
1402
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1401
+			    $buffer = explode('},{', $buffer);
1402
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1403 1403
 		    }
1404 1404
 		    // SBS format is CSV format
1405 1405
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1434,13 +1434,13 @@  discard block
 block discarded – undo
1434 1434
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1435 1435
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1436 1436
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1437
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1437
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1438 1438
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1439 1439
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1440 1440
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1441 1441
 
1442 1442
 			    if (isset($ais_data['timestamp'])) {
1443
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1443
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1444 1444
 			    } else {
1445 1445
 				$data['datetime'] = date('Y-m-d H:i:s');
1446 1446
 			    }
@@ -1451,10 +1451,10 @@  discard block
 block discarded – undo
1451 1451
                         } elseif ($format == 'flightgearsp') {
1452 1452
                     	    //echo $buffer."\n";
1453 1453
                     	    if (strlen($buffer) > 5) {
1454
-				$line = explode(',',$buffer);
1454
+				$line = explode(',', $buffer);
1455 1455
 				$data = array();
1456 1456
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1457
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1457
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1458 1458
 				$data['ident'] = $line[6];
1459 1459
 				$data['aircraft_name'] = $line[7];
1460 1460
 				$data['longitude'] = $line[1];
@@ -1471,16 +1471,16 @@  discard block
 block discarded – undo
1471 1471
                         } elseif ($format == 'acars') {
1472 1472
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1473 1473
 			    $ACARS->add(trim($buffer));
1474
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1474
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1475 1475
 			    $ACARS->deleteLiveAcarsData();
1476 1476
 			} elseif ($format == 'flightgearmp') {
1477
-			    if (substr($buffer,0,1) != '#') {
1477
+			    if (substr($buffer, 0, 1) != '#') {
1478 1478
 				$data = array();
1479 1479
 				//echo $buffer."\n";
1480
-				$line = explode(' ',$buffer);
1480
+				$line = explode(' ', $buffer);
1481 1481
 				if (count($line) == 11) {
1482
-				    $userserver = explode('@',$line[0]);
1483
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1482
+				    $userserver = explode('@', $line[0]);
1483
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1484 1484
 				    $data['ident'] = $userserver[0];
1485 1485
 				    $data['registration'] = $userserver[0];
1486 1486
 				    $data['latitude'] = $line[4];
@@ -1488,8 +1488,8 @@  discard block
 block discarded – undo
1488 1488
 				    $data['altitude'] = $line[6];
1489 1489
 				    $data['datetime'] = date('Y-m-d H:i:s');
1490 1490
 				    $aircraft_type = $line[10];
1491
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1492
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1491
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1492
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1493 1493
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1494 1494
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1495 1495
 				}
@@ -1498,8 +1498,8 @@  discard block
 block discarded – undo
1498 1498
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1499 1499
 			    die;
1500 1500
 			} elseif ($format == 'vrstcp') {
1501
-			    foreach($buffer as $all_data) {
1502
-				$line = json_decode('{'.$all_data.'}',true);
1501
+			    foreach ($buffer as $all_data) {
1502
+				$line = json_decode('{'.$all_data.'}', true);
1503 1503
 				$data = array();
1504 1504
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1505 1505
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1525,16 +1525,16 @@  discard block
 block discarded – undo
1525 1525
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1526 1526
 				unset($data);
1527 1527
 			    }
1528
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1528
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1529 1529
 			    $line = explode("\t", $buffer);
1530
-			    for($k = 0; $k < count($line); $k=$k+2) {
1530
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1531 1531
 				$key = $line[$k];
1532
-			        $lined[$key] = $line[$k+1];
1532
+			        $lined[$key] = $line[$k + 1];
1533 1533
 			    }
1534 1534
     			    if (count($lined) > 3) {
1535 1535
     				$data['hex'] = $lined['hexid'];
1536 1536
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1537
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1537
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1538 1538
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1539 1539
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1540 1540
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1553,23 +1553,23 @@  discard block
 block discarded – undo
1553 1553
     			    } else $error = true;
1554 1554
 			} elseif ($format == 'aprs' && $use_aprs) {
1555 1555
 			    if ($aprs_connect == 0) {
1556
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1556
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1557 1557
 				$aprs_connect = 1;
1558 1558
 			    }
1559 1559
 			    
1560
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1560
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1561 1561
 				$aprs_last_tx = time();
1562 1562
 				$data_aprs = "# Keep alive";
1563
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1563
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1564 1564
 			    }
1565 1565
 			    
1566 1566
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1567 1567
 			    //echo 'APRS data : '.$buffer."\n";
1568
-			    $buffer = str_replace('APRS <- ','',$buffer);
1569
-			    $buffer = str_replace('APRS -> ','',$buffer);
1568
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1569
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1570 1570
 			    //echo $buffer."\n";
1571 1571
 			    date_default_timezone_set('UTC');
1572
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1572
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1573 1573
 				$line = $APRS->parse($buffer);
1574 1574
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1575 1575
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1584,7 +1584,7 @@  discard block
 block discarded – undo
1584 1584
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1585 1585
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1586 1586
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1587
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1587
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1588 1588
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1589 1589
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1590 1590
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1667,29 +1667,29 @@  discard block
 block discarded – undo
1667 1667
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1668 1668
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1669 1669
 					$Source->deleteOldLocationByType('gs');
1670
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1671
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1670
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1671
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1672 1672
 					} else {
1673
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1673
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1674 1674
 					}
1675 1675
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1676 1676
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1677 1677
 					if ($globalDebug) echo '# Weather Station added'."\n";
1678 1678
 					$Source->deleteOldLocationByType('wx');
1679 1679
 					$weather_data = json_encode($line);
1680
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1681
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1680
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1681
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1682 1682
 					} else {
1683
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1683
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1684 1684
 					}
1685 1685
 				    } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1686 1686
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1687 1687
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1688 1688
 					$Source->deleteOldLocationByType('lightning');
1689
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1690
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1689
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1690
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1691 1691
 					} else {
1692
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1692
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1693 1693
 					}
1694 1694
 				    } elseif ($globalDebug) {
1695 1695
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1698,7 +1698,7 @@  discard block
 block discarded – undo
1698 1698
 				    unset($data);
1699 1699
 				}
1700 1700
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1701
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1701
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1702 1702
 				}
1703 1703
 				/*
1704 1704
 				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')) {
@@ -1707,7 +1707,7 @@  discard block
 block discarded – undo
1707 1707
 				*/
1708 1708
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1709 1709
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1710
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1710
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1711 1711
 					$Source->deleteOldLocationByType('lightning');
1712 1712
 					$Source->deleteOldLocationByType('wx');
1713 1713
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1792,7 +1792,7 @@  discard block
 block discarded – undo
1792 1792
 				connect_all($sourceee);
1793 1793
 				$sourceee = array();
1794 1794
 				//connect_all($globalSources);
1795
-				$tt[$format]=0;
1795
+				$tt[$format] = 0;
1796 1796
 				break;
1797 1797
 			    } 
1798 1798
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -1802,14 +1802,14 @@  discard block
 block discarded – undo
1802 1802
 	    } else {
1803 1803
 		$error = socket_strerror(socket_last_error());
1804 1804
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1805
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1805
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1806 1806
 			if (isset($globalDebug)) echo "Restarting...\n";
1807 1807
 			// Restart the script if possible
1808 1808
 			if (is_array($sockets)) {
1809 1809
 			    if ($globalDebug) echo "Shutdown all sockets...";
1810 1810
 			    
1811 1811
 			    foreach ($sockets as $sock) {
1812
-				@socket_shutdown($sock,2);
1812
+				@socket_shutdown($sock, 2);
1813 1813
 				@socket_close($sock);
1814 1814
 			    }
1815 1815
 			    
Please login to merge, or discard this patch.
Braces   +1081 added lines, -368 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -59,66 +63,107 @@  discard block
 block discarded – undo
59 63
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 64
 if (isset($options['s'])) {
61 65
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
64
-} elseif (isset($options['source'])) {
66
+    if (isset($options['format'])) {
67
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
68
+    } else {
69
+    	$globalSources[] = array('host' => $options['s']);
70
+    }
71
+    } elseif (isset($options['source'])) {
65 72
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
68
-}
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['source']);
77
+    }
78
+    }
69 79
 if (isset($options['aprsserverhost'])) {
70 80
 	$globalServerAPRS = TRUE;
71 81
 	$globalServerAPRShost = $options['aprsserverhost'];
72 82
 }
73
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
74
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
75
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
76
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
83
+if (isset($options['aprsserverport'])) {
84
+	$globalServerAPRSport = $options['aprsserverport'];
85
+}
86
+if (isset($options['aprsserverssid'])) {
87
+	$globalServerAPRSssid = $options['aprsserverssid'];
88
+}
89
+if (isset($options['aprsserverpass'])) {
90
+	$globalServerAPRSpass = $options['aprsserverpass'];
91
+}
92
+if (isset($options['noaprsserver'])) {
93
+	$globalServerAPRS = FALSE;
94
+}
77 95
 if (isset($options['enable-aircraft'])) {
78
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
96
+	if ($globalDebug) {
97
+		echo 'Enable Aircraft mode'."\n";
98
+	}
79 99
 	$globalAircraft = TRUE; 
80 100
 }
81 101
 if (isset($options['disable-aircraft'])) {
82
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
102
+	if ($globalDebug) {
103
+		echo 'Disable Aircraft mode'."\n";
104
+	}
83 105
 	$globalAircraft = FALSE;
84 106
 }
85 107
 if (isset($options['enable-tracker'])) {
86
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
108
+	if ($globalDebug) {
109
+		echo 'Enable Tracker mode'."\n";
110
+	}
87 111
 	$globalTracker = TRUE; 
88 112
 }
89 113
 if (isset($options['disable-tracker'])) {
90
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
114
+	if ($globalDebug) {
115
+		echo 'Disable Tracker mode'."\n";
116
+	}
91 117
 	$globalTracker = FALSE;
92 118
 }
93 119
 if (isset($options['enable-marine'])) {
94
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
120
+	if ($globalDebug) {
121
+		echo 'Enable Marine mode'."\n";
122
+	}
95 123
 	$globalMarine = TRUE;
96 124
 }
97 125
 if (isset($options['disable-marine'])) {
98
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
126
+	if ($globalDebug) {
127
+		echo 'Disable Marine mode'."\n";
128
+	}
99 129
 	$globalMarine = FALSE;
100 130
 }
101
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
102
-if (isset($options['server'])) $globalServer = TRUE;
103
-if (isset($options['idsource'])) $id_source = $options['idsource'];
104
-else $id_source = 1;
131
+if (isset($options['nodaemon'])) {
132
+	$globalDaemon = FALSE;
133
+}
134
+if (isset($options['server'])) {
135
+	$globalServer = TRUE;
136
+}
137
+if (isset($options['idsource'])) {
138
+	$id_source = $options['idsource'];
139
+} else {
140
+	$id_source = 1;
141
+}
105 142
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
143
+    if ($globalDebug) {
144
+    	echo "Using Server Mode\n";
145
+    }
107 146
     $SI=new SpotterServer();
108 147
 /*
109 148
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 149
     $SI = new adsb2aprs();
111 150
     $SI->connect();
112 151
 */
113
-} else $SI=new SpotterImport($Connection->db);
152
+} else {
153
+	$SI=new SpotterImport($Connection->db);
154
+}
114 155
 
115
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
156
+if (isset($globalTracker) && $globalTracker) {
157
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
158
+}
116 159
 if (isset($globalMarine) && $globalMarine) {
117 160
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
118 161
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 162
 }
120 163
 
121
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
164
+if (isset($globalTracker) && $globalTracker) {
165
+	$TI = new TrackerImport($Connection->db);
166
+}
122 167
 if (isset($globalMarine) && $globalMarine) {
123 168
     $AIS = new AIS();
124 169
     $MI = new MarineImport($Connection->db);
@@ -143,7 +188,9 @@  discard block
 block discarded – undo
143 188
 }
144 189
 
145 190
 // let's try and connect
146
-if ($globalDebug) echo "Connecting...\n";
191
+if ($globalDebug) {
192
+	echo "Connecting...\n";
193
+}
147 194
 $use_aprs = false;
148 195
 $aprs_full = false;
149 196
 $reset = 0;
@@ -152,7 +199,9 @@  discard block
 block discarded – undo
152 199
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153 200
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154 201
     $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
202
+    if ($globalDebug) {
203
+    	echo 'Connect to all...'."\n";
204
+    }
156 205
     foreach ($hosts as $id => $value) {
157 206
 	$host = $value['host'];
158 207
 	$globalSources[$id]['last_exec'] = 0;
@@ -162,22 +211,30 @@  discard block
 block discarded – undo
162 211
         	//$formats[$id] = 'deltadbtxt';
163 212
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 213
         	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to deltadb source (".$host.")...\n";
216
+        	}
166 217
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167 218
         	//$formats[$id] = 'vatsimtxt';
168 219
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 220
         	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
221
+        	if ($globalDebug) {
222
+        		echo "Connect to vatsim source (".$host.")...\n";
223
+        	}
171 224
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172 225
         	//$formats[$id] = 'aircraftlistjson';
173 226
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 227
         	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
230
+        	}
176 231
     	    } else if (preg_match('/opensky/i',$host)) {
177 232
         	//$formats[$id] = 'aircraftlistjson';
178 233
         	$globalSources[$id]['format'] = 'opensky';
179 234
         	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
235
+        	if ($globalDebug) {
236
+        		echo "Connect to opensky source (".$host.")...\n";
237
+        	}
181 238
     	    /*
182 239
     	    // Disabled for now, site change source format
183 240
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -194,7 +251,9 @@  discard block
 block discarded – undo
194 251
         	//$formats[$id] = 'planeupdatefaa';
195 252
         	$globalSources[$id]['format'] = 'planeupdatefaa';
196 253
         	//$last_exec['planeupdatefaa'] = 0;
197
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
254
+        	if ($globalDebug) {
255
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
256
+        	}
198 257
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
199 258
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200 259
         	    exit(0);
@@ -203,37 +262,53 @@  discard block
 block discarded – undo
203 262
         	//$formats[$id] = 'phpvmacars';
204 263
         	$globalSources[$id]['format'] = 'phpvmacars';
205 264
         	//$last_exec['phpvmacars'] = 0;
206
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
265
+        	if ($globalDebug) {
266
+        		echo "Connect to phpvmacars source (".$host.")...\n";
267
+        	}
207 268
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
208 269
         	//$formats[$id] = 'phpvmacars';
209 270
         	$globalSources[$id]['format'] = 'vaos';
210 271
         	//$last_exec['phpvmacars'] = 0;
211
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
272
+        	if ($globalDebug) {
273
+        		echo "Connect to vaos source (".$host.")...\n";
274
+        	}
212 275
             } else if (preg_match('/VAM-json.php$/i',$host)) {
213 276
         	//$formats[$id] = 'phpvmacars';
214 277
         	$globalSources[$id]['format'] = 'vam';
215
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
278
+        	if ($globalDebug) {
279
+        		echo "Connect to Vam source (".$host.")...\n";
280
+        	}
216 281
             } else if (preg_match('/whazzup/i',$host)) {
217 282
         	//$formats[$id] = 'whazzup';
218 283
         	$globalSources[$id]['format'] = 'whazzup';
219 284
         	//$last_exec['whazzup'] = 0;
220
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
285
+        	if ($globalDebug) {
286
+        		echo "Connect to whazzup source (".$host.")...\n";
287
+        	}
221 288
             } else if (preg_match('/blitzortung/i',$host)) {
222 289
         	$globalSources[$id]['format'] = 'blitzortung';
223
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
290
+        	if ($globalDebug) {
291
+        		echo "Connect to blitzortung source (".$host.")...\n";
292
+        	}
224 293
             } else if (preg_match('/airwhere/i',$host)) {
225 294
         	$globalSources[$id]['format'] = 'airwhere';
226
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
295
+        	if ($globalDebug) {
296
+        		echo "Connect to airwhere source (".$host.")...\n";
297
+        	}
227 298
             } else if (preg_match('/recentpireps/i',$host)) {
228 299
         	//$formats[$id] = 'pirepsjson';
229 300
         	$globalSources[$id]['format'] = 'pirepsjson';
230 301
         	//$last_exec['pirepsjson'] = 0;
231
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
302
+        	if ($globalDebug) {
303
+        		echo "Connect to pirepsjson source (".$host.")...\n";
304
+        	}
232 305
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
233 306
         	//$formats[$id] = 'fr24json';
234 307
         	$globalSources[$id]['format'] = 'fr24json';
235 308
         	//$last_exec['fr24json'] = 0;
236
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
309
+        	if ($globalDebug) {
310
+        		echo "Connect to fr24 source (".$host.")...\n";
311
+        	}
237 312
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
238 313
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
239 314
         	    exit(0);
@@ -242,7 +317,9 @@  discard block
 block discarded – undo
242 317
         	//$formats[$id] = 'fr24json';
243 318
         	$globalSources[$id]['format'] = 'myshiptracking';
244 319
         	//$last_exec['fr24json'] = 0;
245
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
320
+        	if ($globalDebug) {
321
+        		echo "Connect to myshiptracking source (".$host.")...\n";
322
+        	}
246 323
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
247 324
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
248 325
         	    exit(0);
@@ -251,16 +328,24 @@  discard block
 block discarded – undo
251 328
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
252 329
         	//$formats[$id] = 'tsv';
253 330
         	$globalSources[$id]['format'] = 'tsv';
254
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
331
+        	if ($globalDebug) {
332
+        		echo "Connect to tsv source (".$host.")...\n";
333
+        	}
255 334
             }
256 335
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
257 336
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
258 337
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
259 338
     		    if ($idf !== false) {
260 339
     			$httpfeeds[$id] = $idf;
261
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
262
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
263
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
340
+        		if ($globalDebug) {
341
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
342
+        		}
343
+    		    } elseif ($globalDebug) {
344
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
345
+    		    }
346
+    		} elseif ($globalDebug) {
347
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
348
+    		}
264 349
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
265 350
 	    $hostport = explode(':',$host);
266 351
 	    if (isset($hostport[1])) {
@@ -300,17 +385,25 @@  discard block
 block discarded – undo
300 385
         		//$formats[$id] = 'beast';
301 386
         		$globalSources[$id]['format'] = 'beast';
302 387
 		    //} else $formats[$id] = 'sbs';
303
-		    } else $globalSources[$id]['format'] = 'sbs';
388
+		    } else {
389
+		    	$globalSources[$id]['format'] = 'sbs';
390
+		    }
304 391
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
305 392
 		}
306
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
393
+		if ($globalDebug) {
394
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
395
+		}
307 396
             } else {
308
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
397
+		if ($globalDebug) {
398
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
399
+		}
309 400
     	    }
310 401
         }
311 402
     }
312 403
 }
313
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
404
+if (!isset($globalMinFetch)) {
405
+	$globalMinFetch = 15;
406
+}
314 407
 
315 408
 // Initialize all
316 409
 $status = array();
@@ -319,13 +412,19 @@  discard block
 block discarded – undo
319 412
 $formats = array();
320 413
 $last_exec = array();
321 414
 $time = time();
322
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
323
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
324
-else $timeout = 20;
415
+if (isset($globalSourcesTimeout)) {
416
+	$timeout = $globalSourcesTimeOut;
417
+} else if (isset($globalSBS1TimeOut)) {
418
+	$timeout = $globalSBS1TimeOut;
419
+} else {
420
+	$timeout = 20;
421
+}
325 422
 $errno = '';
326 423
 $errstr='';
327 424
 
328
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
425
+if (!isset($globalDaemon)) {
426
+	$globalDaemon = TRUE;
427
+}
329 428
 /* Initiate connections to all the hosts simultaneously */
330 429
 //connect_all($hosts);
331 430
 //connect_all($globalSources);
@@ -354,7 +453,9 @@  discard block
 block discarded – undo
354 453
     if (isset($source['format']) && $source['format'] == 'aprs') {
355 454
 	$aprs_connect = 0;
356 455
 	$use_aprs = true;
357
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
456
+	if (isset($source['port']) && $source['port'] == '10152') {
457
+		$aprs_full = true;
458
+	}
358 459
 	break;
359 460
     }
360 461
 }
@@ -365,25 +466,46 @@  discard block
 block discarded – undo
365 466
 	$aprs_connect = 0;
366 467
 	$aprs_keep = 120;
367 468
 	$aprs_last_tx = time();
368
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
369
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
370
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
371
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
372
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
373
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
374
-	if ($aprs_full) $aprs_filter = '';
375
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
376
-	else $aprs_pass = '-1';
469
+	if (isset($globalAPRSversion)) {
470
+		$aprs_version = $globalAPRSversion;
471
+	} else {
472
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
473
+	}
474
+	if (isset($globalAPRSssid)) {
475
+		$aprs_ssid = $globalAPRSssid;
476
+	} else {
477
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
478
+	}
479
+	if (isset($globalAPRSfilter)) {
480
+		$aprs_filter = $globalAPRSfilter;
481
+	} else {
482
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
483
+	}
484
+	if ($aprs_full) {
485
+		$aprs_filter = '';
486
+	}
487
+	if (isset($globalAPRSpass)) {
488
+		$aprs_pass = $globalAPRSpass;
489
+	} else {
490
+		$aprs_pass = '-1';
491
+	}
377 492
 
378
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
379
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
380
-}
493
+	if ($aprs_filter != '') {
494
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
495
+	} else {
496
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
497
+	}
498
+	}
381 499
 
382 500
 // connected - lets do some work
383 501
 //if ($globalDebug) echo "Connected!\n";
384 502
 sleep(1);
385
-if ($globalDebug) echo "SCAN MODE \n\n";
386
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
503
+if ($globalDebug) {
504
+	echo "SCAN MODE \n\n";
505
+}
506
+if (!isset($globalCronEnd)) {
507
+	$globalCronEnd = 60;
508
+}
387 509
 $endtime = time()+$globalCronEnd;
388 510
 $i = 1;
389 511
 $tt = array();
@@ -397,20 +519,28 @@  discard block
 block discarded – undo
397 519
 
398 520
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
399 521
 while ($i > 0) {
400
-    if (!$globalDaemon) $i = $endtime-time();
522
+    if (!$globalDaemon) {
523
+    	$i = $endtime-time();
524
+    }
401 525
     // Delete old ATC
402 526
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
403
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
527
+	if ($globalDebug) {
528
+		echo 'Delete old ATC...'."\n";
529
+	}
404 530
         $ATC->deleteOldATC();
405 531
     }
406 532
     
407 533
     if (count($last_exec) == count($globalSources)) {
408 534
 	$max = $globalMinFetch;
409 535
 	foreach ($last_exec as $last) {
410
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
536
+	    if ((time() - $last['last']) < $max) {
537
+	    	$max = time() - $last['last'];
538
+	    }
411 539
 	}
412 540
 	if ($max != $globalMinFetch) {
413
-	    if ($globalDebug) echo 'Sleeping...'."\n";
541
+	    if ($globalDebug) {
542
+	    	echo 'Sleeping...'."\n";
543
+	    }
414 544
 	    sleep($globalMinFetch-$max+2);
415 545
 	}
416 546
     }
@@ -420,7 +550,9 @@  discard block
 block discarded – undo
420 550
     foreach ($globalSources as $id => $value) {
421 551
 	date_default_timezone_set('UTC');
422 552
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
423
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
553
+	if (!isset($last_exec[$id]['last'])) {
554
+		$last_exec[$id]['last'] = 0;
555
+	}
424 556
 	if ($value['format'] == 'deltadbtxt' && 
425 557
 	    (
426 558
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -429,7 +561,9 @@  discard block
 block discarded – undo
429 561
 	) {
430 562
 	    //$buffer = $Common->getData($hosts[$id]);
431 563
 	    $buffer = $Common->getData($value['host']);
432
-	    if ($buffer != '') $reset = 0;
564
+	    if ($buffer != '') {
565
+	    	$reset = 0;
566
+	    }
433 567
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434 568
 	    $buffer = explode('\n',$buffer);
435 569
 	    foreach ($buffer as $line) {
@@ -438,20 +572,41 @@  discard block
 block discarded – undo
438 572
 	            $data = array();
439 573
 	            $data['hex'] = $line[1]; // hex
440 574
 	            $data['ident'] = $line[2]; // ident
441
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
442
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
443
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
444
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
445
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
575
+	            if (isset($line[3])) {
576
+	            	$data['altitude'] = $line[3];
577
+	            }
578
+	            // altitude
579
+	            if (isset($line[4])) {
580
+	            	$data['speed'] = $line[4];
581
+	            }
582
+	            // speed
583
+	            if (isset($line[5])) {
584
+	            	$data['heading'] = $line[5];
585
+	            }
586
+	            // heading
587
+	            if (isset($line[6])) {
588
+	            	$data['latitude'] = $line[6];
589
+	            }
590
+	            // lat
591
+	            if (isset($line[7])) {
592
+	            	$data['longitude'] = $line[7];
593
+	            }
594
+	            // long
446 595
 	            $data['verticalrate'] = ''; // vertical rate
447 596
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
448 597
 	            $data['emergency'] = ''; // emergency
449 598
 		    $data['datetime'] = date('Y-m-d H:i:s');
450 599
 		    $data['format_source'] = 'deltadbtxt';
451 600
     		    $data['id_source'] = $id_source;
452
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
453
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
454
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
601
+		    if (isset($value['name']) && $value['name'] != '') {
602
+		    	$data['source_name'] = $value['name'];
603
+		    }
604
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
605
+		    	$data['noarchive'] = true;
606
+		    }
607
+		    if (isset($value['sourcestats'])) {
608
+		    	$data['sourcestats'] = $value['sourcestats'];
609
+		    }
455 610
     		    $SI->add($data);
456 611
 		    unset($data);
457 612
     		}
@@ -466,7 +621,9 @@  discard block
 block discarded – undo
466 621
 	    date_default_timezone_set('CET');
467 622
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
468 623
 	    date_default_timezone_set('UTC');
469
-	    if ($buffer != '') $reset = 0;
624
+	    if ($buffer != '') {
625
+	    	$reset = 0;
626
+	    }
470 627
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
471 628
 	    $buffer = explode('\n',$buffer);
472 629
 	    foreach ($buffer as $line) {
@@ -475,16 +632,36 @@  discard block
 block discarded – undo
475 632
 		    $add = false;
476 633
 		    $ais_data = $AIS->parse_line(trim($line));
477 634
 		    $data = array();
478
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
479
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
480
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
481
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
482
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
483
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
484
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
485
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
486
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
487
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
635
+		    if (isset($ais_data['ident'])) {
636
+		    	$data['ident'] = $ais_data['ident'];
637
+		    }
638
+		    if (isset($ais_data['mmsi'])) {
639
+		    	$data['mmsi'] = $ais_data['mmsi'];
640
+		    }
641
+		    if (isset($ais_data['speed'])) {
642
+		    	$data['speed'] = $ais_data['speed'];
643
+		    }
644
+		    if (isset($ais_data['heading'])) {
645
+		    	$data['heading'] = $ais_data['heading'];
646
+		    }
647
+		    if (isset($ais_data['latitude'])) {
648
+		    	$data['latitude'] = $ais_data['latitude'];
649
+		    }
650
+		    if (isset($ais_data['longitude'])) {
651
+		    	$data['longitude'] = $ais_data['longitude'];
652
+		    }
653
+		    if (isset($ais_data['status'])) {
654
+		    	$data['status'] = $ais_data['status'];
655
+		    }
656
+		    if (isset($ais_data['type'])) {
657
+		    	$data['type'] = $ais_data['type'];
658
+		    }
659
+		    if (isset($ais_data['imo'])) {
660
+		    	$data['imo'] = $ais_data['imo'];
661
+		    }
662
+		    if (isset($ais_data['callsign'])) {
663
+		    	$data['callsign'] = $ais_data['callsign'];
664
+		    }
488 665
 		    if (isset($ais_data['timestamp'])) {
489 666
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
490 667
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -498,8 +675,12 @@  discard block
 block discarded – undo
498 675
 		    $data['format_source'] = 'aisnmeatxt';
499 676
     		    $data['id_source'] = $id_source;
500 677
 		    //print_r($data);
501
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
502
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
678
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
679
+		    	$data['noarchive'] = true;
680
+		    }
681
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
682
+		    	$MI->add($data);
683
+		    }
503 684
 		    unset($data);
504 685
 		}
505 686
     	    }
@@ -522,20 +703,48 @@  discard block
 block discarded – undo
522 703
 			    if ($line != '') {
523 704
 				$ais_data = $AIS->parse_line(trim($line));
524 705
 				$data = array();
525
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
526
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
527
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
528
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
529
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
530
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
531
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
532
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
533
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
534
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
535
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
536
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
537
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
538
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
706
+				if (isset($ais_data['ident'])) {
707
+					$data['ident'] = $ais_data['ident'];
708
+				}
709
+				if (isset($ais_data['mmsi'])) {
710
+					$data['mmsi'] = $ais_data['mmsi'];
711
+				}
712
+				if (isset($ais_data['speed'])) {
713
+					$data['speed'] = $ais_data['speed'];
714
+				}
715
+				if (isset($ais_data['heading'])) {
716
+					$data['heading'] = $ais_data['heading'];
717
+				}
718
+				if (isset($ais_data['latitude'])) {
719
+					$data['latitude'] = $ais_data['latitude'];
720
+				}
721
+				if (isset($ais_data['longitude'])) {
722
+					$data['longitude'] = $ais_data['longitude'];
723
+				}
724
+				if (isset($ais_data['status'])) {
725
+					$data['status'] = $ais_data['status'];
726
+				}
727
+				if (isset($ais_data['statusid'])) {
728
+					$data['status_id'] = $ais_data['statusid'];
729
+				}
730
+				if (isset($ais_data['type'])) {
731
+					$data['type'] = $ais_data['type'];
732
+				}
733
+				if (isset($ais_data['typeid'])) {
734
+					$data['type_id'] = $ais_data['typeid'];
735
+				}
736
+				if (isset($ais_data['imo'])) {
737
+					$data['imo'] = $ais_data['imo'];
738
+				}
739
+				if (isset($ais_data['callsign'])) {
740
+					$data['callsign'] = $ais_data['callsign'];
741
+				}
742
+				if (isset($ais_data['destination'])) {
743
+					$data['arrival_code'] = $ais_data['destination'];
744
+				}
745
+				if (isset($ais_data['eta_ts'])) {
746
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
747
+				}
539 748
 				if (isset($ais_data['timestamp'])) {
540 749
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
541 750
 				} else {
@@ -543,18 +752,27 @@  discard block
 block discarded – undo
543 752
 				}
544 753
 				$data['format_source'] = 'aisnmeahttp';
545 754
 				$data['id_source'] = $id_source;
546
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
547
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
755
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
756
+					$data['noarchive'] = true;
757
+				}
758
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
759
+					$MI->add($data);
760
+				}
548 761
 				unset($data);
549 762
 			    }
550 763
 			}
551 764
 		    }
552 765
 		} else {
553 766
 		    $format = $value['format'];
554
-		    if (isset($tt[$format])) $tt[$format]++;
555
-		    else $tt[$format] = 0;
767
+		    if (isset($tt[$format])) {
768
+		    	$tt[$format]++;
769
+		    } else {
770
+		    	$tt[$format] = 0;
771
+		    }
556 772
 		    if ($tt[$format] > 30) {
557
-			if ($globalDebug) echo 'Reconnect...'."\n";
773
+			if ($globalDebug) {
774
+				echo 'Reconnect...'."\n";
775
+			}
558 776
 			sleep(2);
559 777
 			//$sourceeen[] = $value;
560 778
 			//connect_all($sourceeen);
@@ -593,7 +811,9 @@  discard block
 block discarded – undo
593 811
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
594 812
 			    $data['format_source'] = 'myshiptracking';
595 813
 			    $data['id_source'] = $id_source;
596
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
814
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
815
+			    	$data['noarchive'] = true;
816
+			    }
597 817
 			    $MI->add($data);
598 818
 			    unset($data);
599 819
 			}
@@ -618,7 +838,9 @@  discard block
 block discarded – undo
618 838
 			    $data['callsign'] = $line['callsign'];
619 839
 			    $data['mmsi'] = $line['mmsi'];
620 840
 			    $data['speed'] = $line['sog'];
621
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
841
+			    if ($line['heading'] != '511') {
842
+			    	$data['heading'] = $line['heading'];
843
+			    }
622 844
 			    $data['latitude'] = $line['latitude'];
623 845
 			    $data['longitude'] = $line['longitude'];
624 846
 			    $data['type_id'] = $line['shiptype'];
@@ -626,7 +848,9 @@  discard block
 block discarded – undo
626 848
 			    $data['datetime'] = $line['time'];
627 849
 			    $data['format_source'] = 'boatbeaconapp';
628 850
 			    $data['id_source'] = $id_source;
629
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
851
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
852
+			    	$data['noarchive'] = true;
853
+			    }
630 854
 			    $MI->add($data);
631 855
 			    unset($data);
632 856
 			}
@@ -647,22 +871,44 @@  discard block
 block discarded – undo
647 871
 		if (isset($all_data['features'][0]['id'])) {
648 872
 		    foreach ($all_data['features'] as $line) {
649 873
 			$data = array();
650
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
651
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
652
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi'];
653
-			if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo'];
654
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
655
-			if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading'];
874
+			if (isset($line['properties']['name'])) {
875
+				$data['ident'] = $line['properties']['name'];
876
+			}
877
+			if (isset($line['properties']['callsign'])) {
878
+				$data['callsign'] = $line['properties']['callsign'];
879
+			}
880
+			if (isset($line['properties']['mmsi'])) {
881
+				$data['mmsi'] = $line['properties']['mmsi'];
882
+			}
883
+			if (isset($line['properties']['imo'])) {
884
+				$data['mmsi'] = $line['properties']['imo'];
885
+			}
886
+			if (isset($line['properties']['speed'])) {
887
+				$data['speed'] = $line['properties']['speed'];
888
+			}
889
+			if (isset($line['properties']['heading'])) {
890
+				$data['heading'] = $line['properties']['heading'];
891
+			}
656 892
 			$data['latitude'] = $line['geometry']['coordinates'][1];
657 893
 			$data['longitude'] = $line['geometry']['coordinates'][0];
658
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
659
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
660
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
894
+			if (isset($line['properties']['vesselType'])) {
895
+				$data['type'] = $line['properties']['vesselType'];
896
+			}
897
+			if (isset($line['properties']['destination'])) {
898
+				$data['arrival_code'] = $line['properties']['destination'];
899
+			}
900
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
901
+				$data['arrival_date'] = $line['properties']['eta'];
902
+			}
661 903
 			$data['format_source'] = 'boatnerd';
662 904
 			$data['id_source'] = $id_source;
663 905
 			$data['datetime'] = date('Y-m-d H:i:s');
664
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
665
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
906
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
907
+				$data['noarchive'] = true;
908
+			}
909
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
910
+				$MI->add($data);
911
+			}
666 912
 			unset($data);
667 913
 		    }
668 914
 		}
@@ -678,7 +924,9 @@  discard block
 block discarded – undo
678 924
 	    echo 'download...';
679 925
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
680 926
 	    echo 'done !'."\n";
681
-	    if ($buffer != '') $reset = 0;
927
+	    if ($buffer != '') {
928
+	    	$reset = 0;
929
+	    }
682 930
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
683 931
 	    $buffer = explode('\n',$buffer);
684 932
 	    foreach ($buffer as $line) {
@@ -703,7 +951,9 @@  discard block
 block discarded – undo
703 951
 		    //$data['etaTime'] = substr($line,135,5);
704 952
 		    $data['format_source'] = 'shipplotter';
705 953
     		    $data['id_source'] = $id_source;
706
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
954
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
955
+		    	$data['noarchive'] = true;
956
+		    }
707 957
 		    //print_r($data);
708 958
 		    echo 'Add...'."\n";
709 959
 		    $MI->add($data);
@@ -737,16 +987,28 @@  discard block
 block discarded – undo
737 987
     		    $line = explode(':', $line);
738 988
     		    if (count($line) > 30 && $line[0] != 'callsign') {
739 989
 			$data = array();
740
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
741
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
990
+			if (isset($line[37]) && $line[37] != '') {
991
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
992
+			} else {
993
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
994
+			}
742 995
 			$data['pilot_id'] = $line[1];
743 996
 			$data['pilot_name'] = $line[2];
744 997
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
745 998
 			$data['ident'] = $line[0]; // ident
746
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
999
+			if ($line[7] != '' && $line[7] != 0) {
1000
+				$data['altitude'] = $line[7];
1001
+			}
1002
+			// altitude
747 1003
 			$data['speed'] = $line[8]; // speed
748
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
749
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1004
+			if (isset($line[45])) {
1005
+				$data['heading'] = $line[45];
1006
+			}
1007
+			// heading
1008
+			elseif (isset($line[38])) {
1009
+				$data['heading'] = $line[38];
1010
+			}
1011
+			// heading
750 1012
 			$data['latitude'] = $line[5]; // lat
751 1013
 	        	$data['longitude'] = $line[6]; // long
752 1014
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -762,7 +1024,9 @@  discard block
 block discarded – undo
762 1024
 			$data['frequency'] = $line[4];
763 1025
 			$data['type'] = $line[18];
764 1026
 			$data['range'] = $line[19];
765
-			if (isset($line[35])) $data['info'] = $line[35];
1027
+			if (isset($line[35])) {
1028
+				$data['info'] = $line[35];
1029
+			}
766 1030
     			$data['id_source'] = $id_source;
767 1031
 	    		//$data['arrival_airport_time'] = ;
768 1032
 	    		if ($line[9] != '') {
@@ -776,27 +1040,47 @@  discard block
 block discarded – undo
776 1040
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
777 1041
 	    		*/
778 1042
 	    		$data['format_source'] = $value['format'];
779
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
780
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
781
-    			if ($line[3] == 'PILOT') $SI->add($data);
782
-			elseif ($line[3] == 'ATC') {
1043
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1044
+				$data['noarchive'] = true;
1045
+			}
1046
+			if (isset($value['name']) && $value['name'] != '') {
1047
+				$data['source_name'] = $value['name'];
1048
+			}
1049
+    			if ($line[3] == 'PILOT') {
1050
+    				$SI->add($data);
1051
+    			} elseif ($line[3] == 'ATC') {
783 1052
 				//print_r($data);
784 1053
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
785 1054
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
786 1055
 				$typec = substr($data['ident'],-3);
787
-				if ($typec == 'APP') $data['type'] = 'Approach';
788
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
789
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
790
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
791
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
792
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
793
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
794
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
795
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
796
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1056
+				if ($typec == 'APP') {
1057
+					$data['type'] = 'Approach';
1058
+				} elseif ($typec == 'TWR') {
1059
+					$data['type'] = 'Tower';
1060
+				} elseif ($typec == 'OBS') {
1061
+					$data['type'] = 'Observer';
1062
+				} elseif ($typec == 'GND') {
1063
+					$data['type'] = 'Ground';
1064
+				} elseif ($typec == 'DEL') {
1065
+					$data['type'] = 'Delivery';
1066
+				} elseif ($typec == 'DEP') {
1067
+					$data['type'] = 'Departure';
1068
+				} elseif ($typec == 'FSS') {
1069
+					$data['type'] = 'Flight Service Station';
1070
+				} elseif ($typec == 'CTR') {
1071
+					$data['type'] = 'Control Radar or Centre';
1072
+				} elseif ($data['type'] == '') {
1073
+					$data['type'] = 'Observer';
1074
+				}
1075
+				if (!isset($data['source_name'])) {
1076
+					$data['source_name'] = '';
1077
+				}
797 1078
 				if (isset($ATC)) {
798
-					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']);
799
-					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']);
1079
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1080
+						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']);
1081
+					} else {
1082
+						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']);
1083
+					}
800 1084
 				}
801 1085
 			}
802 1086
     			unset($data);
@@ -823,14 +1107,20 @@  discard block
 block discarded – undo
823 1107
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
824 1108
 			$data['latitude'] = (float)$line['pktLatitude'];
825 1109
 			$data['longitude'] = (float)$line['pktLongitude'];
826
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
827
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1110
+			if ((float)$line['pktTrack'] != 0) {
1111
+				$data['heading'] = (float)$line['pktTrack'];
1112
+			}
1113
+			if ((int)$line['pktSpeed'] != 0) {
1114
+				$data['speed'] = (int)$line['pktSpeed'];
1115
+			}
828 1116
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
829 1117
 			$data['altitude_relative'] = 'AMSL';
830 1118
 			$data['pilot_id'] = (int)$line['pktPilotID'];
831 1119
 			$data['aircraft_icao'] = 'PARAGLIDER';
832 1120
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
833
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1121
+			if (isset($pilot_data[4])) {
1122
+				$data['pilot_name'] = $pilot_data[4];
1123
+			}
834 1124
 			$data['format_source'] = $value['format'];
835 1125
 			$SI->add($data);
836 1126
 			unset($data);
@@ -878,25 +1168,59 @@  discard block
 block discarded – undo
878 1168
 		    foreach ($all_data['acList'] as $line) {
879 1169
 			$data = array();
880 1170
 			$data['hex'] = $line['Icao']; // hex
881
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
882
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
883
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
884
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
885
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
886
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1171
+			if (isset($line['Call'])) {
1172
+				$data['ident'] = $line['Call'];
1173
+			}
1174
+			// ident
1175
+			if (isset($line['Alt'])) {
1176
+				$data['altitude'] = $line['Alt'];
1177
+			}
1178
+			// altitude
1179
+			if (isset($line['Spd'])) {
1180
+				$data['speed'] = $line['Spd'];
1181
+			}
1182
+			// speed
1183
+			if (isset($line['Trak'])) {
1184
+				$data['heading'] = $line['Trak'];
1185
+			}
1186
+			// heading
1187
+			if (isset($line['Lat'])) {
1188
+				$data['latitude'] = $line['Lat'];
1189
+			}
1190
+			// lat
1191
+			if (isset($line['Long'])) {
1192
+				$data['longitude'] = $line['Long'];
1193
+			}
1194
+			// long
887 1195
 			//$data['verticalrate'] = $line['']; // verticale rate
888
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1196
+			if (isset($line['Sqk'])) {
1197
+				$data['squawk'] = $line['Sqk'];
1198
+			}
1199
+			// squawk
889 1200
 			$data['emergency'] = ''; // emergency
890
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
891
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
892
-			else $data['datetime'] = date('Y-m-d H:i:s');
1201
+			if (isset($line['Reg'])) {
1202
+				$data['registration'] = $line['Reg'];
1203
+			}
1204
+			if (isset($line['PosTime'])) {
1205
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1206
+			} else {
1207
+				$data['datetime'] = date('Y-m-d H:i:s');
1208
+			}
893 1209
 			//$data['datetime'] = date('Y-m-d H:i:s');
894
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1210
+			if (isset($line['Type'])) {
1211
+				$data['aircraft_icao'] = $line['Type'];
1212
+			}
895 1213
 			$data['format_source'] = 'aircraftlistjson';
896 1214
 			$data['id_source'] = $id_source;
897
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
898
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
899
-			if (isset($data['latitude'])) $SI->add($data);
1215
+			if (isset($value['name']) && $value['name'] != '') {
1216
+				$data['source_name'] = $value['name'];
1217
+			}
1218
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1219
+				$data['noarchive'] = true;
1220
+			}
1221
+			if (isset($data['latitude'])) {
1222
+				$SI->add($data);
1223
+			}
900 1224
 			unset($data);
901 1225
 		    }
902 1226
 		} elseif (is_array($all_data)) {
@@ -913,17 +1237,26 @@  discard block
 block discarded – undo
913 1237
 			$data['verticalrate'] = $line['vrt']; // verticale rate
914 1238
 			$data['squawk'] = $line['squawk']; // squawk
915 1239
 			$data['emergency'] = ''; // emergency
916
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
917
-			else $data['datetime'] = date('Y-m-d H:i:s');
1240
+			if (isset($line['PosTime'])) {
1241
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1242
+			} else {
1243
+				$data['datetime'] = date('Y-m-d H:i:s');
1244
+			}
918 1245
 			$data['format_source'] = 'aircraftlistjson';
919 1246
 			$data['id_source'] = $id_source;
920
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
921
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1247
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1248
+				$data['noarchive'] = true;
1249
+			}
1250
+			if (isset($value['name']) && $value['name'] != '') {
1251
+				$data['source_name'] = $value['name'];
1252
+			}
922 1253
 			$SI->add($data);
923 1254
 			unset($data);
924 1255
 		    }
925 1256
 		}
926
-	    } elseif ($globalDebug) echo 'No data'."\n";
1257
+	    } elseif ($globalDebug) {
1258
+	    	echo 'No data'."\n";
1259
+	    }
927 1260
     	    //$last_exec['aircraftlistjson'] = time();
928 1261
     	    $last_exec[$id]['last'] = time();
929 1262
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -959,8 +1292,12 @@  discard block
 block discarded – undo
959 1292
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
960 1293
 	    	    $data['format_source'] = 'planeupdatefaa';
961 1294
     		    $data['id_source'] = $id_source;
962
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
963
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1295
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1296
+		    	$data['noarchive'] = true;
1297
+		    }
1298
+		    if (isset($value['name']) && $value['name'] != '') {
1299
+		    	$data['source_name'] = $value['name'];
1300
+		    }
964 1301
 		    $SI->add($data);
965 1302
 		    unset($data);
966 1303
 		}
@@ -994,7 +1331,9 @@  discard block
 block discarded – undo
994 1331
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
995 1332
 		    $data['format_source'] = 'opensky';
996 1333
 		    $data['id_source'] = $id_source;
997
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1334
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1335
+		    	$data['noarchive'] = true;
1336
+		    }
998 1337
 		    $SI->add($data);
999 1338
 		    unset($data);
1000 1339
 		}
@@ -1011,7 +1350,9 @@  discard block
 block discarded – undo
1011 1350
 	    //$buffer = $Common->getData($hosts[$id]);
1012 1351
 	    $buffer = $Common->getData($value['host']);
1013 1352
 	    $all_data = json_decode($buffer,true);
1014
-	    if (!empty($all_data)) $reset = 0;
1353
+	    if (!empty($all_data)) {
1354
+	    	$reset = 0;
1355
+	    }
1015 1356
 	    foreach ($all_data as $key => $line) {
1016 1357
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1017 1358
 		    $data = array();
@@ -1032,8 +1373,12 @@  discard block
 block discarded – undo
1032 1373
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1033 1374
 	    	    $data['format_source'] = 'fr24json';
1034 1375
     		    $data['id_source'] = $id_source;
1035
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1036
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1376
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1377
+		    	$data['noarchive'] = true;
1378
+		    }
1379
+		    if (isset($value['name']) && $value['name'] != '') {
1380
+		    	$data['source_name'] = $value['name'];
1381
+		    }
1037 1382
 		    $SI->add($data);
1038 1383
 		    unset($data);
1039 1384
 		}
@@ -1062,24 +1407,42 @@  discard block
 block discarded – undo
1062 1407
 		    if (isset($line['inf'])) {
1063 1408
 			$data = array();
1064 1409
 			$data['hex'] = $line['inf']['ia'];
1065
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1410
+			if (isset($line['inf']['cs'])) {
1411
+				$data['ident'] = $line['inf']['cs'];
1412
+			}
1413
+			//$line[13]
1066 1414
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1067
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1068
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1415
+	    		if (isset($line['inf']['gs'])) {
1416
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1417
+	    		}
1418
+	    		// speed
1419
+	    		if (isset($line['inf']['tr'])) {
1420
+	    			$data['heading'] = $line['inf']['tr'];
1421
+	    		}
1422
+	    		// heading
1069 1423
 	    		$data['latitude'] = $line['pt'][0]; // lat
1070 1424
 	    		$data['longitude'] = $line['pt'][1]; // long
1071 1425
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1072
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1426
+	    		if (isset($line['inf']['sq'])) {
1427
+	    			$data['squawk'] = $line['inf']['sq'];
1428
+	    		}
1429
+	    		// squawk
1073 1430
 	    		//$data['aircraft_icao'] = $line[8];
1074
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1431
+	    		if (isset($line['inf']['rc'])) {
1432
+	    			$data['registration'] = $line['inf']['rc'];
1433
+	    		}
1075 1434
 			//$data['departure_airport_iata'] = $line[11];
1076 1435
 			//$data['arrival_airport_iata'] = $line[12];
1077 1436
 	    		//$data['emergency'] = ''; // emergency
1078 1437
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1079 1438
 	    		$data['format_source'] = 'radarvirtueljson';
1080 1439
     			$data['id_source'] = $id_source;
1081
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1082
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1440
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1441
+				$data['noarchive'] = true;
1442
+			}
1443
+			if (isset($value['name']) && $value['name'] != '') {
1444
+				$data['source_name'] = $value['name'];
1445
+			}
1083 1446
 			$SI->add($data);
1084 1447
 			unset($data);
1085 1448
 		    }
@@ -1105,30 +1468,65 @@  discard block
 block discarded – undo
1105 1468
 		    $data['id'] = $line['id'];
1106 1469
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1107 1470
 		    $data['ident'] = $line['callsign']; // ident
1108
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1109
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1110
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1111
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1112
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1113
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1471
+		    if (isset($line['pilotid'])) {
1472
+		    	$data['pilot_id'] = $line['pilotid'];
1473
+		    }
1474
+		    // pilot id
1475
+		    if (isset($line['name'])) {
1476
+		    	$data['pilot_name'] = $line['name'];
1477
+		    }
1478
+		    // pilot name
1479
+		    if (isset($line['alt'])) {
1480
+		    	$data['altitude'] = $line['alt'];
1481
+		    }
1482
+		    // altitude
1483
+		    if (isset($line['gs'])) {
1484
+		    	$data['speed'] = $line['gs'];
1485
+		    }
1486
+		    // speed
1487
+		    if (isset($line['heading'])) {
1488
+		    	$data['heading'] = $line['heading'];
1489
+		    }
1490
+		    // heading
1491
+		    if (isset($line['route'])) {
1492
+		    	$data['waypoints'] = $line['route'];
1493
+		    }
1494
+		    // route
1114 1495
 		    $data['latitude'] = $line['lat']; // lat
1115 1496
 		    $data['longitude'] = $line['lon']; // long
1116 1497
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1117 1498
 		    //$data['squawk'] = $line['squawk']; // squawk
1118 1499
 		    //$data['emergency'] = ''; // emergency
1119
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1120
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1121
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1500
+		    if (isset($line['depicao'])) {
1501
+		    	$data['departure_airport_icao'] = $line['depicao'];
1502
+		    }
1503
+		    if (isset($line['deptime'])) {
1504
+		    	$data['departure_airport_time'] = $line['deptime'];
1505
+		    }
1506
+		    if (isset($line['arricao'])) {
1507
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1508
+		    }
1122 1509
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1123
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1124
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1125
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1126
-		    else $data['info'] = '';
1510
+		    if (isset($line['aircraft'])) {
1511
+		    	$data['aircraft_icao'] = $line['aircraft'];
1512
+		    }
1513
+		    if (isset($line['transponder'])) {
1514
+		    	$data['squawk'] = $line['transponder'];
1515
+		    }
1516
+		    if (isset($line['atis'])) {
1517
+		    	$data['info'] = $line['atis'];
1518
+		    } else {
1519
+		    	$data['info'] = '';
1520
+		    }
1127 1521
 		    $data['format_source'] = 'pireps';
1128 1522
     		    $data['id_source'] = $id_source;
1129 1523
 		    $data['datetime'] = date('Y-m-d H:i:s');
1130
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1131
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1524
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1525
+		    	$data['noarchive'] = true;
1526
+		    }
1527
+		    if (isset($value['name']) && $value['name'] != '') {
1528
+		    	$data['source_name'] = $value['name'];
1529
+		    }
1132 1530
 		    if ($line['icon'] == 'plane') {
1133 1531
 			$SI->add($data);
1134 1532
 		    //    print_r($data);
@@ -1137,16 +1535,28 @@  discard block
 block discarded – undo
1137 1535
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1138 1536
 			$typec = substr($data['ident'],-3);
1139 1537
 			$data['type'] = '';
1140
-			if ($typec == 'APP') $data['type'] = 'Approach';
1141
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
1142
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
1143
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
1144
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
1145
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
1146
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1147
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1148
-			else $data['type'] = 'Observer';
1149
-			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']);
1538
+			if ($typec == 'APP') {
1539
+				$data['type'] = 'Approach';
1540
+			} elseif ($typec == 'TWR') {
1541
+				$data['type'] = 'Tower';
1542
+			} elseif ($typec == 'OBS') {
1543
+				$data['type'] = 'Observer';
1544
+			} elseif ($typec == 'GND') {
1545
+				$data['type'] = 'Ground';
1546
+			} elseif ($typec == 'DEL') {
1547
+				$data['type'] = 'Delivery';
1548
+			} elseif ($typec == 'DEP') {
1549
+				$data['type'] = 'Departure';
1550
+			} elseif ($typec == 'FSS') {
1551
+				$data['type'] = 'Flight Service Station';
1552
+			} elseif ($typec == 'CTR') {
1553
+				$data['type'] = 'Control Radar or Centre';
1554
+			} else {
1555
+				$data['type'] = 'Observer';
1556
+			}
1557
+			if (isset($ATC)) {
1558
+				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']);
1559
+			}
1150 1560
 		    }
1151 1561
 		    unset($data);
1152 1562
 		}
@@ -1161,7 +1571,9 @@  discard block
 block discarded – undo
1161 1571
 	    )
1162 1572
 	) {
1163 1573
 	    //$buffer = $Common->getData($hosts[$id]);
1164
-	    if ($globalDebug) echo 'Get Data...'."\n";
1574
+	    if ($globalDebug) {
1575
+	    	echo 'Get Data...'."\n";
1576
+	    }
1165 1577
 	    $buffer = $Common->getData($value['host']);
1166 1578
 	    $all_data = json_decode($buffer,true);
1167 1579
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1169,10 +1581,16 @@  discard block
 block discarded – undo
1169 1581
 		foreach ($all_data as $line) {
1170 1582
 	    	    $data = array();
1171 1583
 	    	    //$data['id'] = $line['id']; // id not usable
1172
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1584
+	    	    if (isset($line['pilotid'])) {
1585
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1586
+	    	    }
1173 1587
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1174
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1175
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1588
+	    	    if (isset($line['pilotname'])) {
1589
+	    	    	$data['pilot_name'] = $line['pilotname'];
1590
+	    	    }
1591
+	    	    if (isset($line['pilotid'])) {
1592
+	    	    	$data['pilot_id'] = $line['pilotid'];
1593
+	    	    }
1176 1594
 	    	    $data['ident'] = $line['flightnum']; // ident
1177 1595
 	    	    $data['altitude'] = $line['alt']; // altitude
1178 1596
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1188,7 +1606,9 @@  discard block
 block discarded – undo
1188 1606
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1189 1607
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1190 1608
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1191
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1609
+	    	    } else {
1610
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1611
+	    	    }
1192 1612
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1193 1613
 	    	    $data['departure_airport_time'] = $line['deptime'];
1194 1614
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1196,29 +1616,47 @@  discard block
 block discarded – undo
1196 1616
     		    if (isset($line['registration'])) {
1197 1617
     			$data['registration'] = $line['registration'];
1198 1618
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1199
-    		    } else $data['registration'] = $line['aircraft'];
1200
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1201
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1619
+    		    } else {
1620
+    		    	$data['registration'] = $line['aircraft'];
1621
+    		    }
1622
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1623
+		    	$data['noarchive'] = true;
1624
+		    }
1625
+		    if (isset($line['route'])) {
1626
+		    	$data['waypoints'] = $line['route'];
1627
+		    }
1628
+		    // route
1202 1629
 		    if (isset($line['aircraftname'])) {
1203 1630
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1204 1631
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1205 1632
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1206
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1207
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1208
-	    		else {
1633
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1634
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1635
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1636
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1637
+	    		} else {
1209 1638
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1210
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1211
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1639
+	    		    if (isset($aircraft_data[1])) {
1640
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1641
+	    		    } else {
1642
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1643
+	    		    }
1212 1644
 	    		}
1213 1645
 	    	    }
1214
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1646
+    		    if (isset($line['route'])) {
1647
+    		    	$data['waypoints'] = $line['route'];
1648
+    		    }
1215 1649
     		    $data['id_source'] = $id_source;
1216 1650
 	    	    $data['format_source'] = 'phpvmacars';
1217
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1651
+		    if (isset($value['name']) && $value['name'] != '') {
1652
+		    	$data['source_name'] = $value['name'];
1653
+		    }
1218 1654
 		    $SI->add($data);
1219 1655
 		    unset($data);
1220 1656
 		}
1221
-		if ($globalDebug) echo 'No more data...'."\n";
1657
+		if ($globalDebug) {
1658
+			echo 'No more data...'."\n";
1659
+		}
1222 1660
 		unset($buffer);
1223 1661
 		unset($all_data);
1224 1662
 	    }
@@ -1231,7 +1669,9 @@  discard block
 block discarded – undo
1231 1669
 	    )
1232 1670
 	) {
1233 1671
 	    //$buffer = $Common->getData($hosts[$id]);
1234
-	    if ($globalDebug) echo 'Get Data...'."\n";
1672
+	    if ($globalDebug) {
1673
+	    	echo 'Get Data...'."\n";
1674
+	    }
1235 1675
 	    $buffer = $Common->getData($value['host']);
1236 1676
 	    $all_data = json_decode($buffer,true);
1237 1677
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1242,10 +1682,16 @@  discard block
 block discarded – undo
1242 1682
 	    	    //$data['id'] = $line['id']; // id not usable
1243 1683
 	    	    $data['id'] = $line['id'];
1244 1684
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1245
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1246
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1685
+	    	    if (isset($line['user']['username'])) {
1686
+	    	    	$data['pilot_name'] = $line['user']['username'];
1687
+	    	    }
1688
+	    	    if (isset($line['user_id'])) {
1689
+	    	    	$data['pilot_id'] = $line['user_id'];
1690
+	    	    }
1247 1691
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1248
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1692
+	    	    if (is_numeric($data['ident'])) {
1693
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1694
+	    	    }
1249 1695
 	    	    $data['altitude'] = $line['altitude']; // altitude
1250 1696
 	    	    $data['speed'] = $line['groundspeed']; // speed
1251 1697
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1258,7 +1704,9 @@  discard block
 block discarded – undo
1258 1704
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1259 1705
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1260 1706
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1261
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1707
+	    	    } else {
1708
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1709
+	    	    }
1262 1710
 	    	    
1263 1711
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1264 1712
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1266,17 +1714,26 @@  discard block
 block discarded – undo
1266 1714
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1267 1715
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1268 1716
 
1269
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1270
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1717
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1718
+		    	$data['noarchive'] = true;
1719
+		    }
1720
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
1721
+		    	$data['waypoints'] = $line['bid']['route'];
1722
+		    }
1723
+		    // route
1271 1724
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1272 1725
 
1273 1726
     		    $data['id_source'] = $id_source;
1274 1727
 	    	    $data['format_source'] = 'vaos';
1275
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1728
+		    if (isset($value['name']) && $value['name'] != '') {
1729
+		    	$data['source_name'] = $value['name'];
1730
+		    }
1276 1731
 		    $SI->add($data);
1277 1732
 		    unset($data);
1278 1733
 		}
1279
-		if ($globalDebug) echo 'No more data...'."\n";
1734
+		if ($globalDebug) {
1735
+			echo 'No more data...'."\n";
1736
+		}
1280 1737
 		unset($buffer);
1281 1738
 		unset($all_data);
1282 1739
 	    }
@@ -1289,7 +1746,9 @@  discard block
 block discarded – undo
1289 1746
 	    )
1290 1747
 	) {
1291 1748
 	    //$buffer = $Common->getData($hosts[$id]);
1292
-	    if ($globalDebug) echo 'Get Data...'."\n";
1749
+	    if ($globalDebug) {
1750
+	    	echo 'Get Data...'."\n";
1751
+	    }
1293 1752
 	    $buffer = $Common->getData($value['host']);
1294 1753
 	    $all_data = json_decode($buffer,true);
1295 1754
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1318,16 +1777,25 @@  discard block
 block discarded – undo
1318 1777
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1319 1778
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1320 1779
     		    //$data['registration'] = $line['aircraft'];
1321
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1780
+		    if (isset($line['route'])) {
1781
+		    	$data['waypoints'] = $line['route'];
1782
+		    }
1783
+		    // route
1322 1784
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1323 1785
     		    $data['id_source'] = $id_source;
1324 1786
 	    	    $data['format_source'] = 'vam';
1325
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1326
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1787
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1788
+		    	$data['noarchive'] = true;
1789
+		    }
1790
+		    if (isset($value['name']) && $value['name'] != '') {
1791
+		    	$data['source_name'] = $value['name'];
1792
+		    }
1327 1793
 		    $SI->add($data);
1328 1794
 		    unset($data);
1329 1795
 		}
1330
-		if ($globalDebug) echo 'No more data...'."\n";
1796
+		if ($globalDebug) {
1797
+			echo 'No more data...'."\n";
1798
+		}
1331 1799
 		unset($buffer);
1332 1800
 		unset($all_data);
1333 1801
 	    }
@@ -1340,7 +1808,9 @@  discard block
 block discarded – undo
1340 1808
 	    )
1341 1809
 	) {
1342 1810
 	    //$buffer = $Common->getData($hosts[$id]);
1343
-	    if ($globalDebug) echo 'Get Data...'."\n";
1811
+	    if ($globalDebug) {
1812
+	    	echo 'Get Data...'."\n";
1813
+	    }
1344 1814
 	    $buffer = $Common->getData($value['host']);
1345 1815
 	    $all_data = json_decode($buffer,true);
1346 1816
 	    if ($buffer != '') {
@@ -1358,18 +1828,24 @@  discard block
 block discarded – undo
1358 1828
 			$data['id_source'] = $id_source;
1359 1829
 			$data['format_source'] = 'blitzortung';
1360 1830
 			$SI->add($data);
1361
-			if ($globalDebug) echo '☈ Lightning added'."\n";
1831
+			if ($globalDebug) {
1832
+				echo '☈ Lightning added'."\n";
1833
+			}
1362 1834
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1363 1835
 			unset($data);
1364 1836
 		    }
1365 1837
 		}
1366
-		if ($globalDebug) echo 'No more data...'."\n";
1838
+		if ($globalDebug) {
1839
+			echo 'No more data...'."\n";
1840
+		}
1367 1841
 		unset($buffer);
1368 1842
 	    }
1369 1843
 	    $last_exec[$id]['last'] = time();
1370 1844
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1371 1845
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1372
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1846
+	    if (function_exists('pcntl_fork')) {
1847
+	    	pcntl_signal_dispatch();
1848
+	    }
1373 1849
     	    //$last_exec[$id]['last'] = time();
1374 1850
 
1375 1851
 	    //$read = array( $sockets[$id] );
@@ -1377,7 +1853,9 @@  discard block
 block discarded – undo
1377 1853
 	    $write = NULL;
1378 1854
 	    $e = NULL;
1379 1855
 	    $n = socket_select($read, $write, $e, $timeout);
1380
-	    if ($e != NULL) var_dump($e);
1856
+	    if ($e != NULL) {
1857
+	    	var_dump($e);
1858
+	    }
1381 1859
 	    if ($n > 0) {
1382 1860
 		$reset = 0;
1383 1861
 		foreach ($read as $nb => $r) {
@@ -1399,13 +1877,17 @@  discard block
 block discarded – undo
1399 1877
 		    if ($buffer !== FALSE) {
1400 1878
 			if ($format == 'vrstcp') {
1401 1879
 			    $buffer = explode('},{',$buffer);
1402
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1880
+			} else {
1881
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1882
+			}
1403 1883
 		    }
1404 1884
 		    // SBS format is CSV format
1405 1885
 		    if ($buffer !== FALSE && $buffer !== '') {
1406 1886
 			$tt[$format] = 0;
1407 1887
 			if ($format == 'acarssbs3') {
1408
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1888
+			    if ($globalDebug) {
1889
+			    	echo 'ACARS : '.$buffer."\n";
1890
+			    }
1409 1891
 			    $ACARS->add(trim($buffer));
1410 1892
 			    $ACARS->deleteLiveAcarsData();
1411 1893
 			} elseif ($format == 'raw') {
@@ -1414,30 +1896,70 @@  discard block
 block discarded – undo
1414 1896
 			    if (is_array($data)) {
1415 1897
 				$data['datetime'] = date('Y-m-d H:i:s');
1416 1898
 				$data['format_source'] = 'raw';
1417
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1418
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1419
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1420
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1899
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1900
+					$data['source_name'] = $globalSources[$nb]['name'];
1901
+				}
1902
+				if (isset($globalSources[$nb]['sourcestats'])) {
1903
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1904
+				}
1905
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1906
+					$data['noarchive'] = true;
1907
+				}
1908
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1909
+					$SI->add($data);
1910
+				}
1421 1911
 			    }
1422 1912
 			} elseif ($format == 'ais') {
1423 1913
 			    $ais_data = $AIS->parse_line(trim($buffer));
1424 1914
 			    $data = array();
1425
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1426
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1427
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1428
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1429
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1430
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1431
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1432
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1433
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1434
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1435
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1436
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1437
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1438
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1439
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1440
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1915
+			    if (isset($ais_data['ident'])) {
1916
+			    	$data['ident'] = $ais_data['ident'];
1917
+			    }
1918
+			    if (isset($ais_data['mmsi'])) {
1919
+			    	$data['mmsi'] = $ais_data['mmsi'];
1920
+			    }
1921
+			    if (isset($ais_data['speed'])) {
1922
+			    	$data['speed'] = $ais_data['speed'];
1923
+			    }
1924
+			    if (isset($ais_data['heading'])) {
1925
+			    	$data['heading'] = $ais_data['heading'];
1926
+			    }
1927
+			    if (isset($ais_data['latitude'])) {
1928
+			    	$data['latitude'] = $ais_data['latitude'];
1929
+			    }
1930
+			    if (isset($ais_data['longitude'])) {
1931
+			    	$data['longitude'] = $ais_data['longitude'];
1932
+			    }
1933
+			    if (isset($ais_data['status'])) {
1934
+			    	$data['status'] = $ais_data['status'];
1935
+			    }
1936
+			    if (isset($ais_data['statusid'])) {
1937
+			    	$data['status_id'] = $ais_data['statusid'];
1938
+			    }
1939
+			    if (isset($ais_data['type'])) {
1940
+			    	$data['type'] = $ais_data['type'];
1941
+			    }
1942
+			    if (isset($ais_data['imo'])) {
1943
+			    	$data['imo'] = $ais_data['imo'];
1944
+			    }
1945
+			    if (isset($ais_data['callsign'])) {
1946
+			    	$data['callsign'] = $ais_data['callsign'];
1947
+			    }
1948
+			    if (isset($ais_data['destination'])) {
1949
+			    	$data['arrival_code'] = $ais_data['destination'];
1950
+			    }
1951
+			    if (isset($ais_data['eta_ts'])) {
1952
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1953
+			    }
1954
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1955
+			    	$data['noarchive'] = true;
1956
+			    }
1957
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1958
+			    	$data['source_name'] = $globalSources[$nb]['name'];
1959
+			    }
1960
+			    if (isset($globalSources[$nb]['sourcestats'])) {
1961
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1962
+			    }
1441 1963
 
1442 1964
 			    if (isset($ais_data['timestamp'])) {
1443 1965
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1446,7 +1968,9 @@  discard block
 block discarded – undo
1446 1968
 			    }
1447 1969
 			    $data['format_source'] = 'aisnmea';
1448 1970
     			    $data['id_source'] = $id_source;
1449
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1971
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1972
+			    	$MI->add($data);
1973
+			    }
1450 1974
 			    unset($data);
1451 1975
                         } elseif ($format == 'flightgearsp') {
1452 1976
                     	    //echo $buffer."\n";
@@ -1464,12 +1988,18 @@  discard block
 block discarded – undo
1464 1988
 				$data['speed'] = round($line[5]*1.94384);
1465 1989
 				$data['datetime'] = date('Y-m-d H:i:s');
1466 1990
 				$data['format_source'] = 'flightgearsp';
1467
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1468
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1991
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1992
+					$data['noarchive'] = true;
1993
+				}
1994
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1995
+					$SI->add($data);
1996
+				}
1469 1997
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1470 1998
 			    }
1471 1999
                         } elseif ($format == 'acars') {
1472
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2000
+                    	    if ($globalDebug) {
2001
+                    	    	echo 'ACARS : '.$buffer."\n";
2002
+                    	    }
1473 2003
 			    $ACARS->add(trim($buffer));
1474 2004
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1475 2005
 			    $ACARS->deleteLiveAcarsData();
@@ -1490,8 +2020,12 @@  discard block
 block discarded – undo
1490 2020
 				    $aircraft_type = $line[10];
1491 2021
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1492 2022
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1493
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1494
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2023
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2024
+				    	$data['noarchive'] = true;
2025
+				    }
2026
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2027
+				    	$SI->add($data);
2028
+				    }
1495 2029
 				}
1496 2030
 			    }
1497 2031
 			} elseif ($format == 'beast') {
@@ -1501,28 +2035,62 @@  discard block
 block discarded – undo
1501 2035
 			    foreach($buffer as $all_data) {
1502 2036
 				$line = json_decode('{'.$all_data.'}',true);
1503 2037
 				$data = array();
1504
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1505
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1506
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1507
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1508
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1509
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1510
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2038
+				if (isset($line['Icao'])) {
2039
+					$data['hex'] = $line['Icao'];
2040
+				}
2041
+				// hex
2042
+				if (isset($line['Call'])) {
2043
+					$data['ident'] = $line['Call'];
2044
+				}
2045
+				// ident
2046
+				if (isset($line['Alt'])) {
2047
+					$data['altitude'] = $line['Alt'];
2048
+				}
2049
+				// altitude
2050
+				if (isset($line['Spd'])) {
2051
+					$data['speed'] = $line['Spd'];
2052
+				}
2053
+				// speed
2054
+				if (isset($line['Trak'])) {
2055
+					$data['heading'] = $line['Trak'];
2056
+				}
2057
+				// heading
2058
+				if (isset($line['Lat'])) {
2059
+					$data['latitude'] = $line['Lat'];
2060
+				}
2061
+				// lat
2062
+				if (isset($line['Long'])) {
2063
+					$data['longitude'] = $line['Long'];
2064
+				}
2065
+				// long
1511 2066
 				//$data['verticalrate'] = $line['']; // verticale rate
1512
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2067
+				if (isset($line['Sqk'])) {
2068
+					$data['squawk'] = $line['Sqk'];
2069
+				}
2070
+				// squawk
1513 2071
 				$data['emergency'] = ''; // emergency
1514
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2072
+				if (isset($line['Reg'])) {
2073
+					$data['registration'] = $line['Reg'];
2074
+				}
1515 2075
 				/*
1516 2076
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1517 2077
 				else $data['datetime'] = date('Y-m-d H:i:s');
1518 2078
 				*/
1519 2079
 				$data['datetime'] = date('Y-m-d H:i:s');
1520
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2080
+				if (isset($line['Type'])) {
2081
+					$data['aircraft_icao'] = $line['Type'];
2082
+				}
1521 2083
 		    		$data['format_source'] = 'vrstcp';
1522 2084
 				$data['id_source'] = $id_source;
1523
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1524
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1525
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2085
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2086
+					$data['noarchive'] = true;
2087
+				}
2088
+				if (isset($value['name']) && $value['name'] != '') {
2089
+					$data['source_name'] = $value['name'];
2090
+				}
2091
+				if (isset($data['latitude']) && isset($data['hex'])) {
2092
+					$SI->add($data);
2093
+				}
1526 2094
 				unset($data);
1527 2095
 			    }
1528 2096
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1535,22 +2103,46 @@  discard block
 block discarded – undo
1535 2103
     				$data['hex'] = $lined['hexid'];
1536 2104
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1537 2105
     				$data['datetime'] = date('Y-m-d H:i:s');;
1538
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1539
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1540
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1541
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1542
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1543
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1544
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2106
+    				if (isset($lined['ident'])) {
2107
+    					$data['ident'] = $lined['ident'];
2108
+    				}
2109
+    				if (isset($lined['lat'])) {
2110
+    					$data['latitude'] = $lined['lat'];
2111
+    				}
2112
+    				if (isset($lined['lon'])) {
2113
+    					$data['longitude'] = $lined['lon'];
2114
+    				}
2115
+    				if (isset($lined['speed'])) {
2116
+    					$data['speed'] = $lined['speed'];
2117
+    				}
2118
+    				if (isset($lined['squawk'])) {
2119
+    					$data['squawk'] = $lined['squawk'];
2120
+    				}
2121
+    				if (isset($lined['alt'])) {
2122
+    					$data['altitude'] = $lined['alt'];
2123
+    				}
2124
+    				if (isset($lined['heading'])) {
2125
+    					$data['heading'] = $lined['heading'];
2126
+    				}
1545 2127
     				$data['id_source'] = $id_source;
1546 2128
     				$data['format_source'] = 'tsv';
1547
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1548
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1549
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1550
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2129
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2130
+    					$data['source_name'] = $globalSources[$nb]['name'];
2131
+    				}
2132
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2133
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2134
+    				}
2135
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2136
+					$data['noarchive'] = true;
2137
+				}
2138
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2139
+    					$SI->add($data);
2140
+    				}
1551 2141
     				unset($lined);
1552 2142
     				unset($data);
1553
-    			    } else $error = true;
2143
+    			    } else {
2144
+    			    	$error = true;
2145
+    			    }
1554 2146
 			} elseif ($format == 'aprs' && $use_aprs) {
1555 2147
 			    if ($aprs_connect == 0) {
1556 2148
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1576,63 +2168,121 @@  discard block
 block discarded – undo
1576 2168
 				    $aprs_last_tx = time();
1577 2169
 				    $data = array();
1578 2170
 				    //print_r($line);
1579
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1580
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1581
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1582
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1583
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1584
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1585
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1586
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1587
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1588
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2171
+				    if (isset($line['address'])) {
2172
+				    	$data['hex'] = $line['address'];
2173
+				    }
2174
+				    if (isset($line['mmsi'])) {
2175
+				    	$data['mmsi'] = $line['mmsi'];
2176
+				    }
2177
+				    if (isset($line['imo'])) {
2178
+				    	$data['imo'] = $line['imo'];
2179
+				    }
2180
+				    if (isset($line['squawk'])) {
2181
+				    	$data['squawk'] = $line['squawk'];
2182
+				    }
2183
+				    if (isset($line['arrival_code'])) {
2184
+				    	$data['arrival_code'] = $line['arrival_code'];
2185
+				    }
2186
+				    if (isset($line['arrival_date'])) {
2187
+				    	$data['arrival_date'] = $line['arrival_date'];
2188
+				    }
2189
+				    if (isset($line['type_id'])) {
2190
+				    	$data['type_id'] = $line['typeid'];
2191
+				    }
2192
+				    if (isset($line['status_id'])) {
2193
+				    	$data['status_id'] = $line['statusid'];
2194
+				    }
2195
+				    if (isset($line['timestamp'])) {
2196
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2197
+				    } else {
2198
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2199
+				    }
1589 2200
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1590
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2201
+				    if (isset($line['ident'])) {
2202
+				    	$data['ident'] = $line['ident'];
2203
+				    }
1591 2204
 				    $data['latitude'] = $line['latitude'];
1592 2205
 				    $data['longitude'] = $line['longitude'];
1593 2206
 				    //$data['verticalrate'] = $line[16];
1594
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2207
+				    if (isset($line['speed'])) {
2208
+				    	$data['speed'] = $line['speed'];
2209
+				    }
1595 2210
 				    //else $data['speed'] = 0;
1596
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1597
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1598
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2211
+				    if (isset($line['altitude'])) {
2212
+				    	$data['altitude'] = $line['altitude'];
2213
+				    }
2214
+				    if (isset($line['comment'])) {
2215
+				    	$data['comment'] = $line['comment'];
2216
+				    }
2217
+				    if (isset($line['symbol'])) {
2218
+				    	$data['type'] = $line['symbol'];
2219
+				    }
1599 2220
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1600 2221
 				    
1601
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2222
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2223
+				    	$data['heading'] = $line['heading'];
2224
+				    }
1602 2225
 				    //else echo 'No heading...'."\n";
1603 2226
 				    //else $data['heading'] = 0;
1604
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2227
+				    if (isset($line['stealth'])) {
2228
+				    	$data['aircraft_type'] = $line['stealth'];
2229
+				    }
1605 2230
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1606
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1607
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1608
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1609
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2231
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2232
+				    	$data['noarchive'] = true;
2233
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2234
+				    	$data['noarchive'] = false;
2235
+				    }
2236
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2237
+				    	$data['noarchive'] = true;
2238
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2239
+				    	$data['noarchive'] = false;
2240
+				    }
1610 2241
     				    $data['id_source'] = $id_source;
1611
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1612
-				    else $data['format_source'] = 'aprs';
2242
+    				    if (isset($line['format_source'])) {
2243
+    				    	$data['format_source'] = $line['format_source'];
2244
+    				    } else {
2245
+				    	$data['format_source'] = 'aprs';
2246
+				    }
1613 2247
 				    $data['source_name'] = $line['source'];
1614
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1615
-				    else $data['source_type'] = 'flarm';
1616
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2248
+				    if (isset($line['source_type'])) {
2249
+				    	$data['source_type'] = $line['source_type'];
2250
+				    } else {
2251
+				    	$data['source_type'] = 'flarm';
2252
+				    }
2253
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2254
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2255
+    				    }
1617 2256
 				    $currentdate = date('Y-m-d H:i:s');
1618 2257
 				    $aprsdate = strtotime($data['datetime']);
1619
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2258
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2259
+				    	$data['altitude_relative'] = 'AMSL';
2260
+				    }
1620 2261
 				    // Accept data if time <= system time + 20s
1621 2262
 				    //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'])))) {
1622 2263
 				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1623 2264
 					$send = $SI->add($data);
1624 2265
 				    } elseif ($data['source_type'] == 'ais') {
1625 2266
 					$data['type'] = '';
1626
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2267
+					if (isset($globalMarine) && $globalMarine) {
2268
+						$send = $MI->add($data);
2269
+					}
1627 2270
 				    } elseif (isset($line['stealth'])) {
1628
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1629
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2271
+					if ($line['stealth'] != 0) {
2272
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
2273
+					} else {
2274
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2275
+					}
1630 2276
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1631 2277
 					    //$line['symbol'] == 'Balloon' ||
1632 2278
 					    $line['symbol'] == 'Glider' || 
1633 2279
 					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1634
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1635
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2280
+					    if ($line['symbol'] == 'Ballon') {
2281
+					    	$data['aircraft_icao'] = 'BALL';
2282
+					    }
2283
+					    if ($line['symbol'] == 'Glider') {
2284
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2285
+					    }
1636 2286
 					    $send = $SI->add($data);
1637 2287
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1638 2288
 					    $line['symbol'] == 'Yacht (Sail)' || 
@@ -1663,9 +2313,13 @@  discard block
 block discarded – undo
1663 2313
 				    //} 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') {
1664 2314
 				//    } 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') {
1665 2315
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1666
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2316
+					if (isset($globalTracker) && $globalTracker) {
2317
+						$send = $TI->add($data);
2318
+					}
1667 2319
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1668
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2320
+					if (!isset($data['altitude'])) {
2321
+						$data['altitude'] = 0;
2322
+					}
1669 2323
 					$Source->deleteOldLocationByType('gs');
1670 2324
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1671 2325
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1674,7 +2328,9 @@  discard block
 block discarded – undo
1674 2328
 					}
1675 2329
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1676 2330
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1677
-					if ($globalDebug) echo '# Weather Station added'."\n";
2331
+					if ($globalDebug) {
2332
+						echo '# Weather Station added'."\n";
2333
+					}
1678 2334
 					$Source->deleteOldLocationByType('wx');
1679 2335
 					$weather_data = json_encode($line);
1680 2336
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1684,7 +2340,9 @@  discard block
 block discarded – undo
1684 2340
 					}
1685 2341
 				    } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1686 2342
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1687
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2343
+					if ($globalDebug) {
2344
+						echo '☈ Lightning added'."\n";
2345
+					}
1688 2346
 					$Source->deleteOldLocationByType('lightning');
1689 2347
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1690 2348
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1696,8 +2354,7 @@  discard block
 block discarded – undo
1696 2354
 				    	print_r($line);
1697 2355
 				    }
1698 2356
 				    unset($data);
1699
-				}
1700
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2357
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1701 2358
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1702 2359
 				}
1703 2360
 				/*
@@ -1706,7 +2363,9 @@  discard block
 block discarded – undo
1706 2363
 				}
1707 2364
 				*/
1708 2365
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1709
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2366
+				elseif ($line == true && $globalDebug) {
2367
+					echo '!! Failed : '.$buffer."!!\n";
2368
+				}
1710 2369
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1711 2370
 					$Source->deleteOldLocationByType('lightning');
1712 2371
 					$Source->deleteOldLocationByType('wx');
@@ -1742,26 +2401,45 @@  discard block
 block discarded – undo
1742 2401
     				$data['ground'] = $line[21];
1743 2402
     				$data['emergency'] = $line[19];
1744 2403
     				$data['format_source'] = 'sbs';
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
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2404
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2405
+					$data['source_name'] = $globalSources[$nb]['name'];
2406
+				}
2407
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2408
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2409
+    				}
2410
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2411
+					$data['noarchive'] = true;
2412
+				}
1748 2413
     				$data['id_source'] = $id_source;
1749
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1750
-    				else $error = true;
2414
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2415
+    					$send = $SI->add($data);
2416
+    				} else {
2417
+    					$error = true;
2418
+    				}
1751 2419
     				unset($data);
1752
-    			    } else $error = true;
2420
+    			    } else {
2421
+    			    	$error = true;
2422
+    			    }
1753 2423
 			    if ($error) {
1754 2424
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1755
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2425
+					if ($globalDebug) {
2426
+						echo "Not a message. Ignoring... \n";
2427
+					}
1756 2428
 				} else {
1757
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2429
+					if ($globalDebug) {
2430
+						echo "Wrong line format. Ignoring... \n";
2431
+					}
1758 2432
 					if ($globalDebug) {
1759 2433
 						echo $buffer;
1760 2434
 						//print_r($line);
1761 2435
 					}
1762 2436
 					//socket_close($r);
1763
-					if ($globalDebug) echo "Reconnect after an error...\n";
1764
-					if ($format == 'aprs') $aprs_connect = 0;
2437
+					if ($globalDebug) {
2438
+						echo "Reconnect after an error...\n";
2439
+					}
2440
+					if ($format == 'aprs') {
2441
+						$aprs_connect = 0;
2442
+					}
1765 2443
 					$sourceer[$nb] = $globalSources[$nb];
1766 2444
 					connect_all($sourceer);
1767 2445
 					$sourceer = array();
@@ -1769,10 +2447,14 @@  discard block
 block discarded – undo
1769 2447
 			    }
1770 2448
 			}
1771 2449
 			// Sleep for xxx microseconds
1772
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2450
+			if (isset($globalSBSSleep)) {
2451
+				usleep($globalSBSSleep);
2452
+			}
1773 2453
 		    } else {
1774 2454
 			if ($format == 'flightgearmp') {
1775
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2455
+			    	if ($globalDebug) {
2456
+			    		echo "Reconnect FlightGear MP...";
2457
+			    	}
1776 2458
 				//@socket_close($r);
1777 2459
 				sleep($globalMinFetch);
1778 2460
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1781,10 +2463,15 @@  discard block
 block discarded – undo
1781 2463
 				break;
1782 2464
 				
1783 2465
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1784
-			    if (isset($tt[$format])) $tt[$format]++;
1785
-			    else $tt[$format] = 0;
2466
+			    if (isset($tt[$format])) {
2467
+			    	$tt[$format]++;
2468
+			    } else {
2469
+			    	$tt[$format] = 0;
2470
+			    }
1786 2471
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
1787
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2472
+				if ($globalDebug) {
2473
+					echo "ERROR : Reconnect ".$format."...";
2474
+				}
1788 2475
 				//@socket_close($r);
1789 2476
 				sleep(2);
1790 2477
 				$aprs_connect = 0;
@@ -1802,11 +2489,17 @@  discard block
 block discarded – undo
1802 2489
 	    } else {
1803 2490
 		$error = socket_strerror(socket_last_error());
1804 2491
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1805
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1806
-			if (isset($globalDebug)) echo "Restarting...\n";
2492
+			if ($globalDebug) {
2493
+				echo "ERROR : socket_select give this error ".$error . "\n";
2494
+			}
2495
+			if (isset($globalDebug)) {
2496
+				echo "Restarting...\n";
2497
+			}
1807 2498
 			// Restart the script if possible
1808 2499
 			if (is_array($sockets)) {
1809
-			    if ($globalDebug) echo "Shutdown all sockets...";
2500
+			    if ($globalDebug) {
2501
+			    	echo "Shutdown all sockets...";
2502
+			    }
1810 2503
 			    
1811 2504
 			    foreach ($sockets as $sock) {
1812 2505
 				@socket_shutdown($sock,2);
@@ -1814,25 +2507,45 @@  discard block
 block discarded – undo
1814 2507
 			    }
1815 2508
 			    
1816 2509
 			}
1817
-			if ($globalDebug) echo "Waiting...";
2510
+			if ($globalDebug) {
2511
+				echo "Waiting...";
2512
+			}
1818 2513
 			sleep(2);
1819 2514
 			$time = time();
1820 2515
 			//connect_all($hosts);
1821 2516
 			$aprs_connect = 0;
1822
-			if ($reset%5 == 0) sleep(20);
1823
-			if ($reset%10 == 0) sleep(100);
1824
-			if ($reset%20 == 0) sleep(200);
1825
-			if ($reset > 100) exit('Too many attempts...');
1826
-			if ($globalDebug) echo "Restart all connections...";
2517
+			if ($reset%5 == 0) {
2518
+				sleep(20);
2519
+			}
2520
+			if ($reset%10 == 0) {
2521
+				sleep(100);
2522
+			}
2523
+			if ($reset%20 == 0) {
2524
+				sleep(200);
2525
+			}
2526
+			if ($reset > 100) {
2527
+				exit('Too many attempts...');
2528
+			}
2529
+			if ($globalDebug) {
2530
+				echo "Restart all connections...";
2531
+			}
1827 2532
 			connect_all($globalSources);
1828 2533
 		}
1829 2534
 	    }
1830 2535
 	}
1831 2536
 	if ($globalDaemon === false) {
1832
-	    if ($globalDebug) echo 'Check all...'."\n";
1833
-	    if (isset($SI)) $SI->checkAll();
1834
-	    if (isset($TI)) $TI->checkAll();
1835
-	    if (isset($MI)) $MI->checkAll();
2537
+	    if ($globalDebug) {
2538
+	    	echo 'Check all...'."\n";
2539
+	    }
2540
+	    if (isset($SI)) {
2541
+	    	$SI->checkAll();
2542
+	    }
2543
+	    if (isset($TI)) {
2544
+	    	$TI->checkAll();
2545
+	    }
2546
+	    if (isset($MI)) {
2547
+	    	$MI->checkAll();
2548
+	    }
1836 2549
 	}
1837 2550
     }
1838 2551
 }
Please login to merge, or discard this patch.