Completed
Push — master ( c9fe9a...e66237 )
by Yannick
29:51
created
scripts/daemon-spotter.php 3 patches
Indentation   +1204 added lines, -1204 removed lines patch added patch discarded remove patch
@@ -15,65 +15,65 @@  discard block
 block discarded – undo
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) {
18
-    require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19 19
 }
20 20
 if (isset($globalMarine) && $globalMarine) {
21
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
22
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
22
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25 25
 if (!isset($globalDebug)) $globalDebug = FALSE;
26 26
 
27 27
 if ($globalInstalled === FALSE) {
28
-    echo "This script MUST be run after install script. Use your web browser to run install/index.php";
29
-    sleep(5);
30
-    die();
28
+	echo "This script MUST be run after install script. Use your web browser to run install/index.php";
29
+	sleep(5);
30
+	die();
31 31
 }
32 32
 
33 33
 
34 34
 // Check if schema is at latest version
35 35
 $Connection = new Connection();
36 36
 if ($Connection->connectionExists() === false) {
37
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
38
-    exit();
37
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
38
+	exit();
39 39
 }
40 40
 if ($Connection->latest() === false) {
41
-    echo "You MUST update to latest schema. Use your web browser to run install/index.php";
42
-    exit();
41
+	echo "You MUST update to latest schema. Use your web browser to run install/index.php";
42
+	exit();
43 43
 }
44 44
 if (PHP_SAPI != 'cli') {
45
-    echo "This script MUST be called from console, not a web browser.";
45
+	echo "This script MUST be called from console, not a web browser.";
46 46
 //    exit();
47 47
 }
48 48
 
49 49
 // This is to be compatible with old version of settings.php
50 50
 if (!isset($globalSources)) {
51
-    if (isset($globalSBS1Hosts)) {
52
-        //$hosts = $globalSBS1Hosts;
53
-        foreach ($globalSBS1Hosts as $host) {
54
-	    $globalSources[] = array('host' => $host);
55
-    	}
56
-    } else {
57
-        if (!isset($globalSBS1Host)) {
58
-	    echo '$globalSources MUST be defined !';
59
-	    die;
51
+	if (isset($globalSBS1Hosts)) {
52
+		//$hosts = $globalSBS1Hosts;
53
+		foreach ($globalSBS1Hosts as $host) {
54
+		$globalSources[] = array('host' => $host);
55
+		}
56
+	} else {
57
+		if (!isset($globalSBS1Host)) {
58
+		echo '$globalSources MUST be defined !';
59
+		die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62 62
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
63
-    }
63
+	}
64 64
 }
65 65
 
66 66
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70
-    $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
-    else $globalSources[] = array('host' => $options['s']);
70
+	$globalSources = array();
71
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
+	else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74
-    $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
-    else $globalSources[] = array('host' => $options['source']);
74
+	$globalSources = array();
75
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
+	else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
79 79
 	$globalServerAPRS = TRUE;
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 if (isset($options['idsource'])) $id_source = $options['idsource'];
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115
-    if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
115
+	if ($globalDebug) echo "Using Server Mode\n";
116
+	$SI=new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
126
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
127
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
126
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
127
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
128 128
 }
129 129
 
130 130
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
131 131
 if (isset($globalMarine) && $globalMarine) {
132
-    $AIS = new AIS();
133
-    $MI = new MarineImport($Connection->db);
132
+	$AIS = new AIS();
133
+	$MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136 136
 $SBS=new SBS();
@@ -143,12 +143,12 @@  discard block
 block discarded – undo
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
147
-        global $sockets;
148
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149
-        die("Bye!\n");
150
-    });
151
-    pcntl_signal_dispatch();
146
+	pcntl_signal(SIGINT,  function() {
147
+		global $sockets;
148
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149
+		die("Bye!\n");
150
+	});
151
+	pcntl_signal_dispatch();
152 152
 }
153 153
 
154 154
 // let's try and connect
@@ -158,47 +158,47 @@  discard block
 block discarded – undo
158 158
 $reset = 0;
159 159
 
160 160
 function connect_all($hosts) {
161
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163
-    $reset++;
164
-    if ($globalDebug) echo 'Connect to all...'."\n";
165
-    foreach ($hosts as $id => $value) {
161
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163
+	$reset++;
164
+	if ($globalDebug) echo 'Connect to all...'."\n";
165
+	foreach ($hosts as $id => $value) {
166 166
 	$host = $value['host'];
167 167
 	$udp = false;
168 168
 	$globalSources[$id]['last_exec'] = 0;
169 169
 	// Here we check type of source(s)
170 170
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
-            if (preg_match('/deltadb.txt$/i',$host)) {
172
-        	//$formats[$id] = 'deltadbtxt';
173
-        	$globalSources[$id]['format'] = 'deltadbtxt';
174
-        	//$last_exec['deltadbtxt'] = 0;
175
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
177
-        	//$formats[$id] = 'vatsimtxt';
178
-        	$globalSources[$id]['format'] = 'vatsimtxt';
179
-        	//$last_exec['vatsimtxt'] = 0;
180
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
182
-        	//$formats[$id] = 'aircraftlistjson';
183
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
184
-        	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
187
-        	//$formats[$id] = 'aircraftjson';
188
-        	$globalSources[$id]['format'] = 'aircraftjson';
189
-        	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
-    	    } else if (preg_match('/aircraft$/i',$host)) {
192
-        	//$formats[$id] = 'planefinderclient';
193
-        	$globalSources[$id]['format'] = 'planefinderclient';
194
-        	//$last_exec['aircraftlistjson'] = 0;
195
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
-    	    } else if (preg_match('/opensky/i',$host)) {
197
-        	//$formats[$id] = 'aircraftlistjson';
198
-        	$globalSources[$id]['format'] = 'opensky';
199
-        	//$last_exec['aircraftlistjson'] = 0;
200
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
201
-    	    /*
171
+			if (preg_match('/deltadb.txt$/i',$host)) {
172
+			//$formats[$id] = 'deltadbtxt';
173
+			$globalSources[$id]['format'] = 'deltadbtxt';
174
+			//$last_exec['deltadbtxt'] = 0;
175
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
177
+			//$formats[$id] = 'vatsimtxt';
178
+			$globalSources[$id]['format'] = 'vatsimtxt';
179
+			//$last_exec['vatsimtxt'] = 0;
180
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
182
+			//$formats[$id] = 'aircraftlistjson';
183
+			$globalSources[$id]['format'] = 'aircraftlistjson';
184
+			//$last_exec['aircraftlistjson'] = 0;
185
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
+			} else if (preg_match('/aircraft.json$/i',$host)) {
187
+			//$formats[$id] = 'aircraftjson';
188
+			$globalSources[$id]['format'] = 'aircraftjson';
189
+			//$last_exec['aircraftlistjson'] = 0;
190
+			if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
+			} else if (preg_match('/aircraft$/i',$host)) {
192
+			//$formats[$id] = 'planefinderclient';
193
+			$globalSources[$id]['format'] = 'planefinderclient';
194
+			//$last_exec['aircraftlistjson'] = 0;
195
+			if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
+			} else if (preg_match('/opensky/i',$host)) {
197
+			//$formats[$id] = 'aircraftlistjson';
198
+			$globalSources[$id]['format'] = 'opensky';
199
+			//$last_exec['aircraftlistjson'] = 0;
200
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
201
+			/*
202 202
     	    // Disabled for now, site change source format
203 203
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
204 204
         	//$formats[$id] = 'radarvirtueljson';
@@ -210,130 +210,130 @@  discard block
 block discarded – undo
210 210
         	    exit(0);
211 211
         	}
212 212
     	    */
213
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
214
-        	//$formats[$id] = 'planeupdatefaa';
215
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
216
-        	//$last_exec['planeupdatefaa'] = 0;
217
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
218
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
219
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220
-        	    exit(0);
221
-        	}
222
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
223
-        	//$formats[$id] = 'phpvmacars';
224
-        	$globalSources[$id]['format'] = 'phpvmacars';
225
-        	//$last_exec['phpvmacars'] = 0;
226
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
228
-        	//$formats[$id] = 'phpvmacars';
229
-        	$globalSources[$id]['format'] = 'vaos';
230
-        	//$last_exec['phpvmacars'] = 0;
231
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
233
-        	//$formats[$id] = 'phpvmacars';
234
-        	$globalSources[$id]['format'] = 'vam';
235
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
-            } else if (preg_match('/whazzup/i',$host)) {
237
-        	//$formats[$id] = 'whazzup';
238
-        	$globalSources[$id]['format'] = 'whazzup';
239
-        	//$last_exec['whazzup'] = 0;
240
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
-            } else if (preg_match('/blitzortung/i',$host)) {
242
-        	$globalSources[$id]['format'] = 'blitzortung';
243
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
-            } else if (preg_match('/airwhere/i',$host)) {
245
-        	$globalSources[$id]['format'] = 'airwhere';
246
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
-            } else if (preg_match('/recentpireps/i',$host)) {
248
-        	//$formats[$id] = 'pirepsjson';
249
-        	$globalSources[$id]['format'] = 'pirepsjson';
250
-        	//$last_exec['pirepsjson'] = 0;
251
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
253
-        	//$formats[$id] = 'fr24json';
254
-        	$globalSources[$id]['format'] = 'fr24json';
255
-        	//$last_exec['fr24json'] = 0;
256
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
257
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
258
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259
-        	    exit(0);
260
-        	}
261
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
262
-        	//$formats[$id] = 'fr24json';
263
-        	$globalSources[$id]['format'] = 'myshiptracking';
264
-        	//$last_exec['fr24json'] = 0;
265
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
266
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
267
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
268
-        	    exit(0);
269
-        	}
270
-            //} else if (preg_match('/10001/',$host)) {
271
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272
-        	//$formats[$id] = 'tsv';
273
-        	$globalSources[$id]['format'] = 'tsv';
274
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275
-            }
276
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
279
-    		    if ($idf !== false) {
280
-    			$httpfeeds[$id] = $idf;
281
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
285
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
286
-	    $hostport = explode(':',$host);
287
-	    if (isset($hostport[1])) {
213
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
214
+			//$formats[$id] = 'planeupdatefaa';
215
+			$globalSources[$id]['format'] = 'planeupdatefaa';
216
+			//$last_exec['planeupdatefaa'] = 0;
217
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
218
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
219
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220
+				exit(0);
221
+			}
222
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
223
+			//$formats[$id] = 'phpvmacars';
224
+			$globalSources[$id]['format'] = 'phpvmacars';
225
+			//$last_exec['phpvmacars'] = 0;
226
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
228
+			//$formats[$id] = 'phpvmacars';
229
+			$globalSources[$id]['format'] = 'vaos';
230
+			//$last_exec['phpvmacars'] = 0;
231
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
233
+			//$formats[$id] = 'phpvmacars';
234
+			$globalSources[$id]['format'] = 'vam';
235
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
+			} else if (preg_match('/whazzup/i',$host)) {
237
+			//$formats[$id] = 'whazzup';
238
+			$globalSources[$id]['format'] = 'whazzup';
239
+			//$last_exec['whazzup'] = 0;
240
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
+			} else if (preg_match('/blitzortung/i',$host)) {
242
+			$globalSources[$id]['format'] = 'blitzortung';
243
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
+			} else if (preg_match('/airwhere/i',$host)) {
245
+			$globalSources[$id]['format'] = 'airwhere';
246
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
+			} else if (preg_match('/recentpireps/i',$host)) {
248
+			//$formats[$id] = 'pirepsjson';
249
+			$globalSources[$id]['format'] = 'pirepsjson';
250
+			//$last_exec['pirepsjson'] = 0;
251
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
253
+			//$formats[$id] = 'fr24json';
254
+			$globalSources[$id]['format'] = 'fr24json';
255
+			//$last_exec['fr24json'] = 0;
256
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
257
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
258
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259
+				exit(0);
260
+			}
261
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
262
+			//$formats[$id] = 'fr24json';
263
+			$globalSources[$id]['format'] = 'myshiptracking';
264
+			//$last_exec['fr24json'] = 0;
265
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
266
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
267
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
268
+				exit(0);
269
+			}
270
+			//} else if (preg_match('/10001/',$host)) {
271
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272
+			//$formats[$id] = 'tsv';
273
+			$globalSources[$id]['format'] = 'tsv';
274
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275
+			}
276
+		} elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277
+			if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
279
+				if ($idf !== false) {
280
+				$httpfeeds[$id] = $idf;
281
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283
+			} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284
+			elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
285
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
286
+		$hostport = explode(':',$host);
287
+		if (isset($hostport[1])) {
288 288
 		$port = $hostport[1];
289 289
 		$hostn = $hostport[0];
290
-	    } else {
290
+		} else {
291 291
 		$port = $globalSources[$id]['port'];
292 292
 		$hostn = $globalSources[$id]['host'];
293
-	    }
294
-	    $Common = new Common();
295
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
296
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
297
-    	    } else {
298
-    		$udp = true;
299
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
300
-	    }
301
-	    if ($s) {
302
-    	        $sockets[$id] = $s;
303
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
304
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
293
+		}
294
+		$Common = new Common();
295
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
296
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
297
+			} else {
298
+			$udp = true;
299
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
300
+		}
301
+		if ($s) {
302
+				$sockets[$id] = $s;
303
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
304
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
305 305
 			//$formats[$id] = 'aprs';
306 306
 			$globalSources[$id]['format'] = 'aprs';
307 307
 			//$aprs_connect = 0;
308 308
 			//$use_aprs = true;
309
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
309
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
310 310
 			$globalSources[$id]['format'] = 'vrstcp';
311
-    		    } elseif ($port == '10001') {
312
-        		//$formats[$id] = 'tsv';
313
-        		$globalSources[$id]['format'] = 'tsv';
314
-		    } elseif ($port == '30002') {
315
-        		//$formats[$id] = 'raw';
316
-        		$globalSources[$id]['format'] = 'raw';
317
-		    } elseif ($port == '5001') {
318
-        		//$formats[$id] = 'raw';
319
-        		$globalSources[$id]['format'] = 'flightgearmp';
320
-		    } elseif ($port == '30005') {
311
+				} elseif ($port == '10001') {
312
+				//$formats[$id] = 'tsv';
313
+				$globalSources[$id]['format'] = 'tsv';
314
+			} elseif ($port == '30002') {
315
+				//$formats[$id] = 'raw';
316
+				$globalSources[$id]['format'] = 'raw';
317
+			} elseif ($port == '5001') {
318
+				//$formats[$id] = 'raw';
319
+				$globalSources[$id]['format'] = 'flightgearmp';
320
+			} elseif ($port == '30005') {
321 321
 			// Not yet supported
322
-        		//$formats[$id] = 'beast';
323
-        		$globalSources[$id]['format'] = 'beast';
324
-		    //} else $formats[$id] = 'sbs';
325
-		    } else $globalSources[$id]['format'] = 'sbs';
326
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
322
+				//$formats[$id] = 'beast';
323
+				$globalSources[$id]['format'] = 'beast';
324
+			//} else $formats[$id] = 'sbs';
325
+			} else $globalSources[$id]['format'] = 'sbs';
326
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
327 327
 		}
328 328
 		if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
329 329
 		elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
330
-            } else {
330
+			} else {
331 331
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
332 332
 		sleep(10);
333 333
 		connect_all($hosts);
334
-    	    }
335
-        }
336
-    }
334
+			}
335
+		}
336
+	}
337 337
 }
338 338
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
339 339
 
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 //connect_all($globalSources);
357 357
 
358 358
 if (isset($globalProxy) && $globalProxy) {
359
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
359
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
360 360
 } else {
361
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
361
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
362 362
 }
363 363
 
364 364
 // APRS Configuration
@@ -367,21 +367,21 @@  discard block
 block discarded – undo
367 367
 	die;
368 368
 }
369 369
 foreach ($globalSources as $key => $source) {
370
-    if (!isset($source['format'])) {
371
-        $globalSources[$key]['format'] = 'auto';
372
-    }
373
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
374
-        unset($globalSources[$key]);
375
-    }
370
+	if (!isset($source['format'])) {
371
+		$globalSources[$key]['format'] = 'auto';
372
+	}
373
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
374
+		unset($globalSources[$key]);
375
+	}
376 376
 }
377 377
 connect_all($globalSources);
378 378
 foreach ($globalSources as $key => $source) {
379
-    if (isset($source['format']) && $source['format'] == 'aprs') {
379
+	if (isset($source['format']) && $source['format'] == 'aprs') {
380 380
 	$aprs_connect = 0;
381 381
 	$use_aprs = true;
382 382
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
383 383
 	break;
384
-    }
384
+	}
385 385
 }
386 386
 
387 387
 if ($use_aprs) {
@@ -422,173 +422,173 @@  discard block
 block discarded – undo
422 422
 
423 423
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
424 424
 while ($i > 0) {
425
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
425
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
426 426
 
427
-    if (!$globalDaemon) $i = $endtime-time();
428
-    // Delete old ATC
429
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
427
+	if (!$globalDaemon) $i = $endtime-time();
428
+	// Delete old ATC
429
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
430 430
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
431
-        $ATC->deleteOldATC();
432
-    }
431
+		$ATC->deleteOldATC();
432
+	}
433 433
     
434
-    if (count($last_exec) == count($globalSources)) {
434
+	if (count($last_exec) == count($globalSources)) {
435 435
 	$max = $globalMinFetch;
436 436
 	foreach ($last_exec as $last) {
437
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
437
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
438 438
 	}
439 439
 	if ($max < $globalMinFetch) {
440
-	    if ($globalDebug) echo 'Sleeping...'."\n";
441
-	    sleep($globalMinFetch-$max+2);
440
+		if ($globalDebug) echo 'Sleeping...'."\n";
441
+		sleep($globalMinFetch-$max+2);
442
+	}
442 443
 	}
443
-    }
444 444
 
445 445
     
446
-    //foreach ($formats as $id => $value) {
447
-    foreach ($globalSources as $id => $value) {
446
+	//foreach ($formats as $id => $value) {
447
+	foreach ($globalSources as $id => $value) {
448 448
 	date_default_timezone_set('UTC');
449 449
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
450 450
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
451 451
 	if ($value['format'] === 'deltadbtxt' && 
452
-	    (
452
+		(
453 453
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
454 454
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
455
-	    )
455
+		)
456 456
 	) {
457
-        //$buffer = $Common->getData($hosts[$id]);
458
-        $buffer = $Common->getData($value['host']);
459
-        if ($buffer != '') $reset = 0;
460
-        $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
461
-        $buffer = explode('\n', $buffer);
462
-        foreach ($buffer as $line) {
463
-            if ($line != '' && count($line) > 7) {
464
-                $line = explode(',', $line);
465
-                $data = array();
466
-                $data['hex'] = $line[1]; // hex
467
-                $data['ident'] = $line[2]; // ident
468
-                if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
469
-                if (isset($line[4])) $data['speed'] = $line[4]; // speed
470
-                if (isset($line[5])) $data['heading'] = $line[5]; // heading
471
-                if (isset($line[6])) $data['latitude'] = $line[6]; // lat
472
-                if (isset($line[7])) $data['longitude'] = $line[7]; // long
473
-                $data['verticalrate'] = ''; // vertical rate
474
-                //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
475
-                $data['emergency'] = ''; // emergency
476
-                $data['datetime'] = date('Y-m-d H:i:s');
477
-                $data['format_source'] = 'deltadbtxt';
478
-                $data['id_source'] = $id_source;
479
-                if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
480
-                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
481
-                if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
482
-                $SI->add($data);
483
-                unset($data);
484
-            }
485
-        }
486
-        $last_exec[$id]['last'] = time();
487
-    } elseif ($value['format'] === 'radarcapejson' &&
488
-            (
489
-                (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
490
-                (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
491
-            )
492
-        ) {
493
-            //$buffer = $Common->getData($hosts[$id]);
494
-            $buffer = $Common->getData($value['host']);
495
-            if ($buffer != '') {
496
-                $all_data = json_decode($buffer,true);
497
-                foreach ($all_data as $line) {
498
-                    $data = array();
499
-                    $data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
500
-                    $data['hex'] = $line['hex']; // hex
501
-                    $data['ident'] = $line['fli']; // ident
502
-                    $data['altitude'] = $line['alt']; // altitude
503
-                    $data['speed'] = $line['spd']; // speed
504
-                    $data['heading'] = $line['trk']; // heading
505
-                    $data['latitude'] = $line['lat']; // lat
506
-                    $data['longitude'] = $line['lon']; // long
507
-                    $data['verticalrate'] = $line['vrt']; // vertical rate
508
-                    $data['squawk'] = $line['squ']; // squawk
509
-                    $data['ground'] = $line['gda']; // ground
510
-                    $data['registration'] = $line['reg'];
511
-                    //$data['emergency'] = ''; // emergency
512
-                    $data['datetime'] = date('Y-m-d H:i:s');
513
-                    $data['format_source'] = 'radarcapejson';
514
-                    $data['id_source'] = $id_source;
515
-                    if (isset($value['name']) && $value['name'] != '') {
516
-                        if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
517
-                        else $data['source_name'] = $value['name'];
518
-                    } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
519
-                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
520
-                    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
457
+		//$buffer = $Common->getData($hosts[$id]);
458
+		$buffer = $Common->getData($value['host']);
459
+		if ($buffer != '') $reset = 0;
460
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
461
+		$buffer = explode('\n', $buffer);
462
+		foreach ($buffer as $line) {
463
+			if ($line != '' && count($line) > 7) {
464
+				$line = explode(',', $line);
465
+				$data = array();
466
+				$data['hex'] = $line[1]; // hex
467
+				$data['ident'] = $line[2]; // ident
468
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
469
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
470
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
471
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
472
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
473
+				$data['verticalrate'] = ''; // vertical rate
474
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
475
+				$data['emergency'] = ''; // emergency
476
+				$data['datetime'] = date('Y-m-d H:i:s');
477
+				$data['format_source'] = 'deltadbtxt';
478
+				$data['id_source'] = $id_source;
479
+				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
480
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
481
+				if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
482
+				$SI->add($data);
483
+				unset($data);
484
+			}
485
+		}
486
+		$last_exec[$id]['last'] = time();
487
+	} elseif ($value['format'] === 'radarcapejson' &&
488
+			(
489
+				(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
490
+				(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
491
+			)
492
+		) {
493
+			//$buffer = $Common->getData($hosts[$id]);
494
+			$buffer = $Common->getData($value['host']);
495
+			if ($buffer != '') {
496
+				$all_data = json_decode($buffer,true);
497
+				foreach ($all_data as $line) {
498
+					$data = array();
499
+					$data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
500
+					$data['hex'] = $line['hex']; // hex
501
+					$data['ident'] = $line['fli']; // ident
502
+					$data['altitude'] = $line['alt']; // altitude
503
+					$data['speed'] = $line['spd']; // speed
504
+					$data['heading'] = $line['trk']; // heading
505
+					$data['latitude'] = $line['lat']; // lat
506
+					$data['longitude'] = $line['lon']; // long
507
+					$data['verticalrate'] = $line['vrt']; // vertical rate
508
+					$data['squawk'] = $line['squ']; // squawk
509
+					$data['ground'] = $line['gda']; // ground
510
+					$data['registration'] = $line['reg'];
511
+					//$data['emergency'] = ''; // emergency
512
+					$data['datetime'] = date('Y-m-d H:i:s');
513
+					$data['format_source'] = 'radarcapejson';
514
+					$data['id_source'] = $id_source;
515
+					if (isset($value['name']) && $value['name'] != '') {
516
+						if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
517
+						else $data['source_name'] = $value['name'];
518
+					} elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
519
+					if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
520
+					if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
521 521
 
522
-                    $SI->add($data);
523
-                    unset($data);
524
-                }
525
-            }
526
-            $last_exec[$id]['last'] = time();
522
+					$SI->add($data);
523
+					unset($data);
524
+				}
525
+			}
526
+			$last_exec[$id]['last'] = time();
527 527
 	} elseif ($value['format'] === 'aisnmeatxt' && 
528
-	    (
528
+		(
529 529
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
530 530
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
531
-	    )
531
+		)
532 532
 	) {
533
-	    date_default_timezone_set('CET');
534
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
535
-	    date_default_timezone_set('UTC');
536
-	    if ($buffer != '') $reset = 0;
537
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
538
-	    $buffer = explode('\n',$buffer);
539
-	    foreach ($buffer as $line) {
533
+		date_default_timezone_set('CET');
534
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
535
+		date_default_timezone_set('UTC');
536
+		if ($buffer != '') $reset = 0;
537
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
538
+		$buffer = explode('\n',$buffer);
539
+		foreach ($buffer as $line) {
540 540
 		if ($line != '') {
541
-		    //echo "'".$line."'\n";
542
-		    $add = false;
543
-		    $ais_data = $AIS->parse_line(trim($line));
544
-		    $data = array();
545
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
546
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
547
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
548
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
549
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
550
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
551
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
552
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
553
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
554
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
555
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
556
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
557
-		    if (isset($ais_data['timestamp'])) {
541
+			//echo "'".$line."'\n";
542
+			$add = false;
543
+			$ais_data = $AIS->parse_line(trim($line));
544
+			$data = array();
545
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
546
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
547
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
548
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
549
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
550
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
551
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
552
+			if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
553
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
554
+			if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
555
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
556
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
557
+			if (isset($ais_data['timestamp'])) {
558 558
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
559 559
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
560
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
561
-			    $add = true;
560
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
561
+				$add = true;
562 562
 			}
563
-		    } else {
563
+			} else {
564 564
 			$data['datetime'] = date('Y-m-d H:i:s');
565 565
 			$add = true;
566
-		    }
567
-		    $data['format_source'] = 'aisnmeatxt';
568
-    		    $data['id_source'] = $id_source;
569
-		    //print_r($data);
570
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
571
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
572
-		    unset($data);
566
+			}
567
+			$data['format_source'] = 'aisnmeatxt';
568
+				$data['id_source'] = $id_source;
569
+			//print_r($data);
570
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
571
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
572
+			unset($data);
573 573
 		}
574
-    	    }
575
-    	    $last_exec[$id]['last'] = time();
574
+			}
575
+			$last_exec[$id]['last'] = time();
576 576
 	} elseif ($value['format'] === 'aisnmeahttp') {
577
-	    $arr = $httpfeeds;
578
-	    $w = $e = null;
577
+		$arr = $httpfeeds;
578
+		$w = $e = null;
579 579
 	    
580
-	    if (isset($arr[$id])) {
580
+		if (isset($arr[$id])) {
581 581
 		$nn = stream_select($arr,$w,$e,$timeout);
582 582
 		if ($nn > 0) {
583
-		    foreach ($httpfeeds as $feed) {
583
+			foreach ($httpfeeds as $feed) {
584 584
 			$buffer = stream_get_line($feed,2000,"\n");
585 585
 			if ($buffer === FALSE) {
586
-			    connect_all($globalSources);
586
+				connect_all($globalSources);
587 587
 			}
588 588
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
589 589
 			$buffer = explode('\n',$buffer);
590 590
 			foreach ($buffer as $line) {
591
-			    if ($line != '') {
591
+				if ($line != '') {
592 592
 				$ais_data = $AIS->parse_line(trim($line));
593 593
 				$data = array();
594 594
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -606,117 +606,117 @@  discard block
 block discarded – undo
606 606
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
607 607
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
608 608
 				if (isset($ais_data['timestamp'])) {
609
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
609
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
610 610
 				} else {
611
-				    $data['datetime'] = date('Y-m-d H:i:s');
611
+					$data['datetime'] = date('Y-m-d H:i:s');
612 612
 				}
613 613
 				$data['format_source'] = 'aisnmeahttp';
614 614
 				$data['id_source'] = $id_source;
615 615
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
616 616
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
617 617
 				unset($data);
618
-			    }
618
+				}
619
+			}
619 620
 			}
620
-		    }
621 621
 		} else {
622
-		    $format = $value['format'];
623
-		    if (isset($tt[$format])) $tt[$format]++;
624
-		    else $tt[$format] = 0;
625
-		    if ($tt[$format] > 30) {
622
+			$format = $value['format'];
623
+			if (isset($tt[$format])) $tt[$format]++;
624
+			else $tt[$format] = 0;
625
+			if ($tt[$format] > 30) {
626 626
 			if ($globalDebug) echo 'Reconnect...'."\n";
627 627
 			sleep(2);
628 628
 			//$sourceeen[] = $value;
629 629
 			//connect_all($sourceeen);
630 630
 			//$sourceeen = array();
631 631
 			connect_all($globalSources);
632
-		    }
632
+			}
633
+		}
633 634
 		}
634
-	    }
635 635
 	} elseif ($value['format'] === 'myshiptracking' && 
636
-	    (
636
+		(
637 637
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
638 638
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
639
-	    )
639
+		)
640 640
 	) {
641
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
642
-	    if ($buffer != '') {
641
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
642
+		if ($buffer != '') {
643 643
 		//echo $buffer;
644 644
 		$all_data = json_decode($buffer,true);
645 645
 		//print_r($all_data);
646 646
 		if (isset($all_data[0]['DATA'])) {
647
-		    foreach ($all_data[0]['DATA'] as $line) {
647
+			foreach ($all_data[0]['DATA'] as $line) {
648 648
 			if ($line != '') {
649
-			    $data = array();
650
-			    $data['ident'] = $line['NAME'];
651
-			    $data['mmsi'] = $line['MMSI'];
652
-			    if (strlen($data['mmsi']) > 9) {
649
+				$data = array();
650
+				$data['ident'] = $line['NAME'];
651
+				$data['mmsi'] = $line['MMSI'];
652
+				if (strlen($data['mmsi']) > 9) {
653 653
 				$data['mmsi'] = substr($data['mmsi'],-9);
654
-			    }
655
-			    $data['speed'] = $line['SOG'];
656
-			    $data['heading'] = $line['COG'];
657
-			    $data['latitude'] = $line['LAT'];
658
-			    $data['longitude'] = $line['LNG'];
659
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
660
-			    //$data['type_id'] = $line['TYPE'];
661
-			    $data['imo'] = $line['IMO'];
662
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
663
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
664
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
665
-			    $data['format_source'] = 'myshiptracking';
666
-			    $data['id_source'] = $id_source;
667
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
668
-			    $MI->add($data);
669
-			    unset($data);
654
+				}
655
+				$data['speed'] = $line['SOG'];
656
+				$data['heading'] = $line['COG'];
657
+				$data['latitude'] = $line['LAT'];
658
+				$data['longitude'] = $line['LNG'];
659
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
660
+				//$data['type_id'] = $line['TYPE'];
661
+				$data['imo'] = $line['IMO'];
662
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
663
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
664
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
665
+				$data['format_source'] = 'myshiptracking';
666
+				$data['id_source'] = $id_source;
667
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
668
+				$MI->add($data);
669
+				unset($data);
670
+			}
670 671
 			}
671
-		    }
672 672
 		}
673
-	    }
674
-	    $last_exec[$id]['last'] = time();
673
+		}
674
+		$last_exec[$id]['last'] = time();
675 675
 	} elseif ($value['format'] === 'boatbeaconapp' && 
676
-	    (
676
+		(
677 677
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
678 678
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
679
-	    )
679
+		)
680 680
 	) {
681
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
682
-	    if ($buffer != '') {
681
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
682
+		if ($buffer != '') {
683 683
 		$all_data = json_decode($buffer,true);
684 684
 		if (isset($all_data[0]['mmsi'])) {
685
-		    foreach ($all_data as $line) {
685
+			foreach ($all_data as $line) {
686 686
 			if ($line != '') {
687
-			    $data = array();
688
-			    $data['ident'] = $line['shipname'];
689
-			    $data['callsign'] = $line['callsign'];
690
-			    $data['mmsi'] = substr($line['mmsi'],-9);
691
-			    $data['speed'] = $line['sog'];
692
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
693
-			    $data['latitude'] = $line['latitude'];
694
-			    $data['longitude'] = $line['longitude'];
695
-			    $data['type_id'] = $line['shiptype'];
696
-			    $data['arrival_code'] = $line['destination'];
697
-			    $data['datetime'] = $line['time'];
698
-			    $data['format_source'] = 'boatbeaconapp';
699
-			    $data['id_source'] = $id_source;
700
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
701
-			    $MI->add($data);
702
-			    unset($data);
687
+				$data = array();
688
+				$data['ident'] = $line['shipname'];
689
+				$data['callsign'] = $line['callsign'];
690
+				$data['mmsi'] = substr($line['mmsi'],-9);
691
+				$data['speed'] = $line['sog'];
692
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
693
+				$data['latitude'] = $line['latitude'];
694
+				$data['longitude'] = $line['longitude'];
695
+				$data['type_id'] = $line['shiptype'];
696
+				$data['arrival_code'] = $line['destination'];
697
+				$data['datetime'] = $line['time'];
698
+				$data['format_source'] = 'boatbeaconapp';
699
+				$data['id_source'] = $id_source;
700
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
701
+				$MI->add($data);
702
+				unset($data);
703
+			}
703 704
 			}
704
-		    }
705 705
 		}
706 706
 		
707
-	    }
708
-    	    $last_exec[$id]['last'] = time();
707
+		}
708
+			$last_exec[$id]['last'] = time();
709 709
 	} elseif ($value['format'] === 'boatnerd' && 
710
-	    (
710
+		(
711 711
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
712 712
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
713
-	    )
713
+		)
714 714
 	) {
715
-	    $buffer = $Common->getData($value['host']);
716
-	    if ($buffer != '') {
715
+		$buffer = $Common->getData($value['host']);
716
+		if ($buffer != '') {
717 717
 		$all_data = json_decode($buffer,true);
718 718
 		if (isset($all_data['features'][0]['id'])) {
719
-		    foreach ($all_data['features'] as $line) {
719
+			foreach ($all_data['features'] as $line) {
720 720
 			print_r($line);
721 721
 			$data = array();
722 722
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -736,76 +736,76 @@  discard block
 block discarded – undo
736 736
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
737 737
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
738 738
 			unset($data);
739
-		    }
739
+			}
740 740
 		}
741 741
 		
742
-	    }
743
-    	    $last_exec[$id]['last'] = time();
742
+		}
743
+			$last_exec[$id]['last'] = time();
744 744
 	} elseif ($value['format'] === 'shipplotter' && 
745
-	    (
745
+		(
746 746
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
747 747
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
748
-	    )
748
+		)
749 749
 	) {
750
-	    if ($globalDebug) echo 'download...';
751
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
752
-	    if ($globalDebug) echo 'done !'."\n";
753
-	    // FIXME: Need more work
754
-	    if ($buffer != '') $reset = 0;
755
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
756
-	    $buffer = explode('\n',$buffer);
757
-	    foreach ($buffer as $line) {
750
+		if ($globalDebug) echo 'download...';
751
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
752
+		if ($globalDebug) echo 'done !'."\n";
753
+		// FIXME: Need more work
754
+		if ($buffer != '') $reset = 0;
755
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
756
+		$buffer = explode('\n',$buffer);
757
+		foreach ($buffer as $line) {
758 758
 		if ($line != '') {
759
-		    $data = array();
760
-		    //echo $line."\n";
761
-		    $data['mmsi'] = (int)substr($line,0,9);
762
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
763
-		    $data['status_id'] = substr($line,21,2);
764
-		    $data['type_id'] = substr($line,24,3);
765
-		    $data['latitude'] = substr($line,29,9);
766
-		    $data['longitude'] = substr($line,41,9);
767
-		    $data['speed'] = round(substr($line,51,5));
768
-		    //$data['course'] = substr($line,57,5);
769
-		    $data['heading'] = round(substr($line,63,3));
770
-		    //$data['draft'] = substr($line,67,4);
771
-		    //$data['length'] = substr($line,72,3);
772
-		    //$data['beam'] = substr($line,76,2);
773
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
774
-		    //$data['callsign'] = trim(substr($line,100,7);
775
-		    $data['arrival_code'] = substr($line,108,20);
776
-		    //$data['etaDate'] = substr($line,129,5);
777
-		    //$data['etaTime'] = substr($line,135,5);
778
-		    $data['format_source'] = 'shipplotter';
779
-    		    $data['id_source'] = $id_source;
780
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
781
-		    //print_r($data);
782
-		    //echo 'Add...'."\n";
783
-		    $MI->add($data);
784
-		    unset($data);
759
+			$data = array();
760
+			//echo $line."\n";
761
+			$data['mmsi'] = (int)substr($line,0,9);
762
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
763
+			$data['status_id'] = substr($line,21,2);
764
+			$data['type_id'] = substr($line,24,3);
765
+			$data['latitude'] = substr($line,29,9);
766
+			$data['longitude'] = substr($line,41,9);
767
+			$data['speed'] = round(substr($line,51,5));
768
+			//$data['course'] = substr($line,57,5);
769
+			$data['heading'] = round(substr($line,63,3));
770
+			//$data['draft'] = substr($line,67,4);
771
+			//$data['length'] = substr($line,72,3);
772
+			//$data['beam'] = substr($line,76,2);
773
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
774
+			//$data['callsign'] = trim(substr($line,100,7);
775
+			$data['arrival_code'] = substr($line,108,20);
776
+			//$data['etaDate'] = substr($line,129,5);
777
+			//$data['etaTime'] = substr($line,135,5);
778
+			$data['format_source'] = 'shipplotter';
779
+				$data['id_source'] = $id_source;
780
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
781
+			//print_r($data);
782
+			//echo 'Add...'."\n";
783
+			$MI->add($data);
784
+			unset($data);
785 785
 		}
786
-    	    }
787
-    	    $last_exec[$id]['last'] = time();
786
+			}
787
+			$last_exec[$id]['last'] = time();
788 788
 	} elseif ($value['format'] === 'sailaway' && 
789
-	    (
789
+		(
790 790
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
791 791
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
792
-	    )
792
+		)
793 793
 	) {
794
-	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
794
+		if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
795 795
 		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
796 796
 		//echo $authsailaway;
797 797
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
798 798
 		if (isset($setcookie[1][0])) {
799
-		    $sailaway_authcookie = $setcookie[1][0];
799
+			$sailaway_authcookie = $setcookie[1][0];
800
+		}
800 801
 		}
801
-	    }
802 802
 
803
-	    if ($globalDebug) echo '! Download... ';
804
-	    for ($i =0; $i <= 1; $i++) {
803
+		if ($globalDebug) echo '! Download... ';
804
+		for ($i =0; $i <= 1; $i++) {
805 805
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
806 806
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
807
-	    if ($globalDebug) echo 'done'."\n";
808
-	    if ($buffer != '') {
807
+		if ($globalDebug) echo 'done'."\n";
808
+		if ($buffer != '') {
809 809
 		$all_data = json_decode($buffer,true);
810 810
 		if (isset($all_data['missions'])) {
811 811
 			foreach ($all_data['missions'] as $mission) {
@@ -824,19 +824,19 @@  discard block
 block discarded – undo
824 824
 					//print_r($race_data);
825 825
 					unset($racebuffer);
826 826
 					if (isset($race_data['mission'])) {
827
-					    $datar = array();
828
-					    $datar['id'] = $mission['misnr'];
829
-					    $datar['desc'] = $race_data['mission']['misdescr'];
830
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
831
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
832
-					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
833
-					    $markers = array();
834
-					    foreach ($race_data['mission']['course'] as $course) {
827
+						$datar = array();
828
+						$datar['id'] = $mission['misnr'];
829
+						$datar['desc'] = $race_data['mission']['misdescr'];
830
+						$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
831
+						$datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
832
+						$datar['startdate'] = $race_data['mission']['misstartdatetime'];
833
+						$markers = array();
834
+						foreach ($race_data['mission']['course'] as $course) {
835 835
 						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
836
-					    }
837
-					    $datar['markers'] = json_encode($markers);
838
-					    //print_r($datar);
839
-					    $MI->race_add($datar);
836
+						}
837
+						$datar['markers'] = json_encode($markers);
838
+						//print_r($datar);
839
+						$MI->race_add($datar);
840 840
 					}
841 841
 				}
842 842
 				if ($bufferm != '') {
@@ -900,34 +900,34 @@  discard block
 block discarded – undo
900 900
 				}
901 901
 			}
902 902
 		}
903
-	    }
904
-	    }
905
-    	    $last_exec[$id]['last'] = time();
903
+		}
904
+		}
905
+			$last_exec[$id]['last'] = time();
906 906
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
907 907
 	} elseif (
908
-	    (
908
+		(
909 909
 		$value['format'] === 'whazzup' && 
910 910
 		(
911
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
912
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
911
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
912
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
913 913
 		)
914
-	    ) || (
914
+		) || (
915 915
 		$value['format'] === 'vatsimtxt' && 
916 916
 		(
917
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
918
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
917
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
918
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
919
+		)
919 920
 		)
920
-	    )
921 921
 	) {
922
-	    //$buffer = $Common->getData($hosts[$id]);
923
-	    $buffer = $Common->getData($value['host']);
924
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
925
-	    $buffer = explode('\n',$buffer);
926
-	    $reset = 0;
927
-	    foreach ($buffer as $line) {
928
-    		if ($line != '') {
929
-    		    $line = explode(':', $line);
930
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
922
+		//$buffer = $Common->getData($hosts[$id]);
923
+		$buffer = $Common->getData($value['host']);
924
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
925
+		$buffer = explode('\n',$buffer);
926
+		$reset = 0;
927
+		foreach ($buffer as $line) {
928
+			if ($line != '') {
929
+				$line = explode(':', $line);
930
+				if (count($line) > 30 && $line[0] != 'callsign') {
931 931
 			$data = array();
932 932
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
933 933
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -940,37 +940,37 @@  discard block
 block discarded – undo
940 940
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
941 941
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
942 942
 			$data['latitude'] = $line[5]; // lat
943
-	        	$data['longitude'] = $line[6]; // long
944
-	        	$data['verticalrate'] = ''; // vertical rate
945
-	        	$data['squawk'] = ''; // squawk
946
-	        	$data['emergency'] = ''; // emergency
947
-	        	$data['waypoints'] = $line[30];
943
+				$data['longitude'] = $line[6]; // long
944
+				$data['verticalrate'] = ''; // vertical rate
945
+				$data['squawk'] = ''; // squawk
946
+				$data['emergency'] = ''; // emergency
947
+				$data['waypoints'] = $line[30];
948 948
 			$data['datetime'] = date('Y-m-d H:i:s');
949 949
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
950 950
 			//if (isset($line[37])) $data['last_update'] = $line[37];
951
-		        $data['departure_airport_icao'] = $line[11];
952
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
953
-		        $data['arrival_airport_icao'] = $line[13];
951
+				$data['departure_airport_icao'] = $line[11];
952
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
953
+				$data['arrival_airport_icao'] = $line[13];
954 954
 			$data['frequency'] = $line[4];
955 955
 			$data['type'] = $line[18];
956 956
 			$data['range'] = $line[19];
957 957
 			if (isset($line[35])) $data['info'] = $line[35];
958
-    			$data['id_source'] = $id_source;
959
-	    		//$data['arrival_airport_time'] = ;
960
-	    		if ($line[9] != '') {
961
-	    		    $aircraft_data = explode('/',$line[9]);
962
-	    		    if (isset($aircraft_data[1])) {
963
-	    			$data['aircraft_icao'] = $aircraft_data[1];
964
-	    		    }
965
-        		}
966
-	    		/*
958
+				$data['id_source'] = $id_source;
959
+				//$data['arrival_airport_time'] = ;
960
+				if ($line[9] != '') {
961
+					$aircraft_data = explode('/',$line[9]);
962
+					if (isset($aircraft_data[1])) {
963
+					$data['aircraft_icao'] = $aircraft_data[1];
964
+					}
965
+				}
966
+				/*
967 967
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
968 968
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
969 969
 	    		*/
970
-	    		$data['format_source'] = $value['format'];
970
+				$data['format_source'] = $value['format'];
971 971
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
972 972
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
973
-    			if ($line[3] === 'PILOT') $SI->add($data);
973
+				if ($line[3] === 'PILOT') $SI->add($data);
974 974
 			elseif ($line[3] === 'ATC') {
975 975
 				//print_r($data);
976 976
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -991,21 +991,21 @@  discard block
 block discarded – undo
991 991
 					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']);
992 992
 				}
993 993
 			}
994
-    			unset($data);
995
-    		    }
996
-    		}
997
-    	    }
998
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
999
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
1000
-    	    $last_exec[$id]['last'] = time();
1001
-    	} elseif ($value['format'] === 'airwhere' && 
1002
-    	    (
1003
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1004
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1005
-    	    )
1006
-    	) {
1007
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1008
-	    if ($buffer != '') {
994
+				unset($data);
995
+				}
996
+			}
997
+			}
998
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
999
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
1000
+			$last_exec[$id]['last'] = time();
1001
+		} elseif ($value['format'] === 'airwhere' && 
1002
+			(
1003
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1004
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1005
+			)
1006
+		) {
1007
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1008
+		if ($buffer != '') {
1009 1009
 		$all_data = simplexml_load_string($buffer);
1010 1010
 		foreach($all_data->children() as $childdata) {
1011 1011
 			$data = array();
@@ -1027,10 +1027,10 @@  discard block
 block discarded – undo
1027 1027
 			$SI->add($data);
1028 1028
 			unset($data);
1029 1029
 		}
1030
-	    }
1031
-	    $Source->deleteOldLocationByType('gs');
1032
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1033
-	    if ($buffer != '') {
1030
+		}
1031
+		$Source->deleteOldLocationByType('gs');
1032
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1033
+		if ($buffer != '') {
1034 1034
 		$all_data = simplexml_load_string($buffer);
1035 1035
 		foreach($all_data->children() as $childdata) {
1036 1036
 			$data = array();
@@ -1048,8 +1048,8 @@  discard block
 block discarded – undo
1048 1048
 			}
1049 1049
 			unset($data);
1050 1050
 		}
1051
-	    }
1052
-	    $last_exec[$id]['last'] = time();
1051
+		}
1052
+		$last_exec[$id]['last'] = time();
1053 1053
 	/*
1054 1054
 	} if ($value['format'] === 'aircraftlistjson') {
1055 1055
 	    print_r($globalSources);
@@ -1057,17 +1057,17 @@  discard block
 block discarded – undo
1057 1057
 	    echo $globalMinFetch;
1058 1058
 	*/
1059 1059
 	} elseif ($value['format'] === 'aircraftlistjson' && 
1060
-	    (
1060
+		(
1061 1061
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1062 1062
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1063
-	    )
1063
+		)
1064 1064
 	) {
1065
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1066
-	    if ($buffer != '') {
1067
-	        $all_data = json_decode($buffer,true);
1065
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
1066
+		if ($buffer != '') {
1067
+			$all_data = json_decode($buffer,true);
1068 1068
 		if (isset($all_data['acList'])) {
1069
-		    $reset = 0;
1070
-		    foreach ($all_data['acList'] as $line) {
1069
+			$reset = 0;
1070
+			foreach ($all_data['acList'] as $line) {
1071 1071
 			$data = array();
1072 1072
 			$data['hex'] = $line['Icao']; // hex
1073 1073
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1090,10 +1090,10 @@  discard block
 block discarded – undo
1090 1090
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1091 1091
 			if (isset($data['latitude'])) $SI->add($data);
1092 1092
 			unset($data);
1093
-		    }
1093
+			}
1094 1094
 		} elseif (is_array($all_data)) {
1095
-		    $reset = 0;
1096
-		    foreach ($all_data as $line) {
1095
+			$reset = 0;
1096
+			foreach ($all_data as $line) {
1097 1097
 			$data = array();
1098 1098
 			$data['hex'] = $line['hex']; // hex
1099 1099
 			$data['ident'] = $line['flight']; // ident
@@ -1113,291 +1113,291 @@  discard block
 block discarded – undo
1113 1113
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1114 1114
 			$SI->add($data);
1115 1115
 			unset($data);
1116
-		    }
1116
+			}
1117 1117
 		}
1118
-	    } elseif ($globalDebug) echo 'No data'."\n";
1119
-    	    //$last_exec['aircraftlistjson'] = time();
1120
-    	    $last_exec[$id]['last'] = time();
1121
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1122
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
1123
-    	    (
1124
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1125
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1126
-    	    )
1127
-    	) {
1128
-	    $buffer = $Common->getData($value['host']);
1129
-	    $all_data = json_decode($buffer,true);
1130
-	    if (isset($all_data['planes'])) {
1118
+		} elseif ($globalDebug) echo 'No data'."\n";
1119
+			//$last_exec['aircraftlistjson'] = time();
1120
+			$last_exec[$id]['last'] = time();
1121
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1122
+		} elseif ($value['format'] === 'planeupdatefaa' && 
1123
+			(
1124
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1125
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1126
+			)
1127
+		) {
1128
+		$buffer = $Common->getData($value['host']);
1129
+		$all_data = json_decode($buffer,true);
1130
+		if (isset($all_data['planes'])) {
1131 1131
 		$reset = 0;
1132 1132
 		foreach ($all_data['planes'] as $key => $line) {
1133
-		    $data = array();
1134
-		    $data['hex'] = $key; // hex
1135
-		    $data['ident'] = $line[3]; // ident
1136
-		    $data['altitude'] = $line[6]; // altitude
1137
-		    $data['speed'] = $line[8]; // speed
1138
-		    $data['heading'] = $line[7]; // heading
1139
-		    $data['latitude'] = $line[4]; // lat
1140
-		    $data['longitude'] = $line[5]; // long
1141
-		    //$data['verticalrate'] = $line[]; // verticale rate
1142
-		    $data['squawk'] = $line[10]; // squawk
1143
-		    $data['emergency'] = ''; // emergency
1144
-		    $data['registration'] = $line[2];
1145
-		    $data['aircraft_icao'] = $line[0];
1146
-		    $deparr = explode('-',$line[1]);
1147
-		    if (count($deparr) === 2) {
1133
+			$data = array();
1134
+			$data['hex'] = $key; // hex
1135
+			$data['ident'] = $line[3]; // ident
1136
+			$data['altitude'] = $line[6]; // altitude
1137
+			$data['speed'] = $line[8]; // speed
1138
+			$data['heading'] = $line[7]; // heading
1139
+			$data['latitude'] = $line[4]; // lat
1140
+			$data['longitude'] = $line[5]; // long
1141
+			//$data['verticalrate'] = $line[]; // verticale rate
1142
+			$data['squawk'] = $line[10]; // squawk
1143
+			$data['emergency'] = ''; // emergency
1144
+			$data['registration'] = $line[2];
1145
+			$data['aircraft_icao'] = $line[0];
1146
+			$deparr = explode('-',$line[1]);
1147
+			if (count($deparr) === 2) {
1148 1148
 			$data['departure_airport_icao'] = $deparr[0];
1149 1149
 			$data['arrival_airport_icao'] = $deparr[1];
1150
-		    }
1151
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1152
-	    	    $data['format_source'] = 'planeupdatefaa';
1153
-    		    $data['id_source'] = $id_source;
1154
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1155
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1156
-		    $SI->add($data);
1157
-		    unset($data);
1150
+			}
1151
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1152
+				$data['format_source'] = 'planeupdatefaa';
1153
+				$data['id_source'] = $id_source;
1154
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1155
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1156
+			$SI->add($data);
1157
+			unset($data);
1158
+		}
1158 1159
 		}
1159
-	    }
1160
-	    //$last_exec['planeupdatefaa'] = time();
1161
-	    $last_exec[$id]['last'] = time();
1160
+		//$last_exec['planeupdatefaa'] = time();
1161
+		$last_exec[$id]['last'] = time();
1162 1162
 	} elseif ($value['format'] === 'opensky' && 
1163
-	    (
1163
+		(
1164 1164
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1165 1165
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1166
-	    )
1166
+		)
1167 1167
 	) {
1168
-	    $buffer = $Common->getData($value['host']);
1169
-	    $all_data = json_decode($buffer,true);
1170
-	    if (isset($all_data['states'])) {
1168
+		$buffer = $Common->getData($value['host']);
1169
+		$all_data = json_decode($buffer,true);
1170
+		if (isset($all_data['states'])) {
1171 1171
 		$reset = 0;
1172 1172
 		foreach ($all_data['states'] as $key => $line) {
1173
-		    $data = array();
1174
-		    $data['hex'] = $line[0]; // hex
1175
-		    $data['ident'] = trim($line[1]); // ident
1176
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1177
-		    $data['speed'] = round($line[9]*1.94384); // speed
1178
-		    $data['heading'] = round($line[10]); // heading
1179
-		    $data['latitude'] = $line[6]; // lat
1180
-		    $data['longitude'] = $line[5]; // long
1181
-		    $data['verticalrate'] = $line[11]; // verticale rate
1182
-		    //$data['squawk'] = $line[10]; // squawk
1183
-		    //$data['emergency'] = ''; // emergency
1184
-		    //$data['registration'] = $line[2];
1185
-		    //$data['aircraft_icao'] = $line[0];
1186
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1187
-		    $data['format_source'] = 'opensky';
1188
-		    $data['id_source'] = $id_source;
1189
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1190
-		    $SI->add($data);
1191
-		    unset($data);
1173
+			$data = array();
1174
+			$data['hex'] = $line[0]; // hex
1175
+			$data['ident'] = trim($line[1]); // ident
1176
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1177
+			$data['speed'] = round($line[9]*1.94384); // speed
1178
+			$data['heading'] = round($line[10]); // heading
1179
+			$data['latitude'] = $line[6]; // lat
1180
+			$data['longitude'] = $line[5]; // long
1181
+			$data['verticalrate'] = $line[11]; // verticale rate
1182
+			//$data['squawk'] = $line[10]; // squawk
1183
+			//$data['emergency'] = ''; // emergency
1184
+			//$data['registration'] = $line[2];
1185
+			//$data['aircraft_icao'] = $line[0];
1186
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1187
+			$data['format_source'] = 'opensky';
1188
+			$data['id_source'] = $id_source;
1189
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1190
+			$SI->add($data);
1191
+			unset($data);
1192 1192
 		}
1193
-	    }
1194
-	    //$last_exec['planeupdatefaa'] = time();
1195
-	    $last_exec[$id]['last'] = time();
1193
+		}
1194
+		//$last_exec['planeupdatefaa'] = time();
1195
+		$last_exec[$id]['last'] = time();
1196 1196
 	} elseif ($value['format'] === 'aircraftjson' && 
1197
-	    (
1197
+		(
1198 1198
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1199 1199
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1200
-	    )
1200
+		)
1201 1201
 	) {
1202
-	    $buffer = $Common->getData($value['host']);
1203
-	    $all_data = json_decode($buffer,true);
1204
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1202
+		$buffer = $Common->getData($value['host']);
1203
+		$all_data = json_decode($buffer,true);
1204
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1205 1205
 		$reset = 0;
1206 1206
 		foreach ($all_data['aircraft'] as $key => $line) {
1207
-		    $data = array();
1208
-		    // add support for ground vehicule with ~ in front of hex
1209
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1210
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1211
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1212
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1213
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1214
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1215
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1216
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1217
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1218
-		    //$data['emergency'] = ''; // emergency
1219
-		    //$data['registration'] = $line[2];
1220
-		    //$data['aircraft_icao'] = $line[0];
1221
-		    $data['datetime'] = date('Y-m-d H:i:s');
1222
-		    $data['format_source'] = 'aircraftjson';
1223
-		    $data['id_source'] = $id_source;
1224
-		    if (isset($value['name']) && $value['name'] != '') {
1225
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1226
-			    else $data['source_name'] = $value['name'];
1227
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1228
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1229
-		    $SI->add($data);
1230
-		    unset($data);
1207
+			$data = array();
1208
+			// add support for ground vehicule with ~ in front of hex
1209
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1210
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1211
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1212
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1213
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1214
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1215
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1216
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1217
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1218
+			//$data['emergency'] = ''; // emergency
1219
+			//$data['registration'] = $line[2];
1220
+			//$data['aircraft_icao'] = $line[0];
1221
+			$data['datetime'] = date('Y-m-d H:i:s');
1222
+			$data['format_source'] = 'aircraftjson';
1223
+			$data['id_source'] = $id_source;
1224
+			if (isset($value['name']) && $value['name'] != '') {
1225
+				if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1226
+				else $data['source_name'] = $value['name'];
1227
+			} elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1228
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1229
+			$SI->add($data);
1230
+			unset($data);
1231
+		}
1231 1232
 		}
1232
-	    }
1233
-	    //$last_exec['planeupdatefaa'] = time();
1234
-	    $last_exec[$id]['last'] = time();
1233
+		//$last_exec['planeupdatefaa'] = time();
1234
+		$last_exec[$id]['last'] = time();
1235 1235
 	} elseif ($value['format'] === 'planefinderclient' && 
1236
-	    (
1236
+		(
1237 1237
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1238 1238
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1239
-	    )
1239
+		)
1240 1240
 	) {
1241
-	    $buffer = $Common->getData($value['host']);
1242
-	    $all_data = json_decode($buffer,true);
1243
-	    if (isset($all_data['aircraft'])) {
1241
+		$buffer = $Common->getData($value['host']);
1242
+		$all_data = json_decode($buffer,true);
1243
+		if (isset($all_data['aircraft'])) {
1244 1244
 		$reset = 0;
1245 1245
 		foreach ($all_data['aircraft'] as $key => $line) {
1246
-		    $data = array();
1247
-		    $data['hex'] = $key; // hex
1248
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1249
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1250
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1251
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1252
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1253
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1254
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1255
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1256
-		    //$data['emergency'] = ''; // emergency
1257
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1258
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1259
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1260
-		    $data['format_source'] = 'planefinderclient';
1261
-		    $data['id_source'] = $id_source;
1262
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1263
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1264
-		    $SI->add($data);
1265
-		    unset($data);
1246
+			$data = array();
1247
+			$data['hex'] = $key; // hex
1248
+			if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1249
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1250
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1251
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1252
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1253
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1254
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1255
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1256
+			//$data['emergency'] = ''; // emergency
1257
+			if (isset($line['reg'])) $data['registration'] = $line['reg'];
1258
+			if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1259
+			$data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1260
+			$data['format_source'] = 'planefinderclient';
1261
+			$data['id_source'] = $id_source;
1262
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1263
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1264
+			$SI->add($data);
1265
+			unset($data);
1266 1266
 		}
1267
-	    }
1268
-	    $last_exec[$id]['last'] = time();
1267
+		}
1268
+		$last_exec[$id]['last'] = time();
1269 1269
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1270 1270
 	} elseif ($value['format'] === 'fr24json' && 
1271
-	    (
1271
+		(
1272 1272
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1273 1273
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1274
-	    )
1274
+		)
1275 1275
 	) {
1276
-	    //$buffer = $Common->getData($hosts[$id]);
1277
-	    $buffer = $Common->getData($value['host']);
1278
-	    $all_data = json_decode($buffer,true);
1279
-	    if (!empty($all_data)) $reset = 0;
1280
-	    foreach ($all_data as $key => $line) {
1276
+		//$buffer = $Common->getData($hosts[$id]);
1277
+		$buffer = $Common->getData($value['host']);
1278
+		$all_data = json_decode($buffer,true);
1279
+		if (!empty($all_data)) $reset = 0;
1280
+		foreach ($all_data as $key => $line) {
1281 1281
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1282
-		    $data = array();
1283
-		    $data['hex'] = $line[0];
1284
-		    $data['ident'] = $line[16]; //$line[13]
1285
-	    	    $data['altitude'] = $line[4]; // altitude
1286
-	    	    $data['speed'] = $line[5]; // speed
1287
-	    	    $data['heading'] = $line[3]; // heading
1288
-	    	    $data['latitude'] = $line[1]; // lat
1289
-	    	    $data['longitude'] = $line[2]; // long
1290
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1291
-	    	    $data['squawk'] = $line[6]; // squawk
1292
-	    	    $data['aircraft_icao'] = $line[8];
1293
-	    	    $data['registration'] = $line[9];
1294
-		    $data['departure_airport_iata'] = $line[11];
1295
-		    $data['arrival_airport_iata'] = $line[12];
1296
-	    	    $data['emergency'] = ''; // emergency
1297
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1298
-	    	    $data['format_source'] = 'fr24json';
1299
-    		    $data['id_source'] = $id_source;
1300
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1301
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1302
-		    $SI->add($data);
1303
-		    unset($data);
1282
+			$data = array();
1283
+			$data['hex'] = $line[0];
1284
+			$data['ident'] = $line[16]; //$line[13]
1285
+				$data['altitude'] = $line[4]; // altitude
1286
+				$data['speed'] = $line[5]; // speed
1287
+				$data['heading'] = $line[3]; // heading
1288
+				$data['latitude'] = $line[1]; // lat
1289
+				$data['longitude'] = $line[2]; // long
1290
+				$data['verticalrate'] = $line[15]; // verticale rate
1291
+				$data['squawk'] = $line[6]; // squawk
1292
+				$data['aircraft_icao'] = $line[8];
1293
+				$data['registration'] = $line[9];
1294
+			$data['departure_airport_iata'] = $line[11];
1295
+			$data['arrival_airport_iata'] = $line[12];
1296
+				$data['emergency'] = ''; // emergency
1297
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1298
+				$data['format_source'] = 'fr24json';
1299
+				$data['id_source'] = $id_source;
1300
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1301
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1302
+			$SI->add($data);
1303
+			unset($data);
1304 1304
 		}
1305
-	    }
1306
-	    //$last_exec['fr24json'] = time();
1307
-	    $last_exec[$id]['last'] = time();
1305
+		}
1306
+		//$last_exec['fr24json'] = time();
1307
+		$last_exec[$id]['last'] = time();
1308 1308
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1309 1309
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1310
-	    (
1310
+		(
1311 1311
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1312 1312
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1313
-	    )
1313
+		)
1314 1314
 	) {
1315
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1316
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1317
-	    //echo $buffer;
1318
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1319
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1320
-	    $all_data = json_decode($buffer,true);
1321
-	    if (json_last_error() != JSON_ERROR_NONE) {
1315
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1316
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1317
+		//echo $buffer;
1318
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1319
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1320
+		$all_data = json_decode($buffer,true);
1321
+		if (json_last_error() != JSON_ERROR_NONE) {
1322 1322
 		die(json_last_error_msg());
1323
-	    }
1324
-	    if (isset($all_data['mrkrs'])) {
1323
+		}
1324
+		if (isset($all_data['mrkrs'])) {
1325 1325
 		$reset = 0;
1326 1326
 		foreach ($all_data['mrkrs'] as $key => $line) {
1327
-		    if (isset($line['inf'])) {
1327
+			if (isset($line['inf'])) {
1328 1328
 			$data = array();
1329 1329
 			$data['hex'] = $line['inf']['ia'];
1330 1330
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1331
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1332
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1333
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1334
-	    		$data['latitude'] = $line['pt'][0]; // lat
1335
-	    		$data['longitude'] = $line['pt'][1]; // long
1336
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1337
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1338
-	    		//$data['aircraft_icao'] = $line[8];
1339
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1331
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1332
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1333
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1334
+				$data['latitude'] = $line['pt'][0]; // lat
1335
+				$data['longitude'] = $line['pt'][1]; // long
1336
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1337
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1338
+				//$data['aircraft_icao'] = $line[8];
1339
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1340 1340
 			//$data['departure_airport_iata'] = $line[11];
1341 1341
 			//$data['arrival_airport_iata'] = $line[12];
1342
-	    		//$data['emergency'] = ''; // emergency
1342
+				//$data['emergency'] = ''; // emergency
1343 1343
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1344
-	    		$data['format_source'] = 'radarvirtueljson';
1345
-    			$data['id_source'] = $id_source;
1344
+				$data['format_source'] = 'radarvirtueljson';
1345
+				$data['id_source'] = $id_source;
1346 1346
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1347 1347
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1348 1348
 			$SI->add($data);
1349 1349
 			unset($data);
1350
-		    }
1350
+			}
1351 1351
 		}
1352
-	    }
1353
-	    //$last_exec['radarvirtueljson'] = time();
1354
-	    $last_exec[$id]['last'] = time();
1352
+		}
1353
+		//$last_exec['radarvirtueljson'] = time();
1354
+		$last_exec[$id]['last'] = time();
1355 1355
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1356 1356
 	} elseif ($value['format'] === 'pirepsjson' && 
1357
-	    (
1357
+		(
1358 1358
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1359 1359
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1360
-	    )
1360
+		)
1361 1361
 	) {
1362
-	    //$buffer = $Common->getData($hosts[$id]);
1363
-	    $buffer = $Common->getData($value['host'].'?'.time());
1364
-	    $all_data = json_decode(utf8_encode($buffer),true);
1362
+		//$buffer = $Common->getData($hosts[$id]);
1363
+		$buffer = $Common->getData($value['host'].'?'.time());
1364
+		$all_data = json_decode(utf8_encode($buffer),true);
1365 1365
 	    
1366
-	    if (isset($all_data['pireps'])) {
1366
+		if (isset($all_data['pireps'])) {
1367 1367
 		$reset = 0;
1368
-	        foreach ($all_data['pireps'] as $line) {
1369
-		    $data = array();
1370
-		    $data['id'] = $line['id'];
1371
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1372
-		    $data['ident'] = $line['callsign']; // ident
1373
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1374
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1375
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1376
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1377
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1378
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1379
-		    $data['latitude'] = $line['lat']; // lat
1380
-		    $data['longitude'] = $line['lon']; // long
1381
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1382
-		    //$data['squawk'] = $line['squawk']; // squawk
1383
-		    //$data['emergency'] = ''; // emergency
1384
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1385
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1386
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1387
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1388
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1389
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1390
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1391
-		    else $data['info'] = '';
1392
-		    $data['format_source'] = 'pireps';
1393
-    		    $data['id_source'] = $id_source;
1394
-		    $data['datetime'] = date('Y-m-d H:i:s');
1395
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1396
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1397
-		    if ($line['icon'] === 'plane') {
1368
+			foreach ($all_data['pireps'] as $line) {
1369
+			$data = array();
1370
+			$data['id'] = $line['id'];
1371
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1372
+			$data['ident'] = $line['callsign']; // ident
1373
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1374
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1375
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1376
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1377
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1378
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1379
+			$data['latitude'] = $line['lat']; // lat
1380
+			$data['longitude'] = $line['lon']; // long
1381
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1382
+			//$data['squawk'] = $line['squawk']; // squawk
1383
+			//$data['emergency'] = ''; // emergency
1384
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1385
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1386
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1387
+			//$data['arrival_airport_time'] = $line['arrtime'];
1388
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1389
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1390
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1391
+			else $data['info'] = '';
1392
+			$data['format_source'] = 'pireps';
1393
+				$data['id_source'] = $id_source;
1394
+			$data['datetime'] = date('Y-m-d H:i:s');
1395
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1396
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1397
+			if ($line['icon'] === 'plane') {
1398 1398
 			$SI->add($data);
1399
-		    //    print_r($data);
1400
-    		    } elseif ($line['icon'] === 'ct') {
1399
+			//    print_r($data);
1400
+				} elseif ($line['icon'] === 'ct') {
1401 1401
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1402 1402
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1403 1403
 			$typec = substr($data['ident'],-3);
@@ -1412,209 +1412,209 @@  discard block
 block discarded – undo
1412 1412
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1413 1413
 			else $data['type'] = 'Observer';
1414 1414
 			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']);
1415
-		    }
1416
-		    unset($data);
1415
+			}
1416
+			unset($data);
1417 1417
 		}
1418
-	    }
1419
-	    //$last_exec['pirepsjson'] = time();
1420
-	    $last_exec[$id]['last'] = time();
1418
+		}
1419
+		//$last_exec['pirepsjson'] = time();
1420
+		$last_exec[$id]['last'] = time();
1421 1421
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1422 1422
 	} elseif ($value['format'] === 'phpvmacars' && 
1423
-	    (
1423
+		(
1424 1424
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1425 1425
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1426
-	    )
1426
+		)
1427 1427
 	) {
1428
-	    //$buffer = $Common->getData($hosts[$id]);
1429
-	    if ($globalDebug) echo 'Get Data...'."\n";
1430
-	    $buffer = $Common->getData($value['host']);
1431
-	    $all_data = json_decode($buffer,true);
1432
-	    if ($buffer != '' && is_array($all_data)) {
1428
+		//$buffer = $Common->getData($hosts[$id]);
1429
+		if ($globalDebug) echo 'Get Data...'."\n";
1430
+		$buffer = $Common->getData($value['host']);
1431
+		$all_data = json_decode($buffer,true);
1432
+		if ($buffer != '' && is_array($all_data)) {
1433 1433
 		$reset = 0;
1434 1434
 		foreach ($all_data as $line) {
1435
-	    	    $data = array();
1436
-	    	    //$data['id'] = $line['id']; // id not usable
1437
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1438
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1439
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1440
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1441
-	    	    $data['ident'] = $line['flightnum']; // ident
1442
-	    	    $data['altitude'] = $line['alt']; // altitude
1443
-	    	    $data['speed'] = $line['gs']; // speed
1444
-	    	    $data['heading'] = $line['heading']; // heading
1445
-	    	    $data['latitude'] = $line['lat']; // lat
1446
-	    	    $data['longitude'] = $line['lng']; // long
1447
-	    	    $data['verticalrate'] = ''; // verticale rate
1448
-	    	    $data['squawk'] = ''; // squawk
1449
-	    	    $data['emergency'] = ''; // emergency
1450
-	    	    //$data['datetime'] = $line['lastupdate'];
1451
-	    	    //$data['last_update'] = $line['lastupdate'];
1452
-	    	    if (isset($value['timezone'])) {
1453
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1454
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1455
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1456
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1457
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1458
-	    	    $data['departure_airport_time'] = $line['deptime'];
1459
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1460
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1461
-    		    if (isset($line['registration'])) {
1462
-    			$data['registration'] = $line['registration'];
1463
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1464
-    		    } else $data['registration'] = $line['aircraft'];
1465
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1466
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1467
-		    if (isset($line['aircraftname'])) {
1435
+				$data = array();
1436
+				//$data['id'] = $line['id']; // id not usable
1437
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1438
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1439
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1440
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1441
+				$data['ident'] = $line['flightnum']; // ident
1442
+				$data['altitude'] = $line['alt']; // altitude
1443
+				$data['speed'] = $line['gs']; // speed
1444
+				$data['heading'] = $line['heading']; // heading
1445
+				$data['latitude'] = $line['lat']; // lat
1446
+				$data['longitude'] = $line['lng']; // long
1447
+				$data['verticalrate'] = ''; // verticale rate
1448
+				$data['squawk'] = ''; // squawk
1449
+				$data['emergency'] = ''; // emergency
1450
+				//$data['datetime'] = $line['lastupdate'];
1451
+				//$data['last_update'] = $line['lastupdate'];
1452
+				if (isset($value['timezone'])) {
1453
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1454
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1455
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1456
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1457
+				$data['departure_airport_icao'] = $line['depicao'];
1458
+				$data['departure_airport_time'] = $line['deptime'];
1459
+				$data['arrival_airport_icao'] = $line['arricao'];
1460
+				$data['arrival_airport_time'] = $line['arrtime'];
1461
+				if (isset($line['registration'])) {
1462
+				$data['registration'] = $line['registration'];
1463
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1464
+				} else $data['registration'] = $line['aircraft'];
1465
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1466
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1467
+			if (isset($line['aircraftname'])) {
1468 1468
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1469 1469
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1470
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1471
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1472
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1473
-	    		else {
1474
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1475
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1476
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1477
-	    		}
1478
-	    	    }
1479
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1480
-    		    $data['id_source'] = $id_source;
1481
-	    	    $data['format_source'] = 'phpvmacars';
1482
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1483
-		    $SI->add($data);
1484
-		    unset($data);
1470
+				$aircraft_data = explode('-',$line['aircraftname']);
1471
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1472
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1473
+				else {
1474
+					$aircraft_data = explode(' ',$line['aircraftname']);
1475
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1476
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1477
+				}
1478
+				}
1479
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1480
+				$data['id_source'] = $id_source;
1481
+				$data['format_source'] = 'phpvmacars';
1482
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1483
+			$SI->add($data);
1484
+			unset($data);
1485 1485
 		}
1486 1486
 		if ($globalDebug) echo 'No more data...'."\n";
1487 1487
 		unset($buffer);
1488 1488
 		unset($all_data);
1489
-	    }
1490
-	    //$last_exec['phpvmacars'] = time();
1491
-	    $last_exec[$id]['last'] = time();
1489
+		}
1490
+		//$last_exec['phpvmacars'] = time();
1491
+		$last_exec[$id]['last'] = time();
1492 1492
 	} elseif ($value['format'] === 'vaos' && 
1493
-	    (
1493
+		(
1494 1494
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1495 1495
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1496
-	    )
1496
+		)
1497 1497
 	) {
1498
-	    //$buffer = $Common->getData($hosts[$id]);
1499
-	    if ($globalDebug) echo 'Get Data...'."\n";
1500
-	    $buffer = $Common->getData($value['host']);
1501
-	    $all_data = json_decode($buffer,true);
1502
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1498
+		//$buffer = $Common->getData($hosts[$id]);
1499
+		if ($globalDebug) echo 'Get Data...'."\n";
1500
+		$buffer = $Common->getData($value['host']);
1501
+		$all_data = json_decode($buffer,true);
1502
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1503 1503
 		$reset = 0;
1504 1504
 		foreach ($all_data['ACARSData'] as $line) {
1505
-		    //print_r($line);
1506
-	    	    $data = array();
1507
-	    	    //$data['id'] = $line['id']; // id not usable
1508
-	    	    $data['id'] = $line['id'];
1509
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1510
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1511
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1512
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1513
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1514
-	    	    $data['altitude'] = $line['altitude']; // altitude
1515
-	    	    $data['speed'] = $line['groundspeed']; // speed
1516
-	    	    $data['heading'] = $line['heading']; // heading
1517
-	    	    $data['latitude'] = $line['lat']; // lat
1518
-	    	    $data['longitude'] = $line['lon']; // long
1519
-	    	    //$data['verticalrate'] = ''; // verticale rate
1520
-	    	    //$data['squawk'] = ''; // squawk
1521
-	    	    //$data['emergency'] = ''; // emergency
1522
-	    	    if (isset($value['timezone'])) {
1523
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1524
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1525
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1526
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1505
+			//print_r($line);
1506
+				$data = array();
1507
+				//$data['id'] = $line['id']; // id not usable
1508
+				$data['id'] = $line['id'];
1509
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1510
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1511
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1512
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1513
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1514
+				$data['altitude'] = $line['altitude']; // altitude
1515
+				$data['speed'] = $line['groundspeed']; // speed
1516
+				$data['heading'] = $line['heading']; // heading
1517
+				$data['latitude'] = $line['lat']; // lat
1518
+				$data['longitude'] = $line['lon']; // long
1519
+				//$data['verticalrate'] = ''; // verticale rate
1520
+				//$data['squawk'] = ''; // squawk
1521
+				//$data['emergency'] = ''; // emergency
1522
+				if (isset($value['timezone'])) {
1523
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1524
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1525
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1526
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1527 1527
 	    	    
1528
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1529
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1530
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1531
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1532
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1528
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1529
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1530
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1531
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1532
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1533 1533
 
1534
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1535
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1536
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1534
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1535
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1536
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1537 1537
 
1538
-    		    $data['id_source'] = $id_source;
1539
-	    	    $data['format_source'] = 'vaos';
1540
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1541
-		    $SI->add($data);
1542
-		    unset($data);
1538
+				$data['id_source'] = $id_source;
1539
+				$data['format_source'] = 'vaos';
1540
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1541
+			$SI->add($data);
1542
+			unset($data);
1543 1543
 		}
1544 1544
 		if ($globalDebug) echo 'No more data...'."\n";
1545 1545
 		unset($buffer);
1546 1546
 		unset($all_data);
1547
-	    }
1548
-	    //$last_exec['phpvmacars'] = time();
1549
-	    $last_exec[$id]['last'] = time();
1547
+		}
1548
+		//$last_exec['phpvmacars'] = time();
1549
+		$last_exec[$id]['last'] = time();
1550 1550
 	} elseif ($value['format'] === 'vam' && 
1551
-	    (
1551
+		(
1552 1552
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1553 1553
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1554
-	    )
1554
+		)
1555 1555
 	) {
1556
-	    //$buffer = $Common->getData($hosts[$id]);
1557
-	    if ($globalDebug) echo 'Get Data...'."\n";
1558
-	    $buffer = $Common->getData($value['host']);
1559
-	    $all_data = json_decode($buffer,true);
1560
-	    if ($buffer != '' && is_array($all_data)) {
1556
+		//$buffer = $Common->getData($hosts[$id]);
1557
+		if ($globalDebug) echo 'Get Data...'."\n";
1558
+		$buffer = $Common->getData($value['host']);
1559
+		$all_data = json_decode($buffer,true);
1560
+		if ($buffer != '' && is_array($all_data)) {
1561 1561
 		$reset = 0;
1562 1562
 		foreach ($all_data as $line) {
1563
-	    	    $data = array();
1564
-	    	    //$data['id'] = $line['id']; // id not usable
1565
-	    	    $data['id'] = trim($line['flight_id']);
1566
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1567
-	    	    $data['pilot_name'] = $line['pilot_name'];
1568
-	    	    $data['pilot_id'] = $line['pilot_id'];
1569
-	    	    $data['ident'] = trim($line['callsign']); // ident
1570
-	    	    $data['altitude'] = $line['altitude']; // altitude
1571
-	    	    $data['speed'] = $line['gs']; // speed
1572
-	    	    $data['heading'] = $line['heading']; // heading
1573
-	    	    $data['latitude'] = $line['latitude']; // lat
1574
-	    	    $data['longitude'] = $line['longitude']; // long
1575
-	    	    $data['verticalrate'] = ''; // verticale rate
1576
-	    	    $data['squawk'] = ''; // squawk
1577
-	    	    $data['emergency'] = ''; // emergency
1578
-	    	    //$data['datetime'] = $line['lastupdate'];
1579
-	    	    $data['last_update'] = $line['last_update'];
1580
-		    $data['datetime'] = date('Y-m-d H:i:s');
1581
-	    	    $data['departure_airport_icao'] = $line['departure'];
1582
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1583
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1584
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1585
-    		    //$data['registration'] = $line['aircraft'];
1586
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1587
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1588
-    		    $data['id_source'] = $id_source;
1589
-	    	    $data['format_source'] = 'vam';
1590
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1591
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1592
-		    $SI->add($data);
1593
-		    unset($data);
1563
+				$data = array();
1564
+				//$data['id'] = $line['id']; // id not usable
1565
+				$data['id'] = trim($line['flight_id']);
1566
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1567
+				$data['pilot_name'] = $line['pilot_name'];
1568
+				$data['pilot_id'] = $line['pilot_id'];
1569
+				$data['ident'] = trim($line['callsign']); // ident
1570
+				$data['altitude'] = $line['altitude']; // altitude
1571
+				$data['speed'] = $line['gs']; // speed
1572
+				$data['heading'] = $line['heading']; // heading
1573
+				$data['latitude'] = $line['latitude']; // lat
1574
+				$data['longitude'] = $line['longitude']; // long
1575
+				$data['verticalrate'] = ''; // verticale rate
1576
+				$data['squawk'] = ''; // squawk
1577
+				$data['emergency'] = ''; // emergency
1578
+				//$data['datetime'] = $line['lastupdate'];
1579
+				$data['last_update'] = $line['last_update'];
1580
+			$data['datetime'] = date('Y-m-d H:i:s');
1581
+				$data['departure_airport_icao'] = $line['departure'];
1582
+				//$data['departure_airport_time'] = $line['departure_time'];
1583
+				$data['arrival_airport_icao'] = $line['arrival'];
1584
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1585
+				//$data['registration'] = $line['aircraft'];
1586
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1587
+				$data['aircraft_icao'] = $line['plane_type'];
1588
+				$data['id_source'] = $id_source;
1589
+				$data['format_source'] = 'vam';
1590
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1591
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1592
+			$SI->add($data);
1593
+			unset($data);
1594 1594
 		}
1595 1595
 		if ($globalDebug) echo 'No more data...'."\n";
1596 1596
 		unset($buffer);
1597 1597
 		unset($all_data);
1598
-	    }
1599
-	    //$last_exec['phpvmacars'] = time();
1600
-	    $last_exec[$id]['last'] = time();
1598
+		}
1599
+		//$last_exec['phpvmacars'] = time();
1600
+		$last_exec[$id]['last'] = time();
1601 1601
 	} elseif ($value['format'] === 'blitzortung' && 
1602
-	    (
1602
+		(
1603 1603
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1604 1604
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1605
-	    )
1605
+		)
1606 1606
 	) {
1607
-	    //$buffer = $Common->getData($hosts[$id]);
1608
-	    if ($globalDebug) echo 'Get Data...'."\n";
1609
-	    $buffer = $Common->getData($value['host']);
1610
-	    $all_data = json_decode($buffer,true);
1611
-	    if ($buffer != '') {
1607
+		//$buffer = $Common->getData($hosts[$id]);
1608
+		if ($globalDebug) echo 'Get Data...'."\n";
1609
+		$buffer = $Common->getData($value['host']);
1610
+		$all_data = json_decode($buffer,true);
1611
+		if ($buffer != '') {
1612 1612
 		$Source->deleteLocationBySource('blitzortung');
1613 1613
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1614 1614
 		$buffer = explode('\n',$buffer);
1615 1615
 		foreach ($buffer as $buffer_line) {
1616
-		    $line = json_decode($buffer_line,true);
1617
-		    if (isset($line['time'])) {
1616
+			$line = json_decode($buffer_line,true);
1617
+			if (isset($line['time'])) {
1618 1618
 			$data = array();
1619 1619
 			$data['altitude'] = $line['alt']; // altitude
1620 1620
 			$data['latitude'] = $line['lat']; // lat
@@ -1626,92 +1626,92 @@  discard block
 block discarded – undo
1626 1626
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1627 1627
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1628 1628
 			unset($data);
1629
-		    }
1629
+			}
1630 1630
 		}
1631 1631
 		if ($globalDebug) echo 'No more data...'."\n";
1632 1632
 		unset($buffer);
1633
-	    }
1634
-	    $last_exec[$id]['last'] = time();
1633
+		}
1634
+		$last_exec[$id]['last'] = time();
1635 1635
 	} elseif ($value['format'] === 'acarsjson') {
1636
-        $arr = $httpfeeds;
1637
-        $w = $e = null;
1638
-        if (isset($arr[$id])) {
1639
-            $nn = stream_select($arr,$w,$e,$timeout);
1640
-            if ($nn > 0) {
1641
-                foreach ($httpfeeds as $feed) {
1642
-                    $buffer = stream_get_line($feed,2000,"\n");
1643
-                    if ($buffer === FALSE) {
1644
-                        connect_all($globalSources);
1645
-                    }
1646
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1647
-                    $buffer = explode('\n',$buffer);
1648
-                    foreach ($buffer as $line) {
1649
-                        if ($line != '') {
1650
-                            $line = json_decode($line, true);
1651
-                            if (!empty($line)) {
1652
-                                $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1653
-                                $ACARS->deleteLiveAcarsData();
1654
-                            }
1655
-                        }
1656
-                    }
1657
-                }
1658
-            } else {
1659
-                $format = $value['format'];
1660
-                if (isset($tt[$format])) $tt[$format]++;
1661
-                else $tt[$format] = 0;
1662
-                if ($tt[$format] > 30) {
1663
-                    if ($globalDebug) echo 'Reconnect...'."\n";
1664
-                    sleep(2);
1665
-                    //$sourceeen[] = $value;
1666
-                    //connect_all($sourceeen);
1667
-                    //$sourceeen = array();
1668
-                    connect_all($globalSources);
1669
-                }
1670
-            }
1671
-        }
1636
+		$arr = $httpfeeds;
1637
+		$w = $e = null;
1638
+		if (isset($arr[$id])) {
1639
+			$nn = stream_select($arr,$w,$e,$timeout);
1640
+			if ($nn > 0) {
1641
+				foreach ($httpfeeds as $feed) {
1642
+					$buffer = stream_get_line($feed,2000,"\n");
1643
+					if ($buffer === FALSE) {
1644
+						connect_all($globalSources);
1645
+					}
1646
+					$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1647
+					$buffer = explode('\n',$buffer);
1648
+					foreach ($buffer as $line) {
1649
+						if ($line != '') {
1650
+							$line = json_decode($line, true);
1651
+							if (!empty($line)) {
1652
+								$ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1653
+								$ACARS->deleteLiveAcarsData();
1654
+							}
1655
+						}
1656
+					}
1657
+				}
1658
+			} else {
1659
+				$format = $value['format'];
1660
+				if (isset($tt[$format])) $tt[$format]++;
1661
+				else $tt[$format] = 0;
1662
+				if ($tt[$format] > 30) {
1663
+					if ($globalDebug) echo 'Reconnect...'."\n";
1664
+					sleep(2);
1665
+					//$sourceeen[] = $value;
1666
+					//connect_all($sourceeen);
1667
+					//$sourceeen = array();
1668
+					connect_all($globalSources);
1669
+				}
1670
+			}
1671
+		}
1672 1672
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1673 1673
 	} elseif ($value['format'] === 'sbs' || $value['format'] === 'tsv' || $value['format'] === 'raw' || $value['format'] === 'aprs' || $value['format'] === 'famaprs' || $value['format'] === 'beast' || $value['format'] === 'flightgearmp' || $value['format'] === 'flightgearsp' || $value['format'] === 'acars' || $value['format'] === 'acarsjsonudp' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') {
1674
-	    //$last_exec[$id]['last'] = time();
1675
-	    //$read = array( $sockets[$id] );
1676
-	    $read = $sockets;
1677
-	    $write = NULL;
1678
-	    $e = NULL;
1679
-	    $n = socket_select($read, $write, $e, $timeout);
1680
-	    if ($e != NULL) var_dump($e);
1681
-	    if ($n > 0) {
1674
+		//$last_exec[$id]['last'] = time();
1675
+		//$read = array( $sockets[$id] );
1676
+		$read = $sockets;
1677
+		$write = NULL;
1678
+		$e = NULL;
1679
+		$n = socket_select($read, $write, $e, $timeout);
1680
+		if ($e != NULL) var_dump($e);
1681
+		if ($n > 0) {
1682 1682
 		$reset = 0;
1683 1683
 		foreach ($read as $nb => $r) {
1684
-		    //$value = $formats[$nb];
1685
-		    $format = $globalSources[$nb]['format'];
1686
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1684
+			//$value = $formats[$nb];
1685
+			$format = $globalSources[$nb]['format'];
1686
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1687 1687
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1688
-		    } elseif ($format === 'vrstcp') {
1688
+			} elseif ($format === 'vrstcp') {
1689 1689
 			$buffer = @socket_read($r, 6000);
1690
-		    } else {
1690
+			} else {
1691 1691
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1692
-		    }
1693
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1694
-		    //echo $buffer."\n";
1695
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1696
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1697
-		    $error = false;
1698
-		    //$SI::del();
1699
-		    if ($buffer !== FALSE) {
1692
+			}
1693
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1694
+			//echo $buffer."\n";
1695
+			// lets play nice and handle signals such as ctrl-c/kill properly
1696
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1697
+			$error = false;
1698
+			//$SI::del();
1699
+			if ($buffer !== FALSE) {
1700 1700
 			if ($format === 'vrstcp') {
1701
-			    $buffer = explode('},{',$buffer);
1701
+				$buffer = explode('},{',$buffer);
1702 1702
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1703
-		    }
1704
-		    // SBS format is CSV format
1705
-		    if ($buffer !== FALSE && $buffer !== '') {
1703
+			}
1704
+			// SBS format is CSV format
1705
+			if ($buffer !== FALSE && $buffer !== '') {
1706 1706
 			$tt[$format] = 0;
1707 1707
 			if ($format === 'acarssbs3') {
1708
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1709
-			    $ACARS->add(trim($buffer));
1710
-			    $ACARS->deleteLiveAcarsData();
1708
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1709
+				$ACARS->add(trim($buffer));
1710
+				$ACARS->deleteLiveAcarsData();
1711 1711
 			} elseif ($format === 'raw') {
1712
-			    // AVR format
1713
-			    $data = $SBS->parse($buffer);
1714
-			    if (is_array($data)) {
1712
+				// AVR format
1713
+				$data = $SBS->parse($buffer);
1714
+				if (is_array($data)) {
1715 1715
 				//if (!empty($data)) print_r($data);
1716 1716
 				$data['datetime'] = date('Y-m-d H:i:s');
1717 1717
 				$data['format_source'] = 'raw';
@@ -1721,39 +1721,39 @@  discard block
 block discarded – undo
1721 1721
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1722 1722
 				$SI->add($data);
1723 1723
 				unset($data);
1724
-			    }
1724
+				}
1725 1725
 			} elseif ($format === 'ais') {
1726
-			    $ais_data = $AIS->parse_line(trim($buffer));
1727
-			    $data = array();
1728
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1729
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1730
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1731
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1732
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1733
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1734
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1735
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1736
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1737
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1738
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1739
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1740
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1741
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1742
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1743
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1726
+				$ais_data = $AIS->parse_line(trim($buffer));
1727
+				$data = array();
1728
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1729
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1730
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1731
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1732
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1733
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1734
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1735
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1736
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1737
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1738
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1739
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1740
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1741
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1742
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1743
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1744 1744
 
1745
-			    if (isset($ais_data['timestamp'])) {
1745
+				if (isset($ais_data['timestamp'])) {
1746 1746
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1747
-			    } else {
1747
+				} else {
1748 1748
 				$data['datetime'] = date('Y-m-d H:i:s');
1749
-			    }
1750
-			    $data['format_source'] = 'aisnmea';
1751
-    			    $data['id_source'] = $id_source;
1752
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1753
-			    unset($data);
1754
-                        } elseif ($format === 'flightgearsp') {
1755
-                    	    //echo $buffer."\n";
1756
-                    	    if (strlen($buffer) > 5) {
1749
+				}
1750
+				$data['format_source'] = 'aisnmea';
1751
+					$data['id_source'] = $id_source;
1752
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1753
+				unset($data);
1754
+						} elseif ($format === 'flightgearsp') {
1755
+							//echo $buffer."\n";
1756
+							if (strlen($buffer) > 5) {
1757 1757
 				$line = explode(',',$buffer);
1758 1758
 				$data = array();
1759 1759
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1770,46 +1770,46 @@  discard block
 block discarded – undo
1770 1770
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1771 1771
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1772 1772
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1773
-			    }
1774
-                        } elseif ($format === 'acars') {
1775
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1776
-			    $ACARS->add(trim($buffer));
1777
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1778
-			    $ACARS->deleteLiveAcarsData();
1773
+				}
1774
+						} elseif ($format === 'acars') {
1775
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1776
+				$ACARS->add(trim($buffer));
1777
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1778
+				$ACARS->deleteLiveAcarsData();
1779 1779
 			} elseif ($format === 'acarsjsonudp') {
1780
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1781
-                            $line = json_decode(trim($buffer), true);
1782
-                            if (!empty($line)) {
1783
-                                $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1784
-                                $ACARS->deleteLiveAcarsData();
1785
-                            }
1786
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1780
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1781
+							$line = json_decode(trim($buffer), true);
1782
+							if (!empty($line)) {
1783
+								$ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1784
+								$ACARS->deleteLiveAcarsData();
1785
+							}
1786
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1787 1787
 			} elseif ($format === 'flightgearmp') {
1788
-			    if (substr($buffer,0,1) != '#') {
1788
+				if (substr($buffer,0,1) != '#') {
1789 1789
 				$data = array();
1790 1790
 				//echo $buffer."\n";
1791 1791
 				$line = explode(' ',$buffer);
1792 1792
 				if (count($line) === 11) {
1793
-				    $userserver = explode('@',$line[0]);
1794
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1795
-				    $data['ident'] = $userserver[0];
1796
-				    $data['registration'] = $userserver[0];
1797
-				    $data['latitude'] = $line[4];
1798
-				    $data['longitude'] = $line[5];
1799
-				    $data['altitude'] = $line[6];
1800
-				    $data['datetime'] = date('Y-m-d H:i:s');
1801
-				    $aircraft_type = $line[10];
1802
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1803
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1804
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1805
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1793
+					$userserver = explode('@',$line[0]);
1794
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1795
+					$data['ident'] = $userserver[0];
1796
+					$data['registration'] = $userserver[0];
1797
+					$data['latitude'] = $line[4];
1798
+					$data['longitude'] = $line[5];
1799
+					$data['altitude'] = $line[6];
1800
+					$data['datetime'] = date('Y-m-d H:i:s');
1801
+					$aircraft_type = $line[10];
1802
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1803
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1804
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1805
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1806
+				}
1806 1807
 				}
1807
-			    }
1808 1808
 			} elseif ($format === 'beast') {
1809
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1810
-			    die;
1809
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1810
+				die;
1811 1811
 			} elseif ($format === 'vrstcp') {
1812
-			    foreach($buffer as $all_data) {
1812
+				foreach($buffer as $all_data) {
1813 1813
 				$line = json_decode('{'.$all_data.'}',true);
1814 1814
 				$data = array();
1815 1815
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1829,158 +1829,158 @@  discard block
 block discarded – undo
1829 1829
 				*/
1830 1830
 				$data['datetime'] = date('Y-m-d H:i:s');
1831 1831
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1832
-		    		$data['format_source'] = 'vrstcp';
1832
+					$data['format_source'] = 'vrstcp';
1833 1833
 				$data['id_source'] = $id_source;
1834 1834
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1835 1835
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1836 1836
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1837 1837
 				unset($data);
1838
-			    }
1838
+				}
1839 1839
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1840
-			    $line = explode("\t", $buffer);
1841
-			    for($k = 0; $k < count($line); $k=$k+2) {
1840
+				$line = explode("\t", $buffer);
1841
+				for($k = 0; $k < count($line); $k=$k+2) {
1842 1842
 				$key = $line[$k];
1843
-			        $lined[$key] = $line[$k+1];
1844
-			    }
1845
-    			    if (count($lined) > 3) {
1846
-    				$data['hex'] = $lined['hexid'];
1847
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1848
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1849
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1850
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1851
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1852
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1853
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1854
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1855
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1856
-    				$data['id_source'] = $id_source;
1857
-    				$data['format_source'] = 'tsv';
1858
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1859
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1843
+					$lined[$key] = $line[$k+1];
1844
+				}
1845
+					if (count($lined) > 3) {
1846
+					$data['hex'] = $lined['hexid'];
1847
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1848
+					$data['datetime'] = date('Y-m-d H:i:s');;
1849
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1850
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1851
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1852
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1853
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1854
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1855
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1856
+					$data['id_source'] = $id_source;
1857
+					$data['format_source'] = 'tsv';
1858
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1859
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1860 1860
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1861
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1862
-    				unset($lined);
1863
-    				unset($data);
1864
-    			    } else $error = true;
1861
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1862
+					unset($lined);
1863
+					unset($data);
1864
+					} else $error = true;
1865 1865
 			} elseif ($format === 'aprs' && $use_aprs) {
1866
-			    if ($aprs_connect === 0) {
1866
+				if ($aprs_connect === 0) {
1867 1867
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1868 1868
 				$aprs_connect = 1;
1869
-			    }
1869
+				}
1870 1870
 			    
1871
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1871
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1872 1872
 				$aprs_last_tx = time();
1873 1873
 				$data_aprs = "# Keep alive";
1874 1874
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1875
-			    }
1875
+				}
1876 1876
 			    
1877
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1878
-			    //echo 'APRS data : '.$buffer."\n";
1879
-			    $buffer = str_replace('APRS <- ','',$buffer);
1880
-			    $buffer = str_replace('APRS -> ','',$buffer);
1881
-			    //echo $buffer."\n";
1882
-			    date_default_timezone_set('UTC');
1883
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1877
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1878
+				//echo 'APRS data : '.$buffer."\n";
1879
+				$buffer = str_replace('APRS <- ','',$buffer);
1880
+				$buffer = str_replace('APRS -> ','',$buffer);
1881
+				//echo $buffer."\n";
1882
+				date_default_timezone_set('UTC');
1883
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1884 1884
 				$line = $APRS->parse($buffer);
1885 1885
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1886 1886
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1887
-				    $aprs_last_tx = time();
1888
-				    $data = array();
1889
-				    //print_r($line);
1890
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1891
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1892
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1893
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1894
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1895
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1896
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1897
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1898
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1899
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1900
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1901
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1902
-				    $data['latitude'] = $line['latitude'];
1903
-				    $data['longitude'] = $line['longitude'];
1904
-				    //$data['verticalrate'] = $line[16];
1905
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1906
-				    //else $data['speed'] = 0;
1907
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1908
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1909
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1910
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1887
+					$aprs_last_tx = time();
1888
+					$data = array();
1889
+					//print_r($line);
1890
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1891
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1892
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1893
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1894
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1895
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1896
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1897
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1898
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1899
+					else $data['datetime'] = date('Y-m-d H:i:s');
1900
+					//$data['datetime'] = date('Y-m-d H:i:s');
1901
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1902
+					$data['latitude'] = $line['latitude'];
1903
+					$data['longitude'] = $line['longitude'];
1904
+					//$data['verticalrate'] = $line[16];
1905
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1906
+					//else $data['speed'] = 0;
1907
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1908
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1909
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1910
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1911 1911
 				    
1912
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1913
-				    //else echo 'No heading...'."\n";
1914
-				    //else $data['heading'] = 0;
1915
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1916
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1917
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1918
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1919
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1920
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1921
-    				    $data['id_source'] = $id_source;
1922
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1923
-				    else $data['format_source'] = 'aprs';
1924
-				    $data['source_name'] = $line['source'];
1925
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1926
-				    else $data['source_type'] = 'flarm';
1927
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1928
-				    $currentdate = date('Y-m-d H:i:s');
1929
-				    $aprsdate = strtotime($data['datetime']);
1930
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1931
-				    // Accept data if time <= system time + 20s
1932
-				    //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'])))) {
1933
-				    if (
1912
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1913
+					//else echo 'No heading...'."\n";
1914
+					//else $data['heading'] = 0;
1915
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1916
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1917
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1918
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1919
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1920
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1921
+						$data['id_source'] = $id_source;
1922
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1923
+					else $data['format_source'] = 'aprs';
1924
+					$data['source_name'] = $line['source'];
1925
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1926
+					else $data['source_type'] = 'flarm';
1927
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1928
+					$currentdate = date('Y-m-d H:i:s');
1929
+					$aprsdate = strtotime($data['datetime']);
1930
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1931
+					// Accept data if time <= system time + 20s
1932
+					//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'])))) {
1933
+					if (
1934 1934
 					($data['source_type'] === 'modes') || 
1935 1935
 					isset($line['stealth']) && 
1936 1936
 					(!isset($data['hex']) || $data['hex'] != 'FFFFFF') && 
1937 1937
 					 ($line['stealth'] === 0 || $line['stealth'] == '') && 
1938 1938
 					 (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1939 1939
 					$send = $SI->add($data);
1940
-				    } elseif ($data['source_type'] === 'ais') {
1940
+					} elseif ($data['source_type'] === 'ais') {
1941 1941
 					$data['type'] = '';
1942 1942
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1943
-				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1943
+					} elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1944 1944
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1945
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1946
-					    //$line['symbol'] === 'Balloon' ||
1947
-					    $line['symbol'] === 'Glider' || 
1948
-					    $line['symbol'] === 'No. Plane' || 
1949
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1950
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1951
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1952
-					    $send = $SI->add($data);
1953
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1954
-					    $line['symbol'] === 'Yacht (Sail)' || 
1955
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1956
-					    $send = $MI->add($data);
1957
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1958
-					    $line['symbol'] === 'Car' || 
1959
-					    $line['symbol'] === 'Ambulance' || 
1960
-					    $line['symbol'] === 'Van' || 
1961
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1962
-					    $line['symbol'] === 'Motorcycle' || 
1963
-					    $line['symbol'] === 'Tractor' || 
1964
-					    $line['symbol'] === 'Police' || 
1965
-					    $line['symbol'] === 'Bike' || 
1966
-					    $line['symbol'] === 'Jogger' || 
1967
-					    $line['symbol'] === 'Horse' || 
1968
-					    $line['symbol'] === 'Bus' || 
1969
-					    $line['symbol'] === 'Jeep' || 
1970
-					    $line['symbol'] === 'Recreational Vehicle' || 
1971
-					    $line['symbol'] === 'Yacht (Sail)' || 
1972
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1973
-					    $line['symbol'] === 'Firetruck' || 
1974
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1975
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1976
-					    $line['symbol'] === 'SUV' ||
1977
-					    $line['symbol'] === 'Snowmobile' ||
1978
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1979
-				    //} 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') {
1945
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1946
+						//$line['symbol'] === 'Balloon' ||
1947
+						$line['symbol'] === 'Glider' || 
1948
+						$line['symbol'] === 'No. Plane' || 
1949
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1950
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1951
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1952
+						$send = $SI->add($data);
1953
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1954
+						$line['symbol'] === 'Yacht (Sail)' || 
1955
+						$line['symbol'] === 'Ship (Power Boat)')) {
1956
+						$send = $MI->add($data);
1957
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1958
+						$line['symbol'] === 'Car' || 
1959
+						$line['symbol'] === 'Ambulance' || 
1960
+						$line['symbol'] === 'Van' || 
1961
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1962
+						$line['symbol'] === 'Motorcycle' || 
1963
+						$line['symbol'] === 'Tractor' || 
1964
+						$line['symbol'] === 'Police' || 
1965
+						$line['symbol'] === 'Bike' || 
1966
+						$line['symbol'] === 'Jogger' || 
1967
+						$line['symbol'] === 'Horse' || 
1968
+						$line['symbol'] === 'Bus' || 
1969
+						$line['symbol'] === 'Jeep' || 
1970
+						$line['symbol'] === 'Recreational Vehicle' || 
1971
+						$line['symbol'] === 'Yacht (Sail)' || 
1972
+						$line['symbol'] === 'Ship (Power Boat)' || 
1973
+						$line['symbol'] === 'Firetruck' || 
1974
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1975
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1976
+						$line['symbol'] === 'SUV' ||
1977
+						$line['symbol'] === 'Snowmobile' ||
1978
+						$line['symbol'] === 'Mobile Satellite Station')) {
1979
+					//} 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') {
1980 1980
 				//    } 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') {
1981 1981
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1982 1982
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1983
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1983
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1984 1984
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1985 1985
 					$Source->deleteOldLocationByType('gs');
1986 1986
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1988,7 +1988,7 @@  discard block
 block discarded – undo
1988 1988
 					} else {
1989 1989
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1990 1990
 					}
1991
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1991
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1992 1992
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1993 1993
 					if ($globalDebug) echo '# Weather Station added'."\n";
1994 1994
 					$Source->deleteOldLocationByType('wx');
@@ -1998,7 +1998,7 @@  discard block
 block discarded – undo
1998 1998
 					} else {
1999 1999
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2000 2000
 					}
2001
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2001
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2002 2002
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2003 2003
 					if ($globalDebug) echo '☈ Lightning added'."\n";
2004 2004
 					$Source->deleteOldLocationByType('lightning');
@@ -2007,11 +2007,11 @@  discard block
 block discarded – undo
2007 2007
 					} else {
2008 2008
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2009 2009
 					}
2010
-				    } elseif ($globalDebug) {
2011
-				    	echo '/!\ Not added: '.$buffer."\n";
2012
-				    	print_r($line);
2013
-				    }
2014
-				    unset($data);
2010
+					} elseif ($globalDebug) {
2011
+						echo '/!\ Not added: '.$buffer."\n";
2012
+						print_r($line);
2013
+					}
2014
+					unset($data);
2015 2015
 				}
2016 2016
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2017 2017
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -2030,13 +2030,13 @@  discard block
 block discarded – undo
2030 2030
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
2031 2031
 					$globalSources[$nb]['last_weather_clean'] = time();
2032 2032
 				}
2033
-			    }
2033
+				}
2034 2034
 			} else {
2035
-			    $line = explode(',', $buffer);
2036
-			    //print_r($line);
2037
-    			    if (count($line) > 20) {
2038
-    			    	$data['hex'] = $line[4];
2039
-    				/*
2035
+				$line = explode(',', $buffer);
2036
+				//print_r($line);
2037
+					if (count($line) > 20) {
2038
+						$data['hex'] = $line[4];
2039
+					/*
2040 2040
     				$data['datetime'] = $line[6].' '.$line[7];
2041 2041
     					date_default_timezone_set($globalTimezone);
2042 2042
     					$datetime = new DateTime($data['datetime']);
@@ -2044,31 +2044,31 @@  discard block
 block discarded – undo
2044 2044
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
2045 2045
     					date_default_timezone_set('UTC');
2046 2046
     				*/
2047
-    				// Force datetime to current UTC datetime
2048
-    				date_default_timezone_set('UTC');
2049
-    				$data['datetime'] = date('Y-m-d H:i:s');
2050
-    				$data['ident'] = trim($line[10]);
2051
-    				$data['latitude'] = $line[14];
2052
-    				$data['longitude'] = $line[15];
2053
-    				$data['verticalrate'] = $line[16];
2054
-    				$data['emergency'] = $line[20];
2055
-    				$data['speed'] = $line[12];
2056
-    				$data['squawk'] = $line[17];
2057
-    				$data['altitude'] = $line[11];
2058
-    				$data['heading'] = $line[13];
2059
-    				$data['ground'] = $line[21];
2060
-    				$data['emergency'] = $line[19];
2061
-    				$data['format_source'] = 'sbs';
2047
+					// Force datetime to current UTC datetime
2048
+					date_default_timezone_set('UTC');
2049
+					$data['datetime'] = date('Y-m-d H:i:s');
2050
+					$data['ident'] = trim($line[10]);
2051
+					$data['latitude'] = $line[14];
2052
+					$data['longitude'] = $line[15];
2053
+					$data['verticalrate'] = $line[16];
2054
+					$data['emergency'] = $line[20];
2055
+					$data['speed'] = $line[12];
2056
+					$data['squawk'] = $line[17];
2057
+					$data['altitude'] = $line[11];
2058
+					$data['heading'] = $line[13];
2059
+					$data['ground'] = $line[21];
2060
+					$data['emergency'] = $line[19];
2061
+					$data['format_source'] = 'sbs';
2062 2062
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
2063 2063
 				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
2064 2064
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2065 2065
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2066
-    				$data['id_source'] = $id_source;
2067
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2068
-    				else $error = true;
2069
-    				unset($data);
2070
-    			    } else $error = true;
2071
-			    if ($error) {
2066
+					$data['id_source'] = $id_source;
2067
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2068
+					else $error = true;
2069
+					unset($data);
2070
+					} else $error = true;
2071
+				if ($error) {
2072 2072
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
2073 2073
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
2074 2074
 				} else {
@@ -2084,13 +2084,13 @@  discard block
 block discarded – undo
2084 2084
 					connect_all($sourceer);
2085 2085
 					$sourceer = array();
2086 2086
 				}
2087
-			    }
2087
+				}
2088 2088
 			}
2089 2089
 			// Sleep for xxx microseconds
2090 2090
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2091
-		    } else {
2091
+			} else {
2092 2092
 			if ($format === 'flightgearmp') {
2093
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2093
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
2094 2094
 				//@socket_close($r);
2095 2095
 				sleep($globalMinFetch);
2096 2096
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2099,9 +2099,9 @@  discard block
 block discarded – undo
2099 2099
 				break;
2100 2100
 				
2101 2101
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2102
-			    if (isset($tt[$format])) $tt[$format]++;
2103
-			    else $tt[$format] = 0;
2104
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
2102
+				if (isset($tt[$format])) $tt[$format]++;
2103
+				else $tt[$format] = 0;
2104
+				if ($tt[$format] > 30 || $buffer === FALSE) {
2105 2105
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2106 2106
 				//@socket_close($r);
2107 2107
 				sleep(2);
@@ -2112,24 +2112,24 @@  discard block
 block discarded – undo
2112 2112
 				//connect_all($globalSources);
2113 2113
 				$tt[$format]=0;
2114 2114
 				break;
2115
-			    } 
2116
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2115
+				} 
2116
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2117
+			}
2117 2118
 			}
2118
-		    }
2119 2119
 		}
2120
-	    } else {
2120
+		} else {
2121 2121
 		$error = socket_strerror(socket_last_error());
2122 2122
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2123 2123
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2124 2124
 			if (isset($globalDebug)) echo "Restarting...\n";
2125 2125
 			// Restart the script if possible
2126 2126
 			if (is_array($sockets)) {
2127
-			    if ($globalDebug) echo "Shutdown all sockets...";
2127
+				if ($globalDebug) echo "Shutdown all sockets...";
2128 2128
 			    
2129
-			    foreach ($sockets as $sock) {
2129
+				foreach ($sockets as $sock) {
2130 2130
 				@socket_shutdown($sock,2);
2131 2131
 				@socket_close($sock);
2132
-			    }
2132
+				}
2133 2133
 			    
2134 2134
 			}
2135 2135
 			if ($globalDebug) echo "Waiting...";
@@ -2144,15 +2144,15 @@  discard block
 block discarded – undo
2144 2144
 			if ($globalDebug) echo "Restart all connections...";
2145 2145
 			connect_all($globalSources);
2146 2146
 		}
2147
-	    }
2147
+		}
2148 2148
 	}
2149 2149
 	if ($globalDaemon === false) {
2150
-	    if ($globalDebug) echo 'Check all...'."\n";
2151
-	    if (isset($SI)) $SI->checkAll();
2152
-	    if (isset($TI)) $TI->checkAll();
2153
-	    if (isset($MI)) $MI->checkAll();
2150
+		if ($globalDebug) echo 'Check all...'."\n";
2151
+		if (isset($SI)) $SI->checkAll();
2152
+		if (isset($TI)) $TI->checkAll();
2153
+		if (isset($MI)) $MI->checkAll();
2154
+	}
2154 2155
 	}
2155
-    }
2156 2156
 }
2157 2157
 
2158 2158
 ?>
Please login to merge, or discard this patch.
Spacing   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
 	    die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
62
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
63 63
     }
64 64
 }
65 65
 
66
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
66
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70 70
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
71
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
72 72
     else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74 74
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
76 76
     else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115 115
     if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
116
+    $SI = new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
120 120
     $SI->connect();
121 121
 */
122
-} else $SI=new SpotterImport($Connection->db);
122
+} else $SI = new SpotterImport($Connection->db);
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
     $MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136
-$SBS=new SBS();
136
+$SBS = new SBS();
137 137
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
138
-	$ACARS=new ACARS($Connection->db,true);
139
-	$Source=new Source($Connection->db);
138
+	$ACARS = new ACARS($Connection->db, true);
139
+	$Source = new Source($Connection->db);
140 140
 }
141
-$Common=new Common();
141
+$Common = new Common();
142 142
 date_default_timezone_set('UTC');
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
146
+    pcntl_signal(SIGINT, function() {
147 147
         global $sockets;
148 148
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149 149
         die("Bye!\n");
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
 function connect_all($hosts) {
161 161
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
162
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
163 163
     $reset++;
164 164
     if ($globalDebug) echo 'Connect to all...'."\n";
165 165
     foreach ($hosts as $id => $value) {
@@ -167,33 +167,33 @@  discard block
 block discarded – undo
167 167
 	$udp = false;
168 168
 	$globalSources[$id]['last_exec'] = 0;
169 169
 	// Here we check type of source(s)
170
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
-            if (preg_match('/deltadb.txt$/i',$host)) {
170
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
+            if (preg_match('/deltadb.txt$/i', $host)) {
172 172
         	//$formats[$id] = 'deltadbtxt';
173 173
         	$globalSources[$id]['format'] = 'deltadbtxt';
174 174
         	//$last_exec['deltadbtxt'] = 0;
175 175
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
176
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
177 177
         	//$formats[$id] = 'vatsimtxt';
178 178
         	$globalSources[$id]['format'] = 'vatsimtxt';
179 179
         	//$last_exec['vatsimtxt'] = 0;
180 180
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
181
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
182 182
         	//$formats[$id] = 'aircraftlistjson';
183 183
         	$globalSources[$id]['format'] = 'aircraftlistjson';
184 184
         	//$last_exec['aircraftlistjson'] = 0;
185 185
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
186
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
187 187
         	//$formats[$id] = 'aircraftjson';
188 188
         	$globalSources[$id]['format'] = 'aircraftjson';
189 189
         	//$last_exec['aircraftlistjson'] = 0;
190 190
         	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
-    	    } else if (preg_match('/aircraft$/i',$host)) {
191
+    	    } else if (preg_match('/aircraft$/i', $host)) {
192 192
         	//$formats[$id] = 'planefinderclient';
193 193
         	$globalSources[$id]['format'] = 'planefinderclient';
194 194
         	//$last_exec['aircraftlistjson'] = 0;
195 195
         	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
-    	    } else if (preg_match('/opensky/i',$host)) {
196
+    	    } else if (preg_match('/opensky/i', $host)) {
197 197
         	//$formats[$id] = 'aircraftlistjson';
198 198
         	$globalSources[$id]['format'] = 'opensky';
199 199
         	//$last_exec['aircraftlistjson'] = 0;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         	    exit(0);
211 211
         	}
212 212
     	    */
213
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
213
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
214 214
         	//$formats[$id] = 'planeupdatefaa';
215 215
         	$globalSources[$id]['format'] = 'planeupdatefaa';
216 216
         	//$last_exec['planeupdatefaa'] = 0;
@@ -219,37 +219,37 @@  discard block
 block discarded – undo
219 219
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220 220
         	    exit(0);
221 221
         	}
222
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
222
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
223 223
         	//$formats[$id] = 'phpvmacars';
224 224
         	$globalSources[$id]['format'] = 'phpvmacars';
225 225
         	//$last_exec['phpvmacars'] = 0;
226 226
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
227
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
228 228
         	//$formats[$id] = 'phpvmacars';
229 229
         	$globalSources[$id]['format'] = 'vaos';
230 230
         	//$last_exec['phpvmacars'] = 0;
231 231
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
232
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
233 233
         	//$formats[$id] = 'phpvmacars';
234 234
         	$globalSources[$id]['format'] = 'vam';
235 235
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
-            } else if (preg_match('/whazzup/i',$host)) {
236
+            } else if (preg_match('/whazzup/i', $host)) {
237 237
         	//$formats[$id] = 'whazzup';
238 238
         	$globalSources[$id]['format'] = 'whazzup';
239 239
         	//$last_exec['whazzup'] = 0;
240 240
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
-            } else if (preg_match('/blitzortung/i',$host)) {
241
+            } else if (preg_match('/blitzortung/i', $host)) {
242 242
         	$globalSources[$id]['format'] = 'blitzortung';
243 243
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
-            } else if (preg_match('/airwhere/i',$host)) {
244
+            } else if (preg_match('/airwhere/i', $host)) {
245 245
         	$globalSources[$id]['format'] = 'airwhere';
246 246
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
-            } else if (preg_match('/recentpireps/i',$host)) {
247
+            } else if (preg_match('/recentpireps/i', $host)) {
248 248
         	//$formats[$id] = 'pirepsjson';
249 249
         	$globalSources[$id]['format'] = 'pirepsjson';
250 250
         	//$last_exec['pirepsjson'] = 0;
251 251
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
252
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
253 253
         	//$formats[$id] = 'fr24json';
254 254
         	$globalSources[$id]['format'] = 'fr24json';
255 255
         	//$last_exec['fr24json'] = 0;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259 259
         	    exit(0);
260 260
         	}
261
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
261
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
262 262
         	//$formats[$id] = 'fr24json';
263 263
         	$globalSources[$id]['format'] = 'myshiptracking';
264 264
         	//$last_exec['fr24json'] = 0;
@@ -268,22 +268,22 @@  discard block
 block discarded – undo
268 268
         	    exit(0);
269 269
         	}
270 270
             //} else if (preg_match('/10001/',$host)) {
271
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272 272
         	//$formats[$id] = 'tsv';
273 273
         	$globalSources[$id]['format'] = 'tsv';
274 274
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275 275
             }
276
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276
+        } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277 277
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
278
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
279 279
     		    if ($idf !== false) {
280 280
     			$httpfeeds[$id] = $idf;
281 281
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282 282
     		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283 283
     		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284 284
     		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
285
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
286
-	    $hostport = explode(':',$host);
285
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
286
+	    $hostport = explode(':', $host);
287 287
 	    if (isset($hostport[1])) {
288 288
 		$port = $hostport[1];
289 289
 		$hostn = $hostport[0];
@@ -293,20 +293,20 @@  discard block
 block discarded – undo
293 293
 	    }
294 294
 	    $Common = new Common();
295 295
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
296
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
296
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
297 297
     	    } else {
298 298
     		$udp = true;
299
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
299
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
300 300
 	    }
301 301
 	    if ($s) {
302 302
     	        $sockets[$id] = $s;
303 303
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
304
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
304
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
305 305
 			//$formats[$id] = 'aprs';
306 306
 			$globalSources[$id]['format'] = 'aprs';
307 307
 			//$aprs_connect = 0;
308 308
 			//$use_aprs = true;
309
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
309
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
310 310
 			$globalSources[$id]['format'] = 'vrstcp';
311 311
     		    } elseif ($port == '10001') {
312 312
         		//$formats[$id] = 'tsv';
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
349 349
 else $timeout = 20;
350 350
 $errno = '';
351
-$errstr='';
351
+$errstr = '';
352 352
 
353 353
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
354 354
 /* Initiate connections to all the hosts simultaneously */
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 //connect_all($globalSources);
357 357
 
358 358
 if (isset($globalProxy) && $globalProxy) {
359
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
359
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
360 360
 } else {
361 361
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
362 362
 }
@@ -386,16 +386,16 @@  discard block
 block discarded – undo
386 386
 
387 387
 if ($use_aprs) {
388 388
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
389
-	$APRS=new APRS();
389
+	$APRS = new APRS();
390 390
 	$aprs_connect = 0;
391 391
 	$aprs_keep = 120;
392 392
 	$aprs_last_tx = time();
393 393
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
394
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
394
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
395 395
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
396
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
396
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
397 397
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
398
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
398
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
399 399
 	if ($aprs_full) $aprs_filter = '';
400 400
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
401 401
 	else $aprs_pass = '-1';
@@ -409,12 +409,12 @@  discard block
 block discarded – undo
409 409
 sleep(1);
410 410
 if ($globalDebug) echo "SCAN MODE \n\n";
411 411
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
412
-$endtime = time()+$globalCronEnd;
412
+$endtime = time() + $globalCronEnd;
413 413
 $i = 1;
414 414
 $tt = array();
415 415
 // Delete all ATC
416 416
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
417
-	$ATC=new ATC($Connection->db);
417
+	$ATC = new ATC($Connection->db);
418 418
 }
419 419
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
420 420
 	$ATC->deleteAll();
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 while ($i > 0) {
425 425
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
426 426
 
427
-    if (!$globalDaemon) $i = $endtime-time();
427
+    if (!$globalDaemon) $i = $endtime - time();
428 428
     // Delete old ATC
429 429
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
430 430
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	}
439 439
 	if ($max < $globalMinFetch) {
440 440
 	    if ($globalDebug) echo 'Sleeping...'."\n";
441
-	    sleep($globalMinFetch-$max+2);
441
+	    sleep($globalMinFetch - $max + 2);
442 442
 	}
443 443
     }
444 444
 
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
             //$buffer = $Common->getData($hosts[$id]);
494 494
             $buffer = $Common->getData($value['host']);
495 495
             if ($buffer != '') {
496
-                $all_data = json_decode($buffer,true);
496
+                $all_data = json_decode($buffer, true);
497 497
                 foreach ($all_data as $line) {
498 498
                     $data = array();
499
-                    $data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
499
+                    $data['datetime'] = date('Y-m-d H:i:s', $line['uti']);
500 500
                     $data['hex'] = $line['hex']; // hex
501 501
                     $data['ident'] = $line['fli']; // ident
502 502
                     $data['altitude'] = $line['alt']; // altitude
@@ -531,11 +531,11 @@  discard block
 block discarded – undo
531 531
 	    )
532 532
 	) {
533 533
 	    date_default_timezone_set('CET');
534
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
534
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
535 535
 	    date_default_timezone_set('UTC');
536 536
 	    if ($buffer != '') $reset = 0;
537
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
538
-	    $buffer = explode('\n',$buffer);
537
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
538
+	    $buffer = explode('\n', $buffer);
539 539
 	    foreach ($buffer as $line) {
540 540
 		if ($line != '') {
541 541
 		    //echo "'".$line."'\n";
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 		    $ais_data = $AIS->parse_line(trim($line));
544 544
 		    $data = array();
545 545
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
546
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
546
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
547 547
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
548 548
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
549 549
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
556 556
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
557 557
 		    if (isset($ais_data['timestamp'])) {
558
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
558
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
559 559
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
560 560
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
561 561
 			    $add = true;
@@ -578,21 +578,21 @@  discard block
 block discarded – undo
578 578
 	    $w = $e = null;
579 579
 	    
580 580
 	    if (isset($arr[$id])) {
581
-		$nn = stream_select($arr,$w,$e,$timeout);
581
+		$nn = stream_select($arr, $w, $e, $timeout);
582 582
 		if ($nn > 0) {
583 583
 		    foreach ($httpfeeds as $feed) {
584
-			$buffer = stream_get_line($feed,2000,"\n");
584
+			$buffer = stream_get_line($feed, 2000, "\n");
585 585
 			if ($buffer === FALSE) {
586 586
 			    connect_all($globalSources);
587 587
 			}
588
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
589
-			$buffer = explode('\n',$buffer);
588
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
589
+			$buffer = explode('\n', $buffer);
590 590
 			foreach ($buffer as $line) {
591 591
 			    if ($line != '') {
592 592
 				$ais_data = $AIS->parse_line(trim($line));
593 593
 				$data = array();
594 594
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
595
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
595
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
596 596
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
597 597
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
598 598
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -604,9 +604,9 @@  discard block
 block discarded – undo
604 604
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
605 605
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
606 606
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
607
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
607
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
608 608
 				if (isset($ais_data['timestamp'])) {
609
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
609
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
610 610
 				} else {
611 611
 				    $data['datetime'] = date('Y-m-d H:i:s');
612 612
 				}
@@ -638,10 +638,10 @@  discard block
 block discarded – undo
638 638
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
639 639
 	    )
640 640
 	) {
641
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
641
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
642 642
 	    if ($buffer != '') {
643 643
 		//echo $buffer;
644
-		$all_data = json_decode($buffer,true);
644
+		$all_data = json_decode($buffer, true);
645 645
 		//print_r($all_data);
646 646
 		if (isset($all_data[0]['DATA'])) {
647 647
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 			    $data['ident'] = $line['NAME'];
651 651
 			    $data['mmsi'] = $line['MMSI'];
652 652
 			    if (strlen($data['mmsi']) > 9) {
653
-				$data['mmsi'] = substr($data['mmsi'],-9);
653
+				$data['mmsi'] = substr($data['mmsi'], -9);
654 654
 			    }
655 655
 			    $data['speed'] = $line['SOG'];
656 656
 			    $data['heading'] = $line['COG'];
@@ -660,8 +660,8 @@  discard block
 block discarded – undo
660 660
 			    //$data['type_id'] = $line['TYPE'];
661 661
 			    $data['imo'] = $line['IMO'];
662 662
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
663
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
664
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
663
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
664
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
665 665
 			    $data['format_source'] = 'myshiptracking';
666 666
 			    $data['id_source'] = $id_source;
667 667
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -678,16 +678,16 @@  discard block
 block discarded – undo
678 678
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
679 679
 	    )
680 680
 	) {
681
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
681
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
682 682
 	    if ($buffer != '') {
683
-		$all_data = json_decode($buffer,true);
683
+		$all_data = json_decode($buffer, true);
684 684
 		if (isset($all_data[0]['mmsi'])) {
685 685
 		    foreach ($all_data as $line) {
686 686
 			if ($line != '') {
687 687
 			    $data = array();
688 688
 			    $data['ident'] = $line['shipname'];
689 689
 			    $data['callsign'] = $line['callsign'];
690
-			    $data['mmsi'] = substr($line['mmsi'],-9);
690
+			    $data['mmsi'] = substr($line['mmsi'], -9);
691 691
 			    $data['speed'] = $line['sog'];
692 692
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
693 693
 			    $data['latitude'] = $line['latitude'];
@@ -714,14 +714,14 @@  discard block
 block discarded – undo
714 714
 	) {
715 715
 	    $buffer = $Common->getData($value['host']);
716 716
 	    if ($buffer != '') {
717
-		$all_data = json_decode($buffer,true);
717
+		$all_data = json_decode($buffer, true);
718 718
 		if (isset($all_data['features'][0]['id'])) {
719 719
 		    foreach ($all_data['features'] as $line) {
720 720
 			print_r($line);
721 721
 			$data = array();
722 722
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
723 723
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
724
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
724
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
725 725
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
726 726
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
727 727
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -748,31 +748,31 @@  discard block
 block discarded – undo
748 748
 	    )
749 749
 	) {
750 750
 	    if ($globalDebug) echo 'download...';
751
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
751
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
752 752
 	    if ($globalDebug) echo 'done !'."\n";
753 753
 	    // FIXME: Need more work
754 754
 	    if ($buffer != '') $reset = 0;
755
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
756
-	    $buffer = explode('\n',$buffer);
755
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
756
+	    $buffer = explode('\n', $buffer);
757 757
 	    foreach ($buffer as $line) {
758 758
 		if ($line != '') {
759 759
 		    $data = array();
760 760
 		    //echo $line."\n";
761
-		    $data['mmsi'] = (int)substr($line,0,9);
762
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
763
-		    $data['status_id'] = substr($line,21,2);
764
-		    $data['type_id'] = substr($line,24,3);
765
-		    $data['latitude'] = substr($line,29,9);
766
-		    $data['longitude'] = substr($line,41,9);
767
-		    $data['speed'] = round(substr($line,51,5));
761
+		    $data['mmsi'] = (int) substr($line, 0, 9);
762
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
763
+		    $data['status_id'] = substr($line, 21, 2);
764
+		    $data['type_id'] = substr($line, 24, 3);
765
+		    $data['latitude'] = substr($line, 29, 9);
766
+		    $data['longitude'] = substr($line, 41, 9);
767
+		    $data['speed'] = round(substr($line, 51, 5));
768 768
 		    //$data['course'] = substr($line,57,5);
769
-		    $data['heading'] = round(substr($line,63,3));
769
+		    $data['heading'] = round(substr($line, 63, 3));
770 770
 		    //$data['draft'] = substr($line,67,4);
771 771
 		    //$data['length'] = substr($line,72,3);
772 772
 		    //$data['beam'] = substr($line,76,2);
773
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
773
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
774 774
 		    //$data['callsign'] = trim(substr($line,100,7);
775
-		    $data['arrival_code'] = substr($line,108,20);
775
+		    $data['arrival_code'] = substr($line, 108, 20);
776 776
 		    //$data['etaDate'] = substr($line,129,5);
777 777
 		    //$data['etaTime'] = substr($line,135,5);
778 778
 		    $data['format_source'] = 'shipplotter';
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 	    )
793 793
 	) {
794 794
 	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
795
-		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
795
+		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl', 'post', array('submitlogin' => 'Login', 'email' => $globalSailaway['email'], 'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'), '', '', '', '', '', false, false, true);
796 796
 		//echo $authsailaway;
797 797
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
798 798
 		if (isset($setcookie[1][0])) {
@@ -801,18 +801,18 @@  discard block
 block discarded – undo
801 801
 	    }
802 802
 
803 803
 	    if ($globalDebug) echo '! Download... ';
804
-	    for ($i =0; $i <= 1; $i++) {
804
+	    for ($i = 0; $i <= 1; $i++) {
805 805
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
806 806
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
807 807
 	    if ($globalDebug) echo 'done'."\n";
808 808
 	    if ($buffer != '') {
809
-		$all_data = json_decode($buffer,true);
809
+		$all_data = json_decode($buffer, true);
810 810
 		if (isset($all_data['missions'])) {
811 811
 			foreach ($all_data['missions'] as $mission) {
812 812
 				$mission_user = $mission['usrname'];
813
-				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
814
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
815
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
813
+				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']));
814
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
815
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie);
816 816
 					else $racebuffer = '';
817 817
 					$bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
818 818
 				} else {
@@ -820,19 +820,19 @@  discard block
 block discarded – undo
820 820
 					$racebuffer = '';
821 821
 				}
822 822
 				if ($racebuffer != '') {
823
-					$race_data = json_decode($racebuffer,true);
823
+					$race_data = json_decode($racebuffer, true);
824 824
 					//print_r($race_data);
825 825
 					unset($racebuffer);
826 826
 					if (isset($race_data['mission'])) {
827 827
 					    $datar = array();
828 828
 					    $datar['id'] = $mission['misnr'];
829 829
 					    $datar['desc'] = $race_data['mission']['misdescr'];
830
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
831
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
830
+					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname'])));
831
+					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle'])));
832 832
 					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
833 833
 					    $markers = array();
834 834
 					    foreach ($race_data['mission']['course'] as $course) {
835
-						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
835
+						$markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']);
836 836
 					    }
837 837
 					    $datar['markers'] = json_encode($markers);
838 838
 					    //print_r($datar);
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 					}
841 841
 				}
842 842
 				if ($bufferm != '') {
843
-					$mission_data = json_decode($bufferm,true);
843
+					$mission_data = json_decode($bufferm, true);
844 844
 					unset($bufferm);
845 845
 					if (isset($mission_data['leaderboard'][0]['results'])) {
846 846
 						foreach ($mission_data['leaderboard'][0]['results'] as $sail) {
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 								//$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr'];
854 854
 								$data['id'] = $sail['misnr'].'-'.$sail['usrnr'];
855 855
 								$data['datetime'] = date('Y-m-d H:i:s');
856
-								$data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart']));
856
+								$data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart']));
857 857
 								$data['last_update'] = date('Y-m-d H:i:s');
858 858
 								$data['status'] = $sail['status'];
859 859
 								$data['type'] = $sail['btptype'];
@@ -864,16 +864,16 @@  discard block
 block discarded – undo
864 864
 									$data['longitude'] = $pos['longitude'];
865 865
 								}
866 866
 								if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') {
867
-									$resultdescr = explode(',',$sail['resultdescr']);
867
+									$resultdescr = explode(',', $sail['resultdescr']);
868 868
 									if (count($resultdescr) > 2) {
869
-										$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2);
870
-										$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1]));
869
+										$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2);
870
+										$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1]));
871 871
 										if (isset($resultdescr[3])) {
872
-											$data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3);
872
+											$data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3);
873 873
 										}
874 874
 									}
875 875
 								}
876
-								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
876
+								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
877 877
 								$data['captain_id'] = $sail['usrnr'];
878 878
 								$data['captain_name'] = $sail['usrname'];
879 879
 								$data['race_id'] = $sail['misnr'];
@@ -921,8 +921,8 @@  discard block
 block discarded – undo
921 921
 	) {
922 922
 	    //$buffer = $Common->getData($hosts[$id]);
923 923
 	    $buffer = $Common->getData($value['host']);
924
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
925
-	    $buffer = explode('\n',$buffer);
924
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
925
+	    $buffer = explode('\n', $buffer);
926 926
 	    $reset = 0;
927 927
 	    foreach ($buffer as $line) {
928 928
     		if ($line != '') {
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
934 934
 			$data['pilot_id'] = $line[1];
935 935
 			$data['pilot_name'] = $line[2];
936
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
936
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
937 937
 			$data['ident'] = $line[0]; // ident
938 938
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
939 939
 			$data['speed'] = $line[8]; // speed
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
950 950
 			//if (isset($line[37])) $data['last_update'] = $line[37];
951 951
 		        $data['departure_airport_icao'] = $line[11];
952
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
952
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
953 953
 		        $data['arrival_airport_icao'] = $line[13];
954 954
 			$data['frequency'] = $line[4];
955 955
 			$data['type'] = $line[18];
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
     			$data['id_source'] = $id_source;
959 959
 	    		//$data['arrival_airport_time'] = ;
960 960
 	    		if ($line[9] != '') {
961
-	    		    $aircraft_data = explode('/',$line[9]);
961
+	    		    $aircraft_data = explode('/', $line[9]);
962 962
 	    		    if (isset($aircraft_data[1])) {
963 963
 	    			$data['aircraft_icao'] = $aircraft_data[1];
964 964
 	    		    }
@@ -973,9 +973,9 @@  discard block
 block discarded – undo
973 973
     			if ($line[3] === 'PILOT') $SI->add($data);
974 974
 			elseif ($line[3] === 'ATC') {
975 975
 				//print_r($data);
976
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
977
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
978
-				$typec = substr($data['ident'],-3);
976
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
977
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
978
+				$typec = substr($data['ident'], -3);
979 979
 				if ($typec === 'APP') $data['type'] = 'Approach';
980 980
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
981 981
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -987,8 +987,8 @@  discard block
 block discarded – undo
987 987
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
988 988
 				if (!isset($data['source_name'])) $data['source_name'] = '';
989 989
 				if (isset($ATC)) {
990
-					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']);
991
-					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']);
990
+					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']);
991
+					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']);
992 992
 				}
993 993
 			}
994 994
     			unset($data);
@@ -1004,24 +1004,24 @@  discard block
 block discarded – undo
1004 1004
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1005 1005
     	    )
1006 1006
     	) {
1007
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1007
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
1008 1008
 	    if ($buffer != '') {
1009 1009
 		$all_data = simplexml_load_string($buffer);
1010
-		foreach($all_data->children() as $childdata) {
1010
+		foreach ($all_data->children() as $childdata) {
1011 1011
 			$data = array();
1012 1012
 			$line = $childdata;
1013 1013
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
1014
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
1015
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1016
-			$data['latitude'] = (float)$line['pktLatitude'];
1017
-			$data['longitude'] = (float)$line['pktLongitude'];
1018
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1019
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1020
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1014
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
1015
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
1016
+			$data['latitude'] = (float) $line['pktLatitude'];
1017
+			$data['longitude'] = (float) $line['pktLongitude'];
1018
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
1019
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
1020
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
1021 1021
 			$data['altitude_relative'] = 'AMSL';
1022
-			$data['pilot_id'] = (int)$line['pktPilotID'];
1022
+			$data['pilot_id'] = (int) $line['pktPilotID'];
1023 1023
 			$data['aircraft_icao'] = 'PARAGLIDER';
1024
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1024
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1025 1025
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1026 1026
 			$data['format_source'] = $value['format'];
1027 1027
 			$SI->add($data);
@@ -1029,22 +1029,22 @@  discard block
 block discarded – undo
1029 1029
 		}
1030 1030
 	    }
1031 1031
 	    $Source->deleteOldLocationByType('gs');
1032
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1032
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
1033 1033
 	    if ($buffer != '') {
1034 1034
 		$all_data = simplexml_load_string($buffer);
1035
-		foreach($all_data->children() as $childdata) {
1035
+		foreach ($all_data->children() as $childdata) {
1036 1036
 			$data = array();
1037 1037
 			$line = $childdata;
1038
-			$data['id'] = (int)$line['gsID'];
1039
-			$data['latitude'] = (float)$line['gsLatitude'];
1040
-			$data['longitude'] = (float)$line['gsLongitude'];
1041
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
1038
+			$data['id'] = (int) $line['gsID'];
1039
+			$data['latitude'] = (float) $line['gsLatitude'];
1040
+			$data['longitude'] = (float) $line['gsLongitude'];
1041
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
1042 1042
 			$data['altitude_relative'] = 'AMSL';
1043
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
1043
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
1044 1044
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
1045
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1045
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1046 1046
 			} else {
1047
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1047
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1048 1048
 			}
1049 1049
 			unset($data);
1050 1050
 		}
@@ -1062,9 +1062,9 @@  discard block
 block discarded – undo
1062 1062
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1063 1063
 	    )
1064 1064
 	) {
1065
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1065
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1066 1066
 	    if ($buffer != '') {
1067
-	        $all_data = json_decode($buffer,true);
1067
+	        $all_data = json_decode($buffer, true);
1068 1068
 		if (isset($all_data['acList'])) {
1069 1069
 		    $reset = 0;
1070 1070
 		    foreach ($all_data['acList'] as $line) {
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1081 1081
 			$data['emergency'] = ''; // emergency
1082 1082
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1083
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1083
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1084 1084
 			else $data['datetime'] = date('Y-m-d H:i:s');
1085 1085
 			//$data['datetime'] = date('Y-m-d H:i:s');
1086 1086
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1106 1106
 			$data['squawk'] = $line['squawk']; // squawk
1107 1107
 			$data['emergency'] = ''; // emergency
1108
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1108
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1109 1109
 			else $data['datetime'] = date('Y-m-d H:i:s');
1110 1110
 			$data['format_source'] = 'aircraftlistjson';
1111 1111
 			$data['id_source'] = $id_source;
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
     	    )
1127 1127
     	) {
1128 1128
 	    $buffer = $Common->getData($value['host']);
1129
-	    $all_data = json_decode($buffer,true);
1129
+	    $all_data = json_decode($buffer, true);
1130 1130
 	    if (isset($all_data['planes'])) {
1131 1131
 		$reset = 0;
1132 1132
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1143,12 +1143,12 @@  discard block
 block discarded – undo
1143 1143
 		    $data['emergency'] = ''; // emergency
1144 1144
 		    $data['registration'] = $line[2];
1145 1145
 		    $data['aircraft_icao'] = $line[0];
1146
-		    $deparr = explode('-',$line[1]);
1146
+		    $deparr = explode('-', $line[1]);
1147 1147
 		    if (count($deparr) === 2) {
1148 1148
 			$data['departure_airport_icao'] = $deparr[0];
1149 1149
 			$data['arrival_airport_icao'] = $deparr[1];
1150 1150
 		    }
1151
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1151
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1152 1152
 	    	    $data['format_source'] = 'planeupdatefaa';
1153 1153
     		    $data['id_source'] = $id_source;
1154 1154
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 	    )
1167 1167
 	) {
1168 1168
 	    $buffer = $Common->getData($value['host']);
1169
-	    $all_data = json_decode($buffer,true);
1169
+	    $all_data = json_decode($buffer, true);
1170 1170
 	    if (isset($all_data['states'])) {
1171 1171
 		$reset = 0;
1172 1172
 		foreach ($all_data['states'] as $key => $line) {
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
 		    //$data['emergency'] = ''; // emergency
1184 1184
 		    //$data['registration'] = $line[2];
1185 1185
 		    //$data['aircraft_icao'] = $line[0];
1186
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1186
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1187 1187
 		    $data['format_source'] = 'opensky';
1188 1188
 		    $data['id_source'] = $id_source;
1189 1189
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1200,8 +1200,8 @@  discard block
 block discarded – undo
1200 1200
 	    )
1201 1201
 	) {
1202 1202
 	    $buffer = $Common->getData($value['host']);
1203
-	    $all_data = json_decode($buffer,true);
1204
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1203
+	    $all_data = json_decode($buffer, true);
1204
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1205 1205
 		$reset = 0;
1206 1206
 		foreach ($all_data['aircraft'] as $key => $line) {
1207 1207
 		    $data = array();
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
 	    )
1240 1240
 	) {
1241 1241
 	    $buffer = $Common->getData($value['host']);
1242
-	    $all_data = json_decode($buffer,true);
1242
+	    $all_data = json_decode($buffer, true);
1243 1243
 	    if (isset($all_data['aircraft'])) {
1244 1244
 		$reset = 0;
1245 1245
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
 		    //$data['emergency'] = ''; // emergency
1257 1257
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1258 1258
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1259
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1259
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1260 1260
 		    $data['format_source'] = 'planefinderclient';
1261 1261
 		    $data['id_source'] = $id_source;
1262 1262
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
 	) {
1276 1276
 	    //$buffer = $Common->getData($hosts[$id]);
1277 1277
 	    $buffer = $Common->getData($value['host']);
1278
-	    $all_data = json_decode($buffer,true);
1278
+	    $all_data = json_decode($buffer, true);
1279 1279
 	    if (!empty($all_data)) $reset = 0;
1280 1280
 	    foreach ($all_data as $key => $line) {
1281 1281
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1313,11 +1313,11 @@  discard block
 block discarded – undo
1313 1313
 	    )
1314 1314
 	) {
1315 1315
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1316
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1316
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1317 1317
 	    //echo $buffer;
1318
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1319
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1320
-	    $all_data = json_decode($buffer,true);
1318
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1319
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1320
+	    $all_data = json_decode($buffer, true);
1321 1321
 	    if (json_last_error() != JSON_ERROR_NONE) {
1322 1322
 		die(json_last_error_msg());
1323 1323
 	    }
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
 			//$data['departure_airport_iata'] = $line[11];
1341 1341
 			//$data['arrival_airport_iata'] = $line[12];
1342 1342
 	    		//$data['emergency'] = ''; // emergency
1343
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1343
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1344 1344
 	    		$data['format_source'] = 'radarvirtueljson';
1345 1345
     			$data['id_source'] = $id_source;
1346 1346
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1361,14 +1361,14 @@  discard block
 block discarded – undo
1361 1361
 	) {
1362 1362
 	    //$buffer = $Common->getData($hosts[$id]);
1363 1363
 	    $buffer = $Common->getData($value['host'].'?'.time());
1364
-	    $all_data = json_decode(utf8_encode($buffer),true);
1364
+	    $all_data = json_decode(utf8_encode($buffer), true);
1365 1365
 	    
1366 1366
 	    if (isset($all_data['pireps'])) {
1367 1367
 		$reset = 0;
1368 1368
 	        foreach ($all_data['pireps'] as $line) {
1369 1369
 		    $data = array();
1370 1370
 		    $data['id'] = $line['id'];
1371
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1371
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1372 1372
 		    $data['ident'] = $line['callsign']; // ident
1373 1373
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1374 1374
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1398,9 +1398,9 @@  discard block
 block discarded – undo
1398 1398
 			$SI->add($data);
1399 1399
 		    //    print_r($data);
1400 1400
     		    } elseif ($line['icon'] === 'ct') {
1401
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1402
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1403
-			$typec = substr($data['ident'],-3);
1401
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1402
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1403
+			$typec = substr($data['ident'], -3);
1404 1404
 			$data['type'] = '';
1405 1405
 			if ($typec === 'APP') $data['type'] = 'Approach';
1406 1406
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1412 1412
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1413 1413
 			else $data['type'] = 'Observer';
1414
-			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']);
1414
+			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']);
1415 1415
 		    }
1416 1416
 		    unset($data);
1417 1417
 		}
@@ -1428,14 +1428,14 @@  discard block
 block discarded – undo
1428 1428
 	    //$buffer = $Common->getData($hosts[$id]);
1429 1429
 	    if ($globalDebug) echo 'Get Data...'."\n";
1430 1430
 	    $buffer = $Common->getData($value['host']);
1431
-	    $all_data = json_decode($buffer,true);
1431
+	    $all_data = json_decode($buffer, true);
1432 1432
 	    if ($buffer != '' && is_array($all_data)) {
1433 1433
 		$reset = 0;
1434 1434
 		foreach ($all_data as $line) {
1435 1435
 	    	    $data = array();
1436 1436
 	    	    //$data['id'] = $line['id']; // id not usable
1437 1437
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1438
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1438
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1439 1439
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1440 1440
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1441 1441
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1450,7 +1450,7 @@  discard block
 block discarded – undo
1450 1450
 	    	    //$data['datetime'] = $line['lastupdate'];
1451 1451
 	    	    //$data['last_update'] = $line['lastupdate'];
1452 1452
 	    	    if (isset($value['timezone'])) {
1453
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1453
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1454 1454
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1455 1455
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1456 1456
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1466,14 +1466,14 @@  discard block
 block discarded – undo
1466 1466
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1467 1467
 		    if (isset($line['aircraftname'])) {
1468 1468
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1469
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1470
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1469
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1470
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1471 1471
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1472 1472
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1473 1473
 	    		else {
1474
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1475
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1476
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1474
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1475
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1476
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1477 1477
 	    		}
1478 1478
 	    	    }
1479 1479
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1498,7 +1498,7 @@  discard block
 block discarded – undo
1498 1498
 	    //$buffer = $Common->getData($hosts[$id]);
1499 1499
 	    if ($globalDebug) echo 'Get Data...'."\n";
1500 1500
 	    $buffer = $Common->getData($value['host']);
1501
-	    $all_data = json_decode($buffer,true);
1501
+	    $all_data = json_decode($buffer, true);
1502 1502
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1503 1503
 		$reset = 0;
1504 1504
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1509,7 +1509,7 @@  discard block
 block discarded – undo
1509 1509
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1510 1510
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1511 1511
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1512
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1512
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1513 1513
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1514 1514
 	    	    $data['altitude'] = $line['altitude']; // altitude
1515 1515
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
 	    	    //$data['squawk'] = ''; // squawk
1521 1521
 	    	    //$data['emergency'] = ''; // emergency
1522 1522
 	    	    if (isset($value['timezone'])) {
1523
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1523
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1524 1524
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1525 1525
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1526 1526
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1556,14 +1556,14 @@  discard block
 block discarded – undo
1556 1556
 	    //$buffer = $Common->getData($hosts[$id]);
1557 1557
 	    if ($globalDebug) echo 'Get Data...'."\n";
1558 1558
 	    $buffer = $Common->getData($value['host']);
1559
-	    $all_data = json_decode($buffer,true);
1559
+	    $all_data = json_decode($buffer, true);
1560 1560
 	    if ($buffer != '' && is_array($all_data)) {
1561 1561
 		$reset = 0;
1562 1562
 		foreach ($all_data as $line) {
1563 1563
 	    	    $data = array();
1564 1564
 	    	    //$data['id'] = $line['id']; // id not usable
1565 1565
 	    	    $data['id'] = trim($line['flight_id']);
1566
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1566
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1567 1567
 	    	    $data['pilot_name'] = $line['pilot_name'];
1568 1568
 	    	    $data['pilot_id'] = $line['pilot_id'];
1569 1569
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1607,24 +1607,24 @@  discard block
 block discarded – undo
1607 1607
 	    //$buffer = $Common->getData($hosts[$id]);
1608 1608
 	    if ($globalDebug) echo 'Get Data...'."\n";
1609 1609
 	    $buffer = $Common->getData($value['host']);
1610
-	    $all_data = json_decode($buffer,true);
1610
+	    $all_data = json_decode($buffer, true);
1611 1611
 	    if ($buffer != '') {
1612 1612
 		$Source->deleteLocationBySource('blitzortung');
1613
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1614
-		$buffer = explode('\n',$buffer);
1613
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1614
+		$buffer = explode('\n', $buffer);
1615 1615
 		foreach ($buffer as $buffer_line) {
1616
-		    $line = json_decode($buffer_line,true);
1616
+		    $line = json_decode($buffer_line, true);
1617 1617
 		    if (isset($line['time'])) {
1618 1618
 			$data = array();
1619 1619
 			$data['altitude'] = $line['alt']; // altitude
1620 1620
 			$data['latitude'] = $line['lat']; // lat
1621 1621
 			$data['longitude'] = $line['lon']; // long
1622
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1622
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1623 1623
 			$data['id_source'] = $id_source;
1624 1624
 			$data['format_source'] = 'blitzortung';
1625 1625
 			$SI->add($data);
1626 1626
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1627
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1627
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1628 1628
 			unset($data);
1629 1629
 		    }
1630 1630
 		}
@@ -1636,15 +1636,15 @@  discard block
 block discarded – undo
1636 1636
         $arr = $httpfeeds;
1637 1637
         $w = $e = null;
1638 1638
         if (isset($arr[$id])) {
1639
-            $nn = stream_select($arr,$w,$e,$timeout);
1639
+            $nn = stream_select($arr, $w, $e, $timeout);
1640 1640
             if ($nn > 0) {
1641 1641
                 foreach ($httpfeeds as $feed) {
1642
-                    $buffer = stream_get_line($feed,2000,"\n");
1642
+                    $buffer = stream_get_line($feed, 2000, "\n");
1643 1643
                     if ($buffer === FALSE) {
1644 1644
                         connect_all($globalSources);
1645 1645
                     }
1646
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1647
-                    $buffer = explode('\n',$buffer);
1646
+                    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1647
+                    $buffer = explode('\n', $buffer);
1648 1648
                     foreach ($buffer as $line) {
1649 1649
                         if ($line != '') {
1650 1650
                             $line = json_decode($line, true);
@@ -1684,11 +1684,11 @@  discard block
 block discarded – undo
1684 1684
 		    //$value = $formats[$nb];
1685 1685
 		    $format = $globalSources[$nb]['format'];
1686 1686
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1687
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1687
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1688 1688
 		    } elseif ($format === 'vrstcp') {
1689 1689
 			$buffer = @socket_read($r, 6000);
1690 1690
 		    } else {
1691
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1691
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1692 1692
 		    }
1693 1693
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1694 1694
 		    //echo $buffer."\n";
@@ -1698,8 +1698,8 @@  discard block
 block discarded – undo
1698 1698
 		    //$SI::del();
1699 1699
 		    if ($buffer !== FALSE) {
1700 1700
 			if ($format === 'vrstcp') {
1701
-			    $buffer = explode('},{',$buffer);
1702
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1701
+			    $buffer = explode('},{', $buffer);
1702
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1703 1703
 		    }
1704 1704
 		    // SBS format is CSV format
1705 1705
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
 			    $ais_data = $AIS->parse_line(trim($buffer));
1727 1727
 			    $data = array();
1728 1728
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1729
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1729
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1730 1730
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1731 1731
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1732 1732
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1737,13 +1737,13 @@  discard block
 block discarded – undo
1737 1737
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1738 1738
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1739 1739
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1740
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1740
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1741 1741
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1742 1742
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1743 1743
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1744 1744
 
1745 1745
 			    if (isset($ais_data['timestamp'])) {
1746
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1746
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1747 1747
 			    } else {
1748 1748
 				$data['datetime'] = date('Y-m-d H:i:s');
1749 1749
 			    }
@@ -1754,10 +1754,10 @@  discard block
 block discarded – undo
1754 1754
                         } elseif ($format === 'flightgearsp') {
1755 1755
                     	    //echo $buffer."\n";
1756 1756
                     	    if (strlen($buffer) > 5) {
1757
-				$line = explode(',',$buffer);
1757
+				$line = explode(',', $buffer);
1758 1758
 				$data = array();
1759 1759
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1760
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1760
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1761 1761
 				$data['ident'] = $line[6];
1762 1762
 				$data['aircraft_name'] = $line[7];
1763 1763
 				$data['longitude'] = $line[1];
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
                         } elseif ($format === 'acars') {
1775 1775
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1776 1776
 			    $ACARS->add(trim($buffer));
1777
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1777
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1778 1778
 			    $ACARS->deleteLiveAcarsData();
1779 1779
 			} elseif ($format === 'acarsjsonudp') {
1780 1780
 			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
@@ -1783,15 +1783,15 @@  discard block
 block discarded – undo
1783 1783
                                 $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1784 1784
                                 $ACARS->deleteLiveAcarsData();
1785 1785
                             }
1786
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1786
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1787 1787
 			} elseif ($format === 'flightgearmp') {
1788
-			    if (substr($buffer,0,1) != '#') {
1788
+			    if (substr($buffer, 0, 1) != '#') {
1789 1789
 				$data = array();
1790 1790
 				//echo $buffer."\n";
1791
-				$line = explode(' ',$buffer);
1791
+				$line = explode(' ', $buffer);
1792 1792
 				if (count($line) === 11) {
1793
-				    $userserver = explode('@',$line[0]);
1794
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1793
+				    $userserver = explode('@', $line[0]);
1794
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1795 1795
 				    $data['ident'] = $userserver[0];
1796 1796
 				    $data['registration'] = $userserver[0];
1797 1797
 				    $data['latitude'] = $line[4];
@@ -1799,8 +1799,8 @@  discard block
 block discarded – undo
1799 1799
 				    $data['altitude'] = $line[6];
1800 1800
 				    $data['datetime'] = date('Y-m-d H:i:s');
1801 1801
 				    $aircraft_type = $line[10];
1802
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1803
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1802
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1803
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1804 1804
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1805 1805
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1806 1806
 				}
@@ -1809,8 +1809,8 @@  discard block
 block discarded – undo
1809 1809
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1810 1810
 			    die;
1811 1811
 			} elseif ($format === 'vrstcp') {
1812
-			    foreach($buffer as $all_data) {
1813
-				$line = json_decode('{'.$all_data.'}',true);
1812
+			    foreach ($buffer as $all_data) {
1813
+				$line = json_decode('{'.$all_data.'}', true);
1814 1814
 				$data = array();
1815 1815
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1816 1816
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1836,16 +1836,16 @@  discard block
 block discarded – undo
1836 1836
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1837 1837
 				unset($data);
1838 1838
 			    }
1839
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1839
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1840 1840
 			    $line = explode("\t", $buffer);
1841
-			    for($k = 0; $k < count($line); $k=$k+2) {
1841
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1842 1842
 				$key = $line[$k];
1843
-			        $lined[$key] = $line[$k+1];
1843
+			        $lined[$key] = $line[$k + 1];
1844 1844
 			    }
1845 1845
     			    if (count($lined) > 3) {
1846 1846
     				$data['hex'] = $lined['hexid'];
1847 1847
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1848
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1848
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1849 1849
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1850 1850
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1851 1851
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1864,23 +1864,23 @@  discard block
 block discarded – undo
1864 1864
     			    } else $error = true;
1865 1865
 			} elseif ($format === 'aprs' && $use_aprs) {
1866 1866
 			    if ($aprs_connect === 0) {
1867
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1867
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1868 1868
 				$aprs_connect = 1;
1869 1869
 			    }
1870 1870
 			    
1871
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1871
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1872 1872
 				$aprs_last_tx = time();
1873 1873
 				$data_aprs = "# Keep alive";
1874
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1874
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1875 1875
 			    }
1876 1876
 			    
1877 1877
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1878 1878
 			    //echo 'APRS data : '.$buffer."\n";
1879
-			    $buffer = str_replace('APRS <- ','',$buffer);
1880
-			    $buffer = str_replace('APRS -> ','',$buffer);
1879
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1880
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1881 1881
 			    //echo $buffer."\n";
1882 1882
 			    date_default_timezone_set('UTC');
1883
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1883
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1884 1884
 				$line = $APRS->parse($buffer);
1885 1885
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1886 1886
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1895,7 +1895,7 @@  discard block
 block discarded – undo
1895 1895
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1896 1896
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1897 1897
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1898
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1898
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1899 1899
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1900 1900
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1901 1901
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1983,29 +1983,29 @@  discard block
 block discarded – undo
1983 1983
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1984 1984
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1985 1985
 					$Source->deleteOldLocationByType('gs');
1986
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1987
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1986
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1987
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1988 1988
 					} else {
1989
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1989
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1990 1990
 					}
1991 1991
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1992 1992
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1993 1993
 					if ($globalDebug) echo '# Weather Station added'."\n";
1994 1994
 					$Source->deleteOldLocationByType('wx');
1995 1995
 					$weather_data = json_encode($line);
1996
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1997
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1996
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1997
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1998 1998
 					} else {
1999
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1999
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2000 2000
 					}
2001 2001
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2002 2002
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2003 2003
 					if ($globalDebug) echo '☈ Lightning added'."\n";
2004 2004
 					$Source->deleteOldLocationByType('lightning');
2005
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
2006
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2005
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
2006
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2007 2007
 					} else {
2008
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2008
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2009 2009
 					}
2010 2010
 				    } elseif ($globalDebug) {
2011 2011
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -2014,7 +2014,7 @@  discard block
 block discarded – undo
2014 2014
 				    unset($data);
2015 2015
 				}
2016 2016
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2017
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2017
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
2018 2018
 				}
2019 2019
 				/*
2020 2020
 				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')) {
@@ -2023,7 +2023,7 @@  discard block
 block discarded – undo
2023 2023
 				*/
2024 2024
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2025 2025
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2026
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2026
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
2027 2027
 					$Source->deleteOldLocationByType('lightning');
2028 2028
 					$Source->deleteOldLocationByType('wx');
2029 2029
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2110,7 +2110,7 @@  discard block
 block discarded – undo
2110 2110
 				connect_all($sourceee);
2111 2111
 				$sourceee = array();
2112 2112
 				//connect_all($globalSources);
2113
-				$tt[$format]=0;
2113
+				$tt[$format] = 0;
2114 2114
 				break;
2115 2115
 			    } 
2116 2116
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2120,14 +2120,14 @@  discard block
 block discarded – undo
2120 2120
 	    } else {
2121 2121
 		$error = socket_strerror(socket_last_error());
2122 2122
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2123
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2123
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2124 2124
 			if (isset($globalDebug)) echo "Restarting...\n";
2125 2125
 			// Restart the script if possible
2126 2126
 			if (is_array($sockets)) {
2127 2127
 			    if ($globalDebug) echo "Shutdown all sockets...";
2128 2128
 			    
2129 2129
 			    foreach ($sockets as $sock) {
2130
-				@socket_shutdown($sock,2);
2130
+				@socket_shutdown($sock, 2);
2131 2131
 				@socket_close($sock);
2132 2132
 			    }
2133 2133
 			    
Please login to merge, or discard this patch.
Braces   +1236 added lines, -416 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
26 28
 
27 29
 if ($globalInstalled === FALSE) {
28 30
     echo "This script MUST be run after install script. Use your web browser to run install/index.php";
@@ -68,66 +70,107 @@  discard block
 block discarded – undo
68 70
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 71
 if (isset($options['s'])) {
70 72
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
-    else $globalSources[] = array('host' => $options['s']);
73
-} elseif (isset($options['source'])) {
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['s']);
77
+    }
78
+    } elseif (isset($options['source'])) {
74 79
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
-    else $globalSources[] = array('host' => $options['source']);
77
-}
80
+    if (isset($options['format'])) {
81
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
82
+    } else {
83
+    	$globalSources[] = array('host' => $options['source']);
84
+    }
85
+    }
78 86
 if (isset($options['aprsserverhost'])) {
79 87
 	$globalServerAPRS = TRUE;
80 88
 	$globalServerAPRShost = $options['aprsserverhost'];
81 89
 }
82
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
83
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
84
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
85
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
90
+if (isset($options['aprsserverport'])) {
91
+	$globalServerAPRSport = $options['aprsserverport'];
92
+}
93
+if (isset($options['aprsserverssid'])) {
94
+	$globalServerAPRSssid = $options['aprsserverssid'];
95
+}
96
+if (isset($options['aprsserverpass'])) {
97
+	$globalServerAPRSpass = $options['aprsserverpass'];
98
+}
99
+if (isset($options['noaprsserver'])) {
100
+	$globalServerAPRS = FALSE;
101
+}
86 102
 if (isset($options['enable-aircraft'])) {
87
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
103
+	if ($globalDebug) {
104
+		echo 'Enable Aircraft mode'."\n";
105
+	}
88 106
 	$globalAircraft = TRUE; 
89 107
 }
90 108
 if (isset($options['disable-aircraft'])) {
91
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
109
+	if ($globalDebug) {
110
+		echo 'Disable Aircraft mode'."\n";
111
+	}
92 112
 	$globalAircraft = FALSE;
93 113
 }
94 114
 if (isset($options['enable-tracker'])) {
95
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
115
+	if ($globalDebug) {
116
+		echo 'Enable Tracker mode'."\n";
117
+	}
96 118
 	$globalTracker = TRUE; 
97 119
 }
98 120
 if (isset($options['disable-tracker'])) {
99
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
121
+	if ($globalDebug) {
122
+		echo 'Disable Tracker mode'."\n";
123
+	}
100 124
 	$globalTracker = FALSE;
101 125
 }
102 126
 if (isset($options['enable-marine'])) {
103
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
127
+	if ($globalDebug) {
128
+		echo 'Enable Marine mode'."\n";
129
+	}
104 130
 	$globalMarine = TRUE;
105 131
 }
106 132
 if (isset($options['disable-marine'])) {
107
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
133
+	if ($globalDebug) {
134
+		echo 'Disable Marine mode'."\n";
135
+	}
108 136
 	$globalMarine = FALSE;
109 137
 }
110
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
111
-if (isset($options['server'])) $globalServer = TRUE;
112
-if (isset($options['idsource'])) $id_source = $options['idsource'];
113
-else $id_source = 1;
138
+if (isset($options['nodaemon'])) {
139
+	$globalDaemon = FALSE;
140
+}
141
+if (isset($options['server'])) {
142
+	$globalServer = TRUE;
143
+}
144
+if (isset($options['idsource'])) {
145
+	$id_source = $options['idsource'];
146
+} else {
147
+	$id_source = 1;
148
+}
114 149
 if (isset($globalServer) && $globalServer) {
115
-    if ($globalDebug) echo "Using Server Mode\n";
150
+    if ($globalDebug) {
151
+    	echo "Using Server Mode\n";
152
+    }
116 153
     $SI=new SpotterServer();
117 154
 /*
118 155
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 156
     $SI = new adsb2aprs();
120 157
     $SI->connect();
121 158
 */
122
-} else $SI=new SpotterImport($Connection->db);
159
+} else {
160
+	$SI=new SpotterImport($Connection->db);
161
+}
123 162
 
124
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
163
+if (isset($globalTracker) && $globalTracker) {
164
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
165
+}
125 166
 if (isset($globalMarine) && $globalMarine) {
126 167
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
127 168
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
128 169
 }
129 170
 
130
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
171
+if (isset($globalTracker) && $globalTracker) {
172
+	$TI = new TrackerImport($Connection->db);
173
+}
131 174
 if (isset($globalMarine) && $globalMarine) {
132 175
     $AIS = new AIS();
133 176
     $MI = new MarineImport($Connection->db);
@@ -152,7 +195,9 @@  discard block
 block discarded – undo
152 195
 }
153 196
 
154 197
 // let's try and connect
155
-if ($globalDebug) echo "Connecting...\n";
198
+if ($globalDebug) {
199
+	echo "Connecting...\n";
200
+}
156 201
 $use_aprs = false;
157 202
 $aprs_full = false;
158 203
 $reset = 0;
@@ -161,7 +206,9 @@  discard block
 block discarded – undo
161 206
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162 207
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163 208
     $reset++;
164
-    if ($globalDebug) echo 'Connect to all...'."\n";
209
+    if ($globalDebug) {
210
+    	echo 'Connect to all...'."\n";
211
+    }
165 212
     foreach ($hosts as $id => $value) {
166 213
 	$host = $value['host'];
167 214
 	$udp = false;
@@ -172,32 +219,44 @@  discard block
 block discarded – undo
172 219
         	//$formats[$id] = 'deltadbtxt';
173 220
         	$globalSources[$id]['format'] = 'deltadbtxt';
174 221
         	//$last_exec['deltadbtxt'] = 0;
175
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
222
+        	if ($globalDebug) {
223
+        		echo "Connect to deltadb source (".$host.")...\n";
224
+        	}
176 225
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
177 226
         	//$formats[$id] = 'vatsimtxt';
178 227
         	$globalSources[$id]['format'] = 'vatsimtxt';
179 228
         	//$last_exec['vatsimtxt'] = 0;
180
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
229
+        	if ($globalDebug) {
230
+        		echo "Connect to vatsim source (".$host.")...\n";
231
+        	}
181 232
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
182 233
         	//$formats[$id] = 'aircraftlistjson';
183 234
         	$globalSources[$id]['format'] = 'aircraftlistjson';
184 235
         	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
236
+        	if ($globalDebug) {
237
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
238
+        	}
186 239
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
187 240
         	//$formats[$id] = 'aircraftjson';
188 241
         	$globalSources[$id]['format'] = 'aircraftjson';
189 242
         	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
243
+        	if ($globalDebug) {
244
+        		echo "Connect to aircraft.json source (".$host.")...\n";
245
+        	}
191 246
     	    } else if (preg_match('/aircraft$/i',$host)) {
192 247
         	//$formats[$id] = 'planefinderclient';
193 248
         	$globalSources[$id]['format'] = 'planefinderclient';
194 249
         	//$last_exec['aircraftlistjson'] = 0;
195
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
250
+        	if ($globalDebug) {
251
+        		echo "Connect to planefinderclient source (".$host.")...\n";
252
+        	}
196 253
     	    } else if (preg_match('/opensky/i',$host)) {
197 254
         	//$formats[$id] = 'aircraftlistjson';
198 255
         	$globalSources[$id]['format'] = 'opensky';
199 256
         	//$last_exec['aircraftlistjson'] = 0;
200
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
257
+        	if ($globalDebug) {
258
+        		echo "Connect to opensky source (".$host.")...\n";
259
+        	}
201 260
     	    /*
202 261
     	    // Disabled for now, site change source format
203 262
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -214,7 +273,9 @@  discard block
 block discarded – undo
214 273
         	//$formats[$id] = 'planeupdatefaa';
215 274
         	$globalSources[$id]['format'] = 'planeupdatefaa';
216 275
         	//$last_exec['planeupdatefaa'] = 0;
217
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
276
+        	if ($globalDebug) {
277
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
278
+        	}
218 279
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
219 280
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220 281
         	    exit(0);
@@ -223,37 +284,53 @@  discard block
 block discarded – undo
223 284
         	//$formats[$id] = 'phpvmacars';
224 285
         	$globalSources[$id]['format'] = 'phpvmacars';
225 286
         	//$last_exec['phpvmacars'] = 0;
226
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
287
+        	if ($globalDebug) {
288
+        		echo "Connect to phpvmacars source (".$host.")...\n";
289
+        	}
227 290
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
228 291
         	//$formats[$id] = 'phpvmacars';
229 292
         	$globalSources[$id]['format'] = 'vaos';
230 293
         	//$last_exec['phpvmacars'] = 0;
231
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
294
+        	if ($globalDebug) {
295
+        		echo "Connect to vaos source (".$host.")...\n";
296
+        	}
232 297
             } else if (preg_match('/VAM-json.php$/i',$host)) {
233 298
         	//$formats[$id] = 'phpvmacars';
234 299
         	$globalSources[$id]['format'] = 'vam';
235
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
300
+        	if ($globalDebug) {
301
+        		echo "Connect to Vam source (".$host.")...\n";
302
+        	}
236 303
             } else if (preg_match('/whazzup/i',$host)) {
237 304
         	//$formats[$id] = 'whazzup';
238 305
         	$globalSources[$id]['format'] = 'whazzup';
239 306
         	//$last_exec['whazzup'] = 0;
240
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
307
+        	if ($globalDebug) {
308
+        		echo "Connect to whazzup source (".$host.")...\n";
309
+        	}
241 310
             } else if (preg_match('/blitzortung/i',$host)) {
242 311
         	$globalSources[$id]['format'] = 'blitzortung';
243
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
312
+        	if ($globalDebug) {
313
+        		echo "Connect to blitzortung source (".$host.")...\n";
314
+        	}
244 315
             } else if (preg_match('/airwhere/i',$host)) {
245 316
         	$globalSources[$id]['format'] = 'airwhere';
246
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
317
+        	if ($globalDebug) {
318
+        		echo "Connect to airwhere source (".$host.")...\n";
319
+        	}
247 320
             } else if (preg_match('/recentpireps/i',$host)) {
248 321
         	//$formats[$id] = 'pirepsjson';
249 322
         	$globalSources[$id]['format'] = 'pirepsjson';
250 323
         	//$last_exec['pirepsjson'] = 0;
251
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
324
+        	if ($globalDebug) {
325
+        		echo "Connect to pirepsjson source (".$host.")...\n";
326
+        	}
252 327
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
253 328
         	//$formats[$id] = 'fr24json';
254 329
         	$globalSources[$id]['format'] = 'fr24json';
255 330
         	//$last_exec['fr24json'] = 0;
256
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
331
+        	if ($globalDebug) {
332
+        		echo "Connect to fr24 source (".$host.")...\n";
333
+        	}
257 334
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
258 335
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259 336
         	    exit(0);
@@ -262,7 +339,9 @@  discard block
 block discarded – undo
262 339
         	//$formats[$id] = 'fr24json';
263 340
         	$globalSources[$id]['format'] = 'myshiptracking';
264 341
         	//$last_exec['fr24json'] = 0;
265
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
342
+        	if ($globalDebug) {
343
+        		echo "Connect to myshiptracking source (".$host.")...\n";
344
+        	}
266 345
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
267 346
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
268 347
         	    exit(0);
@@ -271,17 +350,26 @@  discard block
 block discarded – undo
271 350
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272 351
         	//$formats[$id] = 'tsv';
273 352
         	$globalSources[$id]['format'] = 'tsv';
274
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
353
+        	if ($globalDebug) {
354
+        		echo "Connect to tsv source (".$host.")...\n";
355
+        	}
275 356
             }
276 357
         } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277 358
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278 359
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
279 360
     		    if ($idf !== false) {
280 361
     			$httpfeeds[$id] = $idf;
281
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
362
+        		if ($globalDebug) {
363
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
364
+        		}
365
+    		    } elseif ($globalDebug) {
366
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
367
+    		    }
368
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') {
369
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
370
+    		} elseif ($globalDebug) {
371
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
372
+    		}
285 373
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
286 374
 	    $hostport = explode(':',$host);
287 375
 	    if (isset($hostport[1])) {
@@ -322,20 +410,29 @@  discard block
 block discarded – undo
322 410
         		//$formats[$id] = 'beast';
323 411
         		$globalSources[$id]['format'] = 'beast';
324 412
 		    //} else $formats[$id] = 'sbs';
325
-		    } else $globalSources[$id]['format'] = 'sbs';
413
+		    } else {
414
+		    	$globalSources[$id]['format'] = 'sbs';
415
+		    }
326 416
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
327 417
 		}
328
-		if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
329
-		elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
418
+		if ($globalDebug && $udp) {
419
+			echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
420
+		} elseif ($globalDebug) {
421
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
422
+		}
330 423
             } else {
331
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
424
+		if ($globalDebug) {
425
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
426
+		}
332 427
 		sleep(10);
333 428
 		connect_all($hosts);
334 429
     	    }
335 430
         }
336 431
     }
337 432
 }
338
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
433
+if (!isset($globalMinFetch)) {
434
+	$globalMinFetch = 15;
435
+}
339 436
 
340 437
 // Initialize all
341 438
 $status = array();
@@ -344,13 +441,19 @@  discard block
 block discarded – undo
344 441
 $formats = array();
345 442
 $last_exec = array();
346 443
 $time = time();
347
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
348
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
349
-else $timeout = 20;
444
+if (isset($globalSourcesTimeout)) {
445
+	$timeout = $globalSourcesTimeOut;
446
+} else if (isset($globalSBS1TimeOut)) {
447
+	$timeout = $globalSBS1TimeOut;
448
+} else {
449
+	$timeout = 20;
450
+}
350 451
 $errno = '';
351 452
 $errstr='';
352 453
 
353
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
454
+if (!isset($globalDaemon)) {
455
+	$globalDaemon = TRUE;
456
+}
354 457
 /* Initiate connections to all the hosts simultaneously */
355 458
 //connect_all($hosts);
356 459
 //connect_all($globalSources);
@@ -379,7 +482,9 @@  discard block
 block discarded – undo
379 482
     if (isset($source['format']) && $source['format'] == 'aprs') {
380 483
 	$aprs_connect = 0;
381 484
 	$use_aprs = true;
382
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
485
+	if (isset($source['port']) && $source['port'] == '10152') {
486
+		$aprs_full = true;
487
+	}
383 488
 	break;
384 489
     }
385 490
 }
@@ -390,25 +495,46 @@  discard block
 block discarded – undo
390 495
 	$aprs_connect = 0;
391 496
 	$aprs_keep = 120;
392 497
 	$aprs_last_tx = time();
393
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
394
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
395
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
396
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
397
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
398
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
399
-	if ($aprs_full) $aprs_filter = '';
400
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
401
-	else $aprs_pass = '-1';
498
+	if (isset($globalAPRSversion)) {
499
+		$aprs_version = $globalAPRSversion;
500
+	} else {
501
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
502
+	}
503
+	if (isset($globalAPRSssid)) {
504
+		$aprs_ssid = $globalAPRSssid;
505
+	} else {
506
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
507
+	}
508
+	if (isset($globalAPRSfilter)) {
509
+		$aprs_filter = $globalAPRSfilter;
510
+	} else {
511
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
512
+	}
513
+	if ($aprs_full) {
514
+		$aprs_filter = '';
515
+	}
516
+	if (isset($globalAPRSpass)) {
517
+		$aprs_pass = $globalAPRSpass;
518
+	} else {
519
+		$aprs_pass = '-1';
520
+	}
402 521
 
403
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
404
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
405
-}
522
+	if ($aprs_filter != '') {
523
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
524
+	} else {
525
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
526
+	}
527
+	}
406 528
 
407 529
 // connected - lets do some work
408 530
 //if ($globalDebug) echo "Connected!\n";
409 531
 sleep(1);
410
-if ($globalDebug) echo "SCAN MODE \n\n";
411
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
532
+if ($globalDebug) {
533
+	echo "SCAN MODE \n\n";
534
+}
535
+if (!isset($globalCronEnd)) {
536
+	$globalCronEnd = 60;
537
+}
412 538
 $endtime = time()+$globalCronEnd;
413 539
 $i = 1;
414 540
 $tt = array();
@@ -422,22 +548,32 @@  discard block
 block discarded – undo
422 548
 
423 549
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
424 550
 while ($i > 0) {
425
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
551
+    if (function_exists('pcntl_fork')) {
552
+    	pcntl_signal_dispatch();
553
+    }
426 554
 
427
-    if (!$globalDaemon) $i = $endtime-time();
555
+    if (!$globalDaemon) {
556
+    	$i = $endtime-time();
557
+    }
428 558
     // Delete old ATC
429 559
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
430
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
560
+	if ($globalDebug) {
561
+		echo 'Delete old ATC...'."\n";
562
+	}
431 563
         $ATC->deleteOldATC();
432 564
     }
433 565
     
434 566
     if (count($last_exec) == count($globalSources)) {
435 567
 	$max = $globalMinFetch;
436 568
 	foreach ($last_exec as $last) {
437
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
569
+	    if ((time() - $last['last']) < $max) {
570
+	    	$max = time() - $last['last'];
571
+	    }
438 572
 	}
439 573
 	if ($max < $globalMinFetch) {
440
-	    if ($globalDebug) echo 'Sleeping...'."\n";
574
+	    if ($globalDebug) {
575
+	    	echo 'Sleeping...'."\n";
576
+	    }
441 577
 	    sleep($globalMinFetch-$max+2);
442 578
 	}
443 579
     }
@@ -447,7 +583,9 @@  discard block
 block discarded – undo
447 583
     foreach ($globalSources as $id => $value) {
448 584
 	date_default_timezone_set('UTC');
449 585
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
450
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
586
+	if (!isset($last_exec[$id]['last'])) {
587
+		$last_exec[$id]['last'] = 0;
588
+	}
451 589
 	if ($value['format'] === 'deltadbtxt' && 
452 590
 	    (
453 591
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -456,7 +594,9 @@  discard block
 block discarded – undo
456 594
 	) {
457 595
         //$buffer = $Common->getData($hosts[$id]);
458 596
         $buffer = $Common->getData($value['host']);
459
-        if ($buffer != '') $reset = 0;
597
+        if ($buffer != '') {
598
+        	$reset = 0;
599
+        }
460 600
         $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
461 601
         $buffer = explode('\n', $buffer);
462 602
         foreach ($buffer as $line) {
@@ -465,20 +605,41 @@  discard block
 block discarded – undo
465 605
                 $data = array();
466 606
                 $data['hex'] = $line[1]; // hex
467 607
                 $data['ident'] = $line[2]; // ident
468
-                if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
469
-                if (isset($line[4])) $data['speed'] = $line[4]; // speed
470
-                if (isset($line[5])) $data['heading'] = $line[5]; // heading
471
-                if (isset($line[6])) $data['latitude'] = $line[6]; // lat
472
-                if (isset($line[7])) $data['longitude'] = $line[7]; // long
608
+                if (isset($line[3])) {
609
+                	$data['altitude'] = $line[3];
610
+                }
611
+                // altitude
612
+                if (isset($line[4])) {
613
+                	$data['speed'] = $line[4];
614
+                }
615
+                // speed
616
+                if (isset($line[5])) {
617
+                	$data['heading'] = $line[5];
618
+                }
619
+                // heading
620
+                if (isset($line[6])) {
621
+                	$data['latitude'] = $line[6];
622
+                }
623
+                // lat
624
+                if (isset($line[7])) {
625
+                	$data['longitude'] = $line[7];
626
+                }
627
+                // long
473 628
                 $data['verticalrate'] = ''; // vertical rate
474 629
                 //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
475 630
                 $data['emergency'] = ''; // emergency
476 631
                 $data['datetime'] = date('Y-m-d H:i:s');
477 632
                 $data['format_source'] = 'deltadbtxt';
478 633
                 $data['id_source'] = $id_source;
479
-                if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
480
-                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
481
-                if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
634
+                if (isset($value['name']) && $value['name'] != '') {
635
+                	$data['source_name'] = $value['name'];
636
+                }
637
+                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
638
+                	$data['noarchive'] = true;
639
+                }
640
+                if (isset($value['sourcestats'])) {
641
+                	$data['sourcestats'] = $value['sourcestats'];
642
+                }
482 643
                 $SI->add($data);
483 644
                 unset($data);
484 645
             }
@@ -513,11 +674,20 @@  discard block
 block discarded – undo
513 674
                     $data['format_source'] = 'radarcapejson';
514 675
                     $data['id_source'] = $id_source;
515 676
                     if (isset($value['name']) && $value['name'] != '') {
516
-                        if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
517
-                        else $data['source_name'] = $value['name'];
518
-                    } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
519
-                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
520
-                    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
677
+                        if (isset($line['src']) && !$line['src'] == 'M') {
678
+                        	$data['source_name'] = $value['name'].'_MLAT';
679
+                        } else {
680
+                        	$data['source_name'] = $value['name'];
681
+                        }
682
+                    } elseif (isset($line['src']) && $line['src'] == 'M') {
683
+                    	$data['source_name'] = 'MLAT';
684
+                    }
685
+                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
686
+                    	$data['noarchive'] = true;
687
+                    }
688
+                    if (isset($value['sourcestats'])) {
689
+                    	$data['sourcestats'] = $value['sourcestats'];
690
+                    }
521 691
 
522 692
                     $SI->add($data);
523 693
                     unset($data);
@@ -533,7 +703,9 @@  discard block
 block discarded – undo
533 703
 	    date_default_timezone_set('CET');
534 704
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
535 705
 	    date_default_timezone_set('UTC');
536
-	    if ($buffer != '') $reset = 0;
706
+	    if ($buffer != '') {
707
+	    	$reset = 0;
708
+	    }
537 709
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
538 710
 	    $buffer = explode('\n',$buffer);
539 711
 	    foreach ($buffer as $line) {
@@ -542,18 +714,42 @@  discard block
 block discarded – undo
542 714
 		    $add = false;
543 715
 		    $ais_data = $AIS->parse_line(trim($line));
544 716
 		    $data = array();
545
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
546
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
547
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
548
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
549
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
550
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
551
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
552
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
553
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
554
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
555
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
556
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
717
+		    if (isset($ais_data['ident'])) {
718
+		    	$data['ident'] = $ais_data['ident'];
719
+		    }
720
+		    if (isset($ais_data['mmsi'])) {
721
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
722
+		    }
723
+		    if (isset($ais_data['speed'])) {
724
+		    	$data['speed'] = $ais_data['speed'];
725
+		    }
726
+		    if (isset($ais_data['heading'])) {
727
+		    	$data['heading'] = $ais_data['heading'];
728
+		    }
729
+		    if (isset($ais_data['latitude'])) {
730
+		    	$data['latitude'] = $ais_data['latitude'];
731
+		    }
732
+		    if (isset($ais_data['longitude'])) {
733
+		    	$data['longitude'] = $ais_data['longitude'];
734
+		    }
735
+		    if (isset($ais_data['status'])) {
736
+		    	$data['status'] = $ais_data['status'];
737
+		    }
738
+		    if (isset($ais_data['statusid'])) {
739
+		    	$data['status_id'] = $ais_data['statusid'];
740
+		    }
741
+		    if (isset($ais_data['type'])) {
742
+		    	$data['type'] = $ais_data['type'];
743
+		    }
744
+		    if (isset($ais_data['typeid'])) {
745
+		    	$data['type_id'] = $ais_data['typeid'];
746
+		    }
747
+		    if (isset($ais_data['imo'])) {
748
+		    	$data['imo'] = $ais_data['imo'];
749
+		    }
750
+		    if (isset($ais_data['callsign'])) {
751
+		    	$data['callsign'] = $ais_data['callsign'];
752
+		    }
557 753
 		    if (isset($ais_data['timestamp'])) {
558 754
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
559 755
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -567,8 +763,12 @@  discard block
 block discarded – undo
567 763
 		    $data['format_source'] = 'aisnmeatxt';
568 764
     		    $data['id_source'] = $id_source;
569 765
 		    //print_r($data);
570
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
571
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
766
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
767
+		    	$data['noarchive'] = true;
768
+		    }
769
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
770
+		    	$MI->add($data);
771
+		    }
572 772
 		    unset($data);
573 773
 		}
574 774
     	    }
@@ -591,20 +791,48 @@  discard block
 block discarded – undo
591 791
 			    if ($line != '') {
592 792
 				$ais_data = $AIS->parse_line(trim($line));
593 793
 				$data = array();
594
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
595
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
596
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
597
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
598
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
599
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
600
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
601
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
602
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
603
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
604
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
605
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
606
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
607
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
794
+				if (isset($ais_data['ident'])) {
795
+					$data['ident'] = $ais_data['ident'];
796
+				}
797
+				if (isset($ais_data['mmsi'])) {
798
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
799
+				}
800
+				if (isset($ais_data['speed'])) {
801
+					$data['speed'] = $ais_data['speed'];
802
+				}
803
+				if (isset($ais_data['heading'])) {
804
+					$data['heading'] = $ais_data['heading'];
805
+				}
806
+				if (isset($ais_data['latitude'])) {
807
+					$data['latitude'] = $ais_data['latitude'];
808
+				}
809
+				if (isset($ais_data['longitude'])) {
810
+					$data['longitude'] = $ais_data['longitude'];
811
+				}
812
+				if (isset($ais_data['status'])) {
813
+					$data['status'] = $ais_data['status'];
814
+				}
815
+				if (isset($ais_data['statusid'])) {
816
+					$data['status_id'] = $ais_data['statusid'];
817
+				}
818
+				if (isset($ais_data['type'])) {
819
+					$data['type'] = $ais_data['type'];
820
+				}
821
+				if (isset($ais_data['typeid'])) {
822
+					$data['type_id'] = $ais_data['typeid'];
823
+				}
824
+				if (isset($ais_data['imo'])) {
825
+					$data['imo'] = $ais_data['imo'];
826
+				}
827
+				if (isset($ais_data['callsign'])) {
828
+					$data['callsign'] = $ais_data['callsign'];
829
+				}
830
+				if (isset($ais_data['destination'])) {
831
+					$data['arrival_code'] = $ais_data['destination'];
832
+				}
833
+				if (isset($ais_data['eta_ts'])) {
834
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
835
+				}
608 836
 				if (isset($ais_data['timestamp'])) {
609 837
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
610 838
 				} else {
@@ -612,18 +840,27 @@  discard block
 block discarded – undo
612 840
 				}
613 841
 				$data['format_source'] = 'aisnmeahttp';
614 842
 				$data['id_source'] = $id_source;
615
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
616
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
843
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
844
+					$data['noarchive'] = true;
845
+				}
846
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
847
+					$MI->add($data);
848
+				}
617 849
 				unset($data);
618 850
 			    }
619 851
 			}
620 852
 		    }
621 853
 		} else {
622 854
 		    $format = $value['format'];
623
-		    if (isset($tt[$format])) $tt[$format]++;
624
-		    else $tt[$format] = 0;
855
+		    if (isset($tt[$format])) {
856
+		    	$tt[$format]++;
857
+		    } else {
858
+		    	$tt[$format] = 0;
859
+		    }
625 860
 		    if ($tt[$format] > 30) {
626
-			if ($globalDebug) echo 'Reconnect...'."\n";
861
+			if ($globalDebug) {
862
+				echo 'Reconnect...'."\n";
863
+			}
627 864
 			sleep(2);
628 865
 			//$sourceeen[] = $value;
629 866
 			//connect_all($sourceeen);
@@ -659,12 +896,18 @@  discard block
 block discarded – undo
659 896
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
660 897
 			    //$data['type_id'] = $line['TYPE'];
661 898
 			    $data['imo'] = $line['IMO'];
662
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
663
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
899
+			    if ($line['DEST'] != '') {
900
+			    	$data['arrival_code'] = $line['DEST'];
901
+			    }
902
+			    if ($line['ARV'] != '') {
903
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
904
+			    }
664 905
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
665 906
 			    $data['format_source'] = 'myshiptracking';
666 907
 			    $data['id_source'] = $id_source;
667
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
909
+			    	$data['noarchive'] = true;
910
+			    }
668 911
 			    $MI->add($data);
669 912
 			    unset($data);
670 913
 			}
@@ -689,7 +932,9 @@  discard block
 block discarded – undo
689 932
 			    $data['callsign'] = $line['callsign'];
690 933
 			    $data['mmsi'] = substr($line['mmsi'],-9);
691 934
 			    $data['speed'] = $line['sog'];
692
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
935
+			    if ($line['heading'] != '511') {
936
+			    	$data['heading'] = $line['heading'];
937
+			    }
693 938
 			    $data['latitude'] = $line['latitude'];
694 939
 			    $data['longitude'] = $line['longitude'];
695 940
 			    $data['type_id'] = $line['shiptype'];
@@ -697,7 +942,9 @@  discard block
 block discarded – undo
697 942
 			    $data['datetime'] = $line['time'];
698 943
 			    $data['format_source'] = 'boatbeaconapp';
699 944
 			    $data['id_source'] = $id_source;
700
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
945
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
946
+			    	$data['noarchive'] = true;
947
+			    }
701 948
 			    $MI->add($data);
702 949
 			    unset($data);
703 950
 			}
@@ -719,22 +966,44 @@  discard block
 block discarded – undo
719 966
 		    foreach ($all_data['features'] as $line) {
720 967
 			print_r($line);
721 968
 			$data = array();
722
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
723
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
724
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
725
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
726
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
727
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
969
+			if (isset($line['properties']['name'])) {
970
+				$data['ident'] = $line['properties']['name'];
971
+			}
972
+			if (isset($line['properties']['callsign'])) {
973
+				$data['callsign'] = $line['properties']['callsign'];
974
+			}
975
+			if (isset($line['properties']['mmsi'])) {
976
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
977
+			}
978
+			if (isset($line['properties']['imo'])) {
979
+				$data['imo'] = $line['properties']['imo'];
980
+			}
981
+			if (isset($line['properties']['speed'])) {
982
+				$data['speed'] = $line['properties']['speed'];
983
+			}
984
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
985
+				$data['heading'] = $line['properties']['heading'];
986
+			}
728 987
 			$data['latitude'] = $line['geometry']['coordinates'][1];
729 988
 			$data['longitude'] = $line['geometry']['coordinates'][0];
730
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
731
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
732
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
989
+			if (isset($line['properties']['vesselType'])) {
990
+				$data['type'] = $line['properties']['vesselType'];
991
+			}
992
+			if (isset($line['properties']['destination'])) {
993
+				$data['arrival_code'] = $line['properties']['destination'];
994
+			}
995
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
996
+				$data['arrival_date'] = $line['properties']['eta'];
997
+			}
733 998
 			$data['format_source'] = 'boatnerd';
734 999
 			$data['id_source'] = $id_source;
735 1000
 			$data['datetime'] = date('Y-m-d H:i:s');
736
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
737
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
1001
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1002
+				$data['noarchive'] = true;
1003
+			}
1004
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
1005
+				$MI->add($data);
1006
+			}
738 1007
 			unset($data);
739 1008
 		    }
740 1009
 		}
@@ -747,11 +1016,17 @@  discard block
 block discarded – undo
747 1016
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
748 1017
 	    )
749 1018
 	) {
750
-	    if ($globalDebug) echo 'download...';
1019
+	    if ($globalDebug) {
1020
+	    	echo 'download...';
1021
+	    }
751 1022
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
752
-	    if ($globalDebug) echo 'done !'."\n";
1023
+	    if ($globalDebug) {
1024
+	    	echo 'done !'."\n";
1025
+	    }
753 1026
 	    // FIXME: Need more work
754
-	    if ($buffer != '') $reset = 0;
1027
+	    if ($buffer != '') {
1028
+	    	$reset = 0;
1029
+	    }
755 1030
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
756 1031
 	    $buffer = explode('\n',$buffer);
757 1032
 	    foreach ($buffer as $line) {
@@ -777,7 +1052,9 @@  discard block
 block discarded – undo
777 1052
 		    //$data['etaTime'] = substr($line,135,5);
778 1053
 		    $data['format_source'] = 'shipplotter';
779 1054
     		    $data['id_source'] = $id_source;
780
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1055
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1056
+		    	$data['noarchive'] = true;
1057
+		    }
781 1058
 		    //print_r($data);
782 1059
 		    //echo 'Add...'."\n";
783 1060
 		    $MI->add($data);
@@ -800,11 +1077,17 @@  discard block
 block discarded – undo
800 1077
 		}
801 1078
 	    }
802 1079
 
803
-	    if ($globalDebug) echo '! Download... ';
1080
+	    if ($globalDebug) {
1081
+	    	echo '! Download... ';
1082
+	    }
804 1083
 	    for ($i =0; $i <= 1; $i++) {
805
-		if ($globalDebug) echo 'Racetype: '.$i.' ';
1084
+		if ($globalDebug) {
1085
+			echo 'Racetype: '.$i.' ';
1086
+		}
806 1087
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
807
-	    if ($globalDebug) echo 'done'."\n";
1088
+	    if ($globalDebug) {
1089
+	    	echo 'done'."\n";
1090
+	    }
808 1091
 	    if ($buffer != '') {
809 1092
 		$all_data = json_decode($buffer,true);
810 1093
 		if (isset($all_data['missions'])) {
@@ -812,8 +1095,11 @@  discard block
 block discarded – undo
812 1095
 				$mission_user = $mission['usrname'];
813 1096
 				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
814 1097
 				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
815
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
816
-					else $racebuffer = '';
1098
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') {
1099
+						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
1100
+					} else {
1101
+						$racebuffer = '';
1102
+					}
817 1103
 					$bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
818 1104
 				} else {
819 1105
 					$bufferm = '';
@@ -877,7 +1163,9 @@  discard block
 block discarded – undo
877 1163
 								$data['captain_id'] = $sail['usrnr'];
878 1164
 								$data['captain_name'] = $sail['usrname'];
879 1165
 								$data['race_id'] = $sail['misnr'];
880
-								if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank'];
1166
+								if ($sail['rank'] != 'DNF') {
1167
+									$data['race_rank'] = $sail['rank'];
1168
+								}
881 1169
 								$data['race_time'] = $sail['racetime'];
882 1170
 								if ($mission_user != '') {
883 1171
 									$data['race_name'] = $mission_name.' ('.$mission_user.')';
@@ -887,7 +1175,9 @@  discard block
 block discarded – undo
887 1175
 								//$data['callsign'] = trim(substr($line,100,7);
888 1176
 								$data['format_source'] = 'sailaway';
889 1177
 								$data['id_source'] = $id_source;
890
-								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1178
+								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1179
+									$data['noarchive'] = true;
1180
+								}
891 1181
 								//print_r($data);
892 1182
 								//if ($data['race_id'] == '48') print_r($data);
893 1183
 								//echo 'Add...'."\n";
@@ -929,16 +1219,28 @@  discard block
 block discarded – undo
929 1219
     		    $line = explode(':', $line);
930 1220
     		    if (count($line) > 30 && $line[0] != 'callsign') {
931 1221
 			$data = array();
932
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
933
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1222
+			if (isset($line[37]) && $line[37] != '') {
1223
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1224
+			} else {
1225
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1226
+			}
934 1227
 			$data['pilot_id'] = $line[1];
935 1228
 			$data['pilot_name'] = $line[2];
936 1229
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
937 1230
 			$data['ident'] = $line[0]; // ident
938
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1231
+			if ($line[7] != '' && $line[7] != 0) {
1232
+				$data['altitude'] = $line[7];
1233
+			}
1234
+			// altitude
939 1235
 			$data['speed'] = $line[8]; // speed
940
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
941
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1236
+			if (isset($line[45])) {
1237
+				$data['heading'] = $line[45];
1238
+			}
1239
+			// heading
1240
+			elseif (isset($line[38])) {
1241
+				$data['heading'] = $line[38];
1242
+			}
1243
+			// heading
942 1244
 			$data['latitude'] = $line[5]; // lat
943 1245
 	        	$data['longitude'] = $line[6]; // long
944 1246
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -954,7 +1256,9 @@  discard block
 block discarded – undo
954 1256
 			$data['frequency'] = $line[4];
955 1257
 			$data['type'] = $line[18];
956 1258
 			$data['range'] = $line[19];
957
-			if (isset($line[35])) $data['info'] = $line[35];
1259
+			if (isset($line[35])) {
1260
+				$data['info'] = $line[35];
1261
+			}
958 1262
     			$data['id_source'] = $id_source;
959 1263
 	    		//$data['arrival_airport_time'] = ;
960 1264
 	    		if ($line[9] != '') {
@@ -968,27 +1272,47 @@  discard block
 block discarded – undo
968 1272
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
969 1273
 	    		*/
970 1274
 	    		$data['format_source'] = $value['format'];
971
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
972
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
973
-    			if ($line[3] === 'PILOT') $SI->add($data);
974
-			elseif ($line[3] === 'ATC') {
1275
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1276
+				$data['noarchive'] = true;
1277
+			}
1278
+			if (isset($value['name']) && $value['name'] != '') {
1279
+				$data['source_name'] = $value['name'];
1280
+			}
1281
+    			if ($line[3] === 'PILOT') {
1282
+    				$SI->add($data);
1283
+    			} elseif ($line[3] === 'ATC') {
975 1284
 				//print_r($data);
976 1285
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
977 1286
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
978 1287
 				$typec = substr($data['ident'],-3);
979
-				if ($typec === 'APP') $data['type'] = 'Approach';
980
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
981
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
982
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
983
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
984
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
985
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
986
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
987
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
988
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1288
+				if ($typec === 'APP') {
1289
+					$data['type'] = 'Approach';
1290
+				} elseif ($typec === 'TWR') {
1291
+					$data['type'] = 'Tower';
1292
+				} elseif ($typec === 'OBS') {
1293
+					$data['type'] = 'Observer';
1294
+				} elseif ($typec === 'GND') {
1295
+					$data['type'] = 'Ground';
1296
+				} elseif ($typec === 'DEL') {
1297
+					$data['type'] = 'Delivery';
1298
+				} elseif ($typec === 'DEP') {
1299
+					$data['type'] = 'Departure';
1300
+				} elseif ($typec === 'FSS') {
1301
+					$data['type'] = 'Flight Service Station';
1302
+				} elseif ($typec === 'CTR') {
1303
+					$data['type'] = 'Control Radar or Centre';
1304
+				} elseif ($data['type'] === '') {
1305
+					$data['type'] = 'Observer';
1306
+				}
1307
+				if (!isset($data['source_name'])) {
1308
+					$data['source_name'] = '';
1309
+				}
989 1310
 				if (isset($ATC)) {
990
-					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']);
991
-					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']);
1311
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1312
+						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']);
1313
+					} else {
1314
+						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']);
1315
+					}
992 1316
 				}
993 1317
 			}
994 1318
     			unset($data);
@@ -1015,14 +1339,20 @@  discard block
 block discarded – undo
1015 1339
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1016 1340
 			$data['latitude'] = (float)$line['pktLatitude'];
1017 1341
 			$data['longitude'] = (float)$line['pktLongitude'];
1018
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1019
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1342
+			if ((float)$line['pktTrack'] != 0) {
1343
+				$data['heading'] = (float)$line['pktTrack'];
1344
+			}
1345
+			if ((int)$line['pktSpeed'] != 0) {
1346
+				$data['speed'] = (int)$line['pktSpeed'];
1347
+			}
1020 1348
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1021 1349
 			$data['altitude_relative'] = 'AMSL';
1022 1350
 			$data['pilot_id'] = (int)$line['pktPilotID'];
1023 1351
 			$data['aircraft_icao'] = 'PARAGLIDER';
1024 1352
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1025
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1353
+			if (isset($pilot_data[4])) {
1354
+				$data['pilot_name'] = $pilot_data[4];
1355
+			}
1026 1356
 			$data['format_source'] = $value['format'];
1027 1357
 			$SI->add($data);
1028 1358
 			unset($data);
@@ -1070,25 +1400,59 @@  discard block
 block discarded – undo
1070 1400
 		    foreach ($all_data['acList'] as $line) {
1071 1401
 			$data = array();
1072 1402
 			$data['hex'] = $line['Icao']; // hex
1073
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1074
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1075
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1076
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1077
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1078
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1403
+			if (isset($line['Call'])) {
1404
+				$data['ident'] = $line['Call'];
1405
+			}
1406
+			// ident
1407
+			if (isset($line['Alt'])) {
1408
+				$data['altitude'] = $line['Alt'];
1409
+			}
1410
+			// altitude
1411
+			if (isset($line['Spd'])) {
1412
+				$data['speed'] = $line['Spd'];
1413
+			}
1414
+			// speed
1415
+			if (isset($line['Trak'])) {
1416
+				$data['heading'] = $line['Trak'];
1417
+			}
1418
+			// heading
1419
+			if (isset($line['Lat'])) {
1420
+				$data['latitude'] = $line['Lat'];
1421
+			}
1422
+			// lat
1423
+			if (isset($line['Long'])) {
1424
+				$data['longitude'] = $line['Long'];
1425
+			}
1426
+			// long
1079 1427
 			//$data['verticalrate'] = $line['']; // verticale rate
1080
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1428
+			if (isset($line['Sqk'])) {
1429
+				$data['squawk'] = $line['Sqk'];
1430
+			}
1431
+			// squawk
1081 1432
 			$data['emergency'] = ''; // emergency
1082
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1083
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1084
-			else $data['datetime'] = date('Y-m-d H:i:s');
1433
+			if (isset($line['Reg'])) {
1434
+				$data['registration'] = $line['Reg'];
1435
+			}
1436
+			if (isset($line['PosTime'])) {
1437
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1438
+			} else {
1439
+				$data['datetime'] = date('Y-m-d H:i:s');
1440
+			}
1085 1441
 			//$data['datetime'] = date('Y-m-d H:i:s');
1086
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1442
+			if (isset($line['Type'])) {
1443
+				$data['aircraft_icao'] = $line['Type'];
1444
+			}
1087 1445
 			$data['format_source'] = 'aircraftlistjson';
1088 1446
 			$data['id_source'] = $id_source;
1089
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1090
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1091
-			if (isset($data['latitude'])) $SI->add($data);
1447
+			if (isset($value['name']) && $value['name'] != '') {
1448
+				$data['source_name'] = $value['name'];
1449
+			}
1450
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1451
+				$data['noarchive'] = true;
1452
+			}
1453
+			if (isset($data['latitude'])) {
1454
+				$SI->add($data);
1455
+			}
1092 1456
 			unset($data);
1093 1457
 		    }
1094 1458
 		} elseif (is_array($all_data)) {
@@ -1105,17 +1469,26 @@  discard block
 block discarded – undo
1105 1469
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1106 1470
 			$data['squawk'] = $line['squawk']; // squawk
1107 1471
 			$data['emergency'] = ''; // emergency
1108
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1109
-			else $data['datetime'] = date('Y-m-d H:i:s');
1472
+			if (isset($line['PosTime'])) {
1473
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1474
+			} else {
1475
+				$data['datetime'] = date('Y-m-d H:i:s');
1476
+			}
1110 1477
 			$data['format_source'] = 'aircraftlistjson';
1111 1478
 			$data['id_source'] = $id_source;
1112
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1113
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1479
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1480
+				$data['noarchive'] = true;
1481
+			}
1482
+			if (isset($value['name']) && $value['name'] != '') {
1483
+				$data['source_name'] = $value['name'];
1484
+			}
1114 1485
 			$SI->add($data);
1115 1486
 			unset($data);
1116 1487
 		    }
1117 1488
 		}
1118
-	    } elseif ($globalDebug) echo 'No data'."\n";
1489
+	    } elseif ($globalDebug) {
1490
+	    	echo 'No data'."\n";
1491
+	    }
1119 1492
     	    //$last_exec['aircraftlistjson'] = time();
1120 1493
     	    $last_exec[$id]['last'] = time();
1121 1494
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -1151,8 +1524,12 @@  discard block
 block discarded – undo
1151 1524
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1152 1525
 	    	    $data['format_source'] = 'planeupdatefaa';
1153 1526
     		    $data['id_source'] = $id_source;
1154
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1155
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1527
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1528
+		    	$data['noarchive'] = true;
1529
+		    }
1530
+		    if (isset($value['name']) && $value['name'] != '') {
1531
+		    	$data['source_name'] = $value['name'];
1532
+		    }
1156 1533
 		    $SI->add($data);
1157 1534
 		    unset($data);
1158 1535
 		}
@@ -1186,7 +1563,9 @@  discard block
 block discarded – undo
1186 1563
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1187 1564
 		    $data['format_source'] = 'opensky';
1188 1565
 		    $data['id_source'] = $id_source;
1189
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1566
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1567
+		    	$data['noarchive'] = true;
1568
+		    }
1190 1569
 		    $SI->add($data);
1191 1570
 		    unset($data);
1192 1571
 		}
@@ -1206,15 +1585,42 @@  discard block
 block discarded – undo
1206 1585
 		foreach ($all_data['aircraft'] as $key => $line) {
1207 1586
 		    $data = array();
1208 1587
 		    // add support for ground vehicule with ~ in front of hex
1209
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1210
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1211
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1212
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1213
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1214
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1215
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1216
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1217
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1588
+		    if (isset($line['hex'])) {
1589
+		    	$data['hex'] = $line['hex'];
1590
+		    }
1591
+		    // hex
1592
+		    if (isset($line['flight'])) {
1593
+		    	$data['ident'] = trim($line['flight']);
1594
+		    }
1595
+		    // ident
1596
+		    if (isset($line['altitude'])) {
1597
+		    	$data['altitude'] = $line['altitude'];
1598
+		    }
1599
+		    // altitude
1600
+		    if (isset($line['speed'])) {
1601
+		    	$data['speed'] = $line['speed'];
1602
+		    }
1603
+		    // speed
1604
+		    if (isset($line['track'])) {
1605
+		    	$data['heading'] = $line['track'];
1606
+		    }
1607
+		    // heading
1608
+		    if (isset($line['lat'])) {
1609
+		    	$data['latitude'] = $line['lat'];
1610
+		    }
1611
+		    // lat
1612
+		    if (isset($line['lon'])) {
1613
+		    	$data['longitude'] = $line['lon'];
1614
+		    }
1615
+		    // long
1616
+		    if (isset($line['vert_rate'])) {
1617
+		    	$data['verticalrate'] = $line['vert_rate'];
1618
+		    }
1619
+		    // verticale rate
1620
+		    if (isset($line['squawk'])) {
1621
+		    	$data['squawk'] = $line['squawk'];
1622
+		    }
1623
+		    // squawk
1218 1624
 		    //$data['emergency'] = ''; // emergency
1219 1625
 		    //$data['registration'] = $line[2];
1220 1626
 		    //$data['aircraft_icao'] = $line[0];
@@ -1222,10 +1628,17 @@  discard block
 block discarded – undo
1222 1628
 		    $data['format_source'] = 'aircraftjson';
1223 1629
 		    $data['id_source'] = $id_source;
1224 1630
 		    if (isset($value['name']) && $value['name'] != '') {
1225
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1226
-			    else $data['source_name'] = $value['name'];
1227
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1228
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1631
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1632
+			    	$data['source_name'] = $value['name'].'_MLAT';
1633
+			    } else {
1634
+			    	$data['source_name'] = $value['name'];
1635
+			    }
1636
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1637
+		    	$data['source_name'] = 'MLAT';
1638
+		    }
1639
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1640
+		    	$data['noarchive'] = true;
1641
+		    }
1229 1642
 		    $SI->add($data);
1230 1643
 		    unset($data);
1231 1644
 		}
@@ -1245,22 +1658,54 @@  discard block
 block discarded – undo
1245 1658
 		foreach ($all_data['aircraft'] as $key => $line) {
1246 1659
 		    $data = array();
1247 1660
 		    $data['hex'] = $key; // hex
1248
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1249
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1250
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1251
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1252
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1253
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1254
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1255
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1661
+		    if (isset($line['callsign'])) {
1662
+		    	$data['ident'] = trim($line['callsign']);
1663
+		    }
1664
+		    // ident
1665
+		    if (isset($line['altitude'])) {
1666
+		    	$data['altitude'] = $line['altitude'];
1667
+		    }
1668
+		    // altitude
1669
+		    if (isset($line['speed'])) {
1670
+		    	$data['speed'] = $line['speed'];
1671
+		    }
1672
+		    // speed
1673
+		    if (isset($line['heading'])) {
1674
+		    	$data['heading'] = $line['heading'];
1675
+		    }
1676
+		    // heading
1677
+		    if (isset($line['lat'])) {
1678
+		    	$data['latitude'] = $line['lat'];
1679
+		    }
1680
+		    // lat
1681
+		    if (isset($line['lon'])) {
1682
+		    	$data['longitude'] = $line['lon'];
1683
+		    }
1684
+		    // long
1685
+		    if (isset($line['vert_rate'])) {
1686
+		    	$data['verticalrate'] = $line['vert_rate'];
1687
+		    }
1688
+		    // verticale rate
1689
+		    if (isset($line['squawk'])) {
1690
+		    	$data['squawk'] = $line['squawk'];
1691
+		    }
1692
+		    // squawk
1256 1693
 		    //$data['emergency'] = ''; // emergency
1257
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1258
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1694
+		    if (isset($line['reg'])) {
1695
+		    	$data['registration'] = $line['reg'];
1696
+		    }
1697
+		    if (isset($line['type'])) {
1698
+		    	$data['aircraft_icao'] = $line['type'];
1699
+		    }
1259 1700
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1260 1701
 		    $data['format_source'] = 'planefinderclient';
1261 1702
 		    $data['id_source'] = $id_source;
1262
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1263
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1703
+		    if (isset($value['name']) && $value['name'] != '') {
1704
+		    	$data['source_name'] = $value['name'];
1705
+		    }
1706
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1707
+		    	$data['noarchive'] = true;
1708
+		    }
1264 1709
 		    $SI->add($data);
1265 1710
 		    unset($data);
1266 1711
 		}
@@ -1276,7 +1721,9 @@  discard block
 block discarded – undo
1276 1721
 	    //$buffer = $Common->getData($hosts[$id]);
1277 1722
 	    $buffer = $Common->getData($value['host']);
1278 1723
 	    $all_data = json_decode($buffer,true);
1279
-	    if (!empty($all_data)) $reset = 0;
1724
+	    if (!empty($all_data)) {
1725
+	    	$reset = 0;
1726
+	    }
1280 1727
 	    foreach ($all_data as $key => $line) {
1281 1728
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1282 1729
 		    $data = array();
@@ -1297,8 +1744,12 @@  discard block
 block discarded – undo
1297 1744
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1298 1745
 	    	    $data['format_source'] = 'fr24json';
1299 1746
     		    $data['id_source'] = $id_source;
1300
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1301
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1747
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1748
+		    	$data['noarchive'] = true;
1749
+		    }
1750
+		    if (isset($value['name']) && $value['name'] != '') {
1751
+		    	$data['source_name'] = $value['name'];
1752
+		    }
1302 1753
 		    $SI->add($data);
1303 1754
 		    unset($data);
1304 1755
 		}
@@ -1327,24 +1778,42 @@  discard block
 block discarded – undo
1327 1778
 		    if (isset($line['inf'])) {
1328 1779
 			$data = array();
1329 1780
 			$data['hex'] = $line['inf']['ia'];
1330
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1781
+			if (isset($line['inf']['cs'])) {
1782
+				$data['ident'] = $line['inf']['cs'];
1783
+			}
1784
+			//$line[13]
1331 1785
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1332
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1333
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1786
+	    		if (isset($line['inf']['gs'])) {
1787
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1788
+	    		}
1789
+	    		// speed
1790
+	    		if (isset($line['inf']['tr'])) {
1791
+	    			$data['heading'] = $line['inf']['tr'];
1792
+	    		}
1793
+	    		// heading
1334 1794
 	    		$data['latitude'] = $line['pt'][0]; // lat
1335 1795
 	    		$data['longitude'] = $line['pt'][1]; // long
1336 1796
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1337
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1797
+	    		if (isset($line['inf']['sq'])) {
1798
+	    			$data['squawk'] = $line['inf']['sq'];
1799
+	    		}
1800
+	    		// squawk
1338 1801
 	    		//$data['aircraft_icao'] = $line[8];
1339
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1802
+	    		if (isset($line['inf']['rc'])) {
1803
+	    			$data['registration'] = $line['inf']['rc'];
1804
+	    		}
1340 1805
 			//$data['departure_airport_iata'] = $line[11];
1341 1806
 			//$data['arrival_airport_iata'] = $line[12];
1342 1807
 	    		//$data['emergency'] = ''; // emergency
1343 1808
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1344 1809
 	    		$data['format_source'] = 'radarvirtueljson';
1345 1810
     			$data['id_source'] = $id_source;
1346
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1347
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1811
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1812
+				$data['noarchive'] = true;
1813
+			}
1814
+			if (isset($value['name']) && $value['name'] != '') {
1815
+				$data['source_name'] = $value['name'];
1816
+			}
1348 1817
 			$SI->add($data);
1349 1818
 			unset($data);
1350 1819
 		    }
@@ -1370,30 +1839,65 @@  discard block
 block discarded – undo
1370 1839
 		    $data['id'] = $line['id'];
1371 1840
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1372 1841
 		    $data['ident'] = $line['callsign']; // ident
1373
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1374
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1375
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1376
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1377
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1378
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1842
+		    if (isset($line['pilotid'])) {
1843
+		    	$data['pilot_id'] = $line['pilotid'];
1844
+		    }
1845
+		    // pilot id
1846
+		    if (isset($line['name'])) {
1847
+		    	$data['pilot_name'] = $line['name'];
1848
+		    }
1849
+		    // pilot name
1850
+		    if (isset($line['alt'])) {
1851
+		    	$data['altitude'] = $line['alt'];
1852
+		    }
1853
+		    // altitude
1854
+		    if (isset($line['gs'])) {
1855
+		    	$data['speed'] = $line['gs'];
1856
+		    }
1857
+		    // speed
1858
+		    if (isset($line['heading'])) {
1859
+		    	$data['heading'] = $line['heading'];
1860
+		    }
1861
+		    // heading
1862
+		    if (isset($line['route'])) {
1863
+		    	$data['waypoints'] = $line['route'];
1864
+		    }
1865
+		    // route
1379 1866
 		    $data['latitude'] = $line['lat']; // lat
1380 1867
 		    $data['longitude'] = $line['lon']; // long
1381 1868
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1382 1869
 		    //$data['squawk'] = $line['squawk']; // squawk
1383 1870
 		    //$data['emergency'] = ''; // emergency
1384
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1385
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1386
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1871
+		    if (isset($line['depicao'])) {
1872
+		    	$data['departure_airport_icao'] = $line['depicao'];
1873
+		    }
1874
+		    if (isset($line['deptime'])) {
1875
+		    	$data['departure_airport_time'] = $line['deptime'];
1876
+		    }
1877
+		    if (isset($line['arricao'])) {
1878
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1879
+		    }
1387 1880
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1388
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1389
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1390
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1391
-		    else $data['info'] = '';
1881
+		    if (isset($line['aircraft'])) {
1882
+		    	$data['aircraft_icao'] = $line['aircraft'];
1883
+		    }
1884
+		    if (isset($line['transponder'])) {
1885
+		    	$data['squawk'] = $line['transponder'];
1886
+		    }
1887
+		    if (isset($line['atis'])) {
1888
+		    	$data['info'] = $line['atis'];
1889
+		    } else {
1890
+		    	$data['info'] = '';
1891
+		    }
1392 1892
 		    $data['format_source'] = 'pireps';
1393 1893
     		    $data['id_source'] = $id_source;
1394 1894
 		    $data['datetime'] = date('Y-m-d H:i:s');
1395
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1396
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1895
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1896
+		    	$data['noarchive'] = true;
1897
+		    }
1898
+		    if (isset($value['name']) && $value['name'] != '') {
1899
+		    	$data['source_name'] = $value['name'];
1900
+		    }
1397 1901
 		    if ($line['icon'] === 'plane') {
1398 1902
 			$SI->add($data);
1399 1903
 		    //    print_r($data);
@@ -1402,16 +1906,28 @@  discard block
 block discarded – undo
1402 1906
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1403 1907
 			$typec = substr($data['ident'],-3);
1404 1908
 			$data['type'] = '';
1405
-			if ($typec === 'APP') $data['type'] = 'Approach';
1406
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1407
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1408
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1409
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1410
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1411
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1412
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1413
-			else $data['type'] = 'Observer';
1414
-			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']);
1909
+			if ($typec === 'APP') {
1910
+				$data['type'] = 'Approach';
1911
+			} elseif ($typec === 'TWR') {
1912
+				$data['type'] = 'Tower';
1913
+			} elseif ($typec === 'OBS') {
1914
+				$data['type'] = 'Observer';
1915
+			} elseif ($typec === 'GND') {
1916
+				$data['type'] = 'Ground';
1917
+			} elseif ($typec === 'DEL') {
1918
+				$data['type'] = 'Delivery';
1919
+			} elseif ($typec === 'DEP') {
1920
+				$data['type'] = 'Departure';
1921
+			} elseif ($typec === 'FSS') {
1922
+				$data['type'] = 'Flight Service Station';
1923
+			} elseif ($typec === 'CTR') {
1924
+				$data['type'] = 'Control Radar or Centre';
1925
+			} else {
1926
+				$data['type'] = 'Observer';
1927
+			}
1928
+			if (isset($ATC)) {
1929
+				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']);
1930
+			}
1415 1931
 		    }
1416 1932
 		    unset($data);
1417 1933
 		}
@@ -1426,7 +1942,9 @@  discard block
 block discarded – undo
1426 1942
 	    )
1427 1943
 	) {
1428 1944
 	    //$buffer = $Common->getData($hosts[$id]);
1429
-	    if ($globalDebug) echo 'Get Data...'."\n";
1945
+	    if ($globalDebug) {
1946
+	    	echo 'Get Data...'."\n";
1947
+	    }
1430 1948
 	    $buffer = $Common->getData($value['host']);
1431 1949
 	    $all_data = json_decode($buffer,true);
1432 1950
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1434,10 +1952,16 @@  discard block
 block discarded – undo
1434 1952
 		foreach ($all_data as $line) {
1435 1953
 	    	    $data = array();
1436 1954
 	    	    //$data['id'] = $line['id']; // id not usable
1437
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1955
+	    	    if (isset($line['pilotid'])) {
1956
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1957
+	    	    }
1438 1958
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1439
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1440
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1959
+	    	    if (isset($line['pilotname'])) {
1960
+	    	    	$data['pilot_name'] = $line['pilotname'];
1961
+	    	    }
1962
+	    	    if (isset($line['pilotid'])) {
1963
+	    	    	$data['pilot_id'] = $line['pilotid'];
1964
+	    	    }
1441 1965
 	    	    $data['ident'] = $line['flightnum']; // ident
1442 1966
 	    	    $data['altitude'] = $line['alt']; // altitude
1443 1967
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1453,7 +1977,9 @@  discard block
 block discarded – undo
1453 1977
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1454 1978
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1455 1979
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1456
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1980
+	    	    } else {
1981
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1982
+	    	    }
1457 1983
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1458 1984
 	    	    $data['departure_airport_time'] = $line['deptime'];
1459 1985
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1461,29 +1987,47 @@  discard block
 block discarded – undo
1461 1987
     		    if (isset($line['registration'])) {
1462 1988
     			$data['registration'] = $line['registration'];
1463 1989
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1464
-    		    } else $data['registration'] = $line['aircraft'];
1465
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1466
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1990
+    		    } else {
1991
+    		    	$data['registration'] = $line['aircraft'];
1992
+    		    }
1993
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1994
+		    	$data['noarchive'] = true;
1995
+		    }
1996
+		    if (isset($line['route'])) {
1997
+		    	$data['waypoints'] = $line['route'];
1998
+		    }
1999
+		    // route
1467 2000
 		    if (isset($line['aircraftname'])) {
1468 2001
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1469 2002
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1470 2003
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1471
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1472
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1473
-	    		else {
2004
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
2005
+	    			$data['aircraft_icao'] = $aircraft_data[0];
2006
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
2007
+	    			$data['aircraft_icao'] = $aircraft_data[1];
2008
+	    		} else {
1474 2009
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1475
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1476
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
2010
+	    		    if (isset($aircraft_data[1])) {
2011
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
2012
+	    		    } else {
2013
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
2014
+	    		    }
1477 2015
 	    		}
1478 2016
 	    	    }
1479
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
2017
+    		    if (isset($line['route'])) {
2018
+    		    	$data['waypoints'] = $line['route'];
2019
+    		    }
1480 2020
     		    $data['id_source'] = $id_source;
1481 2021
 	    	    $data['format_source'] = 'phpvmacars';
1482
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2022
+		    if (isset($value['name']) && $value['name'] != '') {
2023
+		    	$data['source_name'] = $value['name'];
2024
+		    }
1483 2025
 		    $SI->add($data);
1484 2026
 		    unset($data);
1485 2027
 		}
1486
-		if ($globalDebug) echo 'No more data...'."\n";
2028
+		if ($globalDebug) {
2029
+			echo 'No more data...'."\n";
2030
+		}
1487 2031
 		unset($buffer);
1488 2032
 		unset($all_data);
1489 2033
 	    }
@@ -1496,7 +2040,9 @@  discard block
 block discarded – undo
1496 2040
 	    )
1497 2041
 	) {
1498 2042
 	    //$buffer = $Common->getData($hosts[$id]);
1499
-	    if ($globalDebug) echo 'Get Data...'."\n";
2043
+	    if ($globalDebug) {
2044
+	    	echo 'Get Data...'."\n";
2045
+	    }
1500 2046
 	    $buffer = $Common->getData($value['host']);
1501 2047
 	    $all_data = json_decode($buffer,true);
1502 2048
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1507,10 +2053,16 @@  discard block
 block discarded – undo
1507 2053
 	    	    //$data['id'] = $line['id']; // id not usable
1508 2054
 	    	    $data['id'] = $line['id'];
1509 2055
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1510
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1511
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
2056
+	    	    if (isset($line['user']['username'])) {
2057
+	    	    	$data['pilot_name'] = $line['user']['username'];
2058
+	    	    }
2059
+	    	    if (isset($line['user_id'])) {
2060
+	    	    	$data['pilot_id'] = $line['user_id'];
2061
+	    	    }
1512 2062
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1513
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2063
+	    	    if (is_numeric($data['ident'])) {
2064
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2065
+	    	    }
1514 2066
 	    	    $data['altitude'] = $line['altitude']; // altitude
1515 2067
 	    	    $data['speed'] = $line['groundspeed']; // speed
1516 2068
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1523,7 +2075,9 @@  discard block
 block discarded – undo
1523 2075
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1524 2076
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1525 2077
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1526
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
2078
+	    	    } else {
2079
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
2080
+	    	    }
1527 2081
 	    	    
1528 2082
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1529 2083
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1531,17 +2085,26 @@  discard block
 block discarded – undo
1531 2085
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1532 2086
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1533 2087
 
1534
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1535
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
2088
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2089
+		    	$data['noarchive'] = true;
2090
+		    }
2091
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
2092
+		    	$data['waypoints'] = $line['bid']['route'];
2093
+		    }
2094
+		    // route
1536 2095
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1537 2096
 
1538 2097
     		    $data['id_source'] = $id_source;
1539 2098
 	    	    $data['format_source'] = 'vaos';
1540
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2099
+		    if (isset($value['name']) && $value['name'] != '') {
2100
+		    	$data['source_name'] = $value['name'];
2101
+		    }
1541 2102
 		    $SI->add($data);
1542 2103
 		    unset($data);
1543 2104
 		}
1544
-		if ($globalDebug) echo 'No more data...'."\n";
2105
+		if ($globalDebug) {
2106
+			echo 'No more data...'."\n";
2107
+		}
1545 2108
 		unset($buffer);
1546 2109
 		unset($all_data);
1547 2110
 	    }
@@ -1554,7 +2117,9 @@  discard block
 block discarded – undo
1554 2117
 	    )
1555 2118
 	) {
1556 2119
 	    //$buffer = $Common->getData($hosts[$id]);
1557
-	    if ($globalDebug) echo 'Get Data...'."\n";
2120
+	    if ($globalDebug) {
2121
+	    	echo 'Get Data...'."\n";
2122
+	    }
1558 2123
 	    $buffer = $Common->getData($value['host']);
1559 2124
 	    $all_data = json_decode($buffer,true);
1560 2125
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1583,16 +2148,25 @@  discard block
 block discarded – undo
1583 2148
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1584 2149
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1585 2150
     		    //$data['registration'] = $line['aircraft'];
1586
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2151
+		    if (isset($line['route'])) {
2152
+		    	$data['waypoints'] = $line['route'];
2153
+		    }
2154
+		    // route
1587 2155
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1588 2156
     		    $data['id_source'] = $id_source;
1589 2157
 	    	    $data['format_source'] = 'vam';
1590
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1591
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2158
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2159
+		    	$data['noarchive'] = true;
2160
+		    }
2161
+		    if (isset($value['name']) && $value['name'] != '') {
2162
+		    	$data['source_name'] = $value['name'];
2163
+		    }
1592 2164
 		    $SI->add($data);
1593 2165
 		    unset($data);
1594 2166
 		}
1595
-		if ($globalDebug) echo 'No more data...'."\n";
2167
+		if ($globalDebug) {
2168
+			echo 'No more data...'."\n";
2169
+		}
1596 2170
 		unset($buffer);
1597 2171
 		unset($all_data);
1598 2172
 	    }
@@ -1605,7 +2179,9 @@  discard block
 block discarded – undo
1605 2179
 	    )
1606 2180
 	) {
1607 2181
 	    //$buffer = $Common->getData($hosts[$id]);
1608
-	    if ($globalDebug) echo 'Get Data...'."\n";
2182
+	    if ($globalDebug) {
2183
+	    	echo 'Get Data...'."\n";
2184
+	    }
1609 2185
 	    $buffer = $Common->getData($value['host']);
1610 2186
 	    $all_data = json_decode($buffer,true);
1611 2187
 	    if ($buffer != '') {
@@ -1623,12 +2199,16 @@  discard block
 block discarded – undo
1623 2199
 			$data['id_source'] = $id_source;
1624 2200
 			$data['format_source'] = 'blitzortung';
1625 2201
 			$SI->add($data);
1626
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2202
+			if ($globalDebug) {
2203
+				echo '☈ Lightning added'."\n";
2204
+			}
1627 2205
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1628 2206
 			unset($data);
1629 2207
 		    }
1630 2208
 		}
1631
-		if ($globalDebug) echo 'No more data...'."\n";
2209
+		if ($globalDebug) {
2210
+			echo 'No more data...'."\n";
2211
+		}
1632 2212
 		unset($buffer);
1633 2213
 	    }
1634 2214
 	    $last_exec[$id]['last'] = time();
@@ -1657,10 +2237,15 @@  discard block
 block discarded – undo
1657 2237
                 }
1658 2238
             } else {
1659 2239
                 $format = $value['format'];
1660
-                if (isset($tt[$format])) $tt[$format]++;
1661
-                else $tt[$format] = 0;
2240
+                if (isset($tt[$format])) {
2241
+                	$tt[$format]++;
2242
+                } else {
2243
+                	$tt[$format] = 0;
2244
+                }
1662 2245
                 if ($tt[$format] > 30) {
1663
-                    if ($globalDebug) echo 'Reconnect...'."\n";
2246
+                    if ($globalDebug) {
2247
+                    	echo 'Reconnect...'."\n";
2248
+                    }
1664 2249
                     sleep(2);
1665 2250
                     //$sourceeen[] = $value;
1666 2251
                     //connect_all($sourceeen);
@@ -1677,7 +2262,9 @@  discard block
 block discarded – undo
1677 2262
 	    $write = NULL;
1678 2263
 	    $e = NULL;
1679 2264
 	    $n = socket_select($read, $write, $e, $timeout);
1680
-	    if ($e != NULL) var_dump($e);
2265
+	    if ($e != NULL) {
2266
+	    	var_dump($e);
2267
+	    }
1681 2268
 	    if ($n > 0) {
1682 2269
 		$reset = 0;
1683 2270
 		foreach ($read as $nb => $r) {
@@ -1699,13 +2286,17 @@  discard block
 block discarded – undo
1699 2286
 		    if ($buffer !== FALSE) {
1700 2287
 			if ($format === 'vrstcp') {
1701 2288
 			    $buffer = explode('},{',$buffer);
1702
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2289
+			} else {
2290
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2291
+			}
1703 2292
 		    }
1704 2293
 		    // SBS format is CSV format
1705 2294
 		    if ($buffer !== FALSE && $buffer !== '') {
1706 2295
 			$tt[$format] = 0;
1707 2296
 			if ($format === 'acarssbs3') {
1708
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2297
+			    if ($globalDebug) {
2298
+			    	echo 'ACARS : '.$buffer."\n";
2299
+			    }
1709 2300
 			    $ACARS->add(trim($buffer));
1710 2301
 			    $ACARS->deleteLiveAcarsData();
1711 2302
 			} elseif ($format === 'raw') {
@@ -1715,9 +2306,15 @@  discard block
 block discarded – undo
1715 2306
 				//if (!empty($data)) print_r($data);
1716 2307
 				$data['datetime'] = date('Y-m-d H:i:s');
1717 2308
 				$data['format_source'] = 'raw';
1718
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1719
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1720
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2309
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2310
+					$data['source_name'] = $globalSources[$nb]['name'];
2311
+				}
2312
+				if (isset($globalSources[$nb]['sourcestats'])) {
2313
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2314
+				}
2315
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2316
+					$data['noarchive'] = true;
2317
+				}
1721 2318
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1722 2319
 				$SI->add($data);
1723 2320
 				unset($data);
@@ -1725,22 +2322,54 @@  discard block
 block discarded – undo
1725 2322
 			} elseif ($format === 'ais') {
1726 2323
 			    $ais_data = $AIS->parse_line(trim($buffer));
1727 2324
 			    $data = array();
1728
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1729
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1730
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1731
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1732
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1733
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1734
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1735
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1736
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1737
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1738
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1739
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1740
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1741
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1742
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1743
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2325
+			    if (isset($ais_data['ident'])) {
2326
+			    	$data['ident'] = $ais_data['ident'];
2327
+			    }
2328
+			    if (isset($ais_data['mmsi'])) {
2329
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2330
+			    }
2331
+			    if (isset($ais_data['speed'])) {
2332
+			    	$data['speed'] = $ais_data['speed'];
2333
+			    }
2334
+			    if (isset($ais_data['heading'])) {
2335
+			    	$data['heading'] = $ais_data['heading'];
2336
+			    }
2337
+			    if (isset($ais_data['latitude'])) {
2338
+			    	$data['latitude'] = $ais_data['latitude'];
2339
+			    }
2340
+			    if (isset($ais_data['longitude'])) {
2341
+			    	$data['longitude'] = $ais_data['longitude'];
2342
+			    }
2343
+			    if (isset($ais_data['status'])) {
2344
+			    	$data['status'] = $ais_data['status'];
2345
+			    }
2346
+			    if (isset($ais_data['statusid'])) {
2347
+			    	$data['status_id'] = $ais_data['statusid'];
2348
+			    }
2349
+			    if (isset($ais_data['type'])) {
2350
+			    	$data['type'] = $ais_data['type'];
2351
+			    }
2352
+			    if (isset($ais_data['imo'])) {
2353
+			    	$data['imo'] = $ais_data['imo'];
2354
+			    }
2355
+			    if (isset($ais_data['callsign'])) {
2356
+			    	$data['callsign'] = $ais_data['callsign'];
2357
+			    }
2358
+			    if (isset($ais_data['destination'])) {
2359
+			    	$data['arrival_code'] = $ais_data['destination'];
2360
+			    }
2361
+			    if (isset($ais_data['eta_ts'])) {
2362
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2363
+			    }
2364
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2365
+			    	$data['noarchive'] = true;
2366
+			    }
2367
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2368
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2369
+			    }
2370
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2371
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2372
+			    }
1744 2373
 
1745 2374
 			    if (isset($ais_data['timestamp'])) {
1746 2375
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1749,7 +2378,9 @@  discard block
 block discarded – undo
1749 2378
 			    }
1750 2379
 			    $data['format_source'] = 'aisnmea';
1751 2380
     			    $data['id_source'] = $id_source;
1752
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2381
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2382
+			    	$MI->add($data);
2383
+			    }
1753 2384
 			    unset($data);
1754 2385
                         } elseif ($format === 'flightgearsp') {
1755 2386
                     	    //echo $buffer."\n";
@@ -1767,17 +2398,25 @@  discard block
 block discarded – undo
1767 2398
 				$data['speed'] = round($line[5]*1.94384);
1768 2399
 				$data['datetime'] = date('Y-m-d H:i:s');
1769 2400
 				$data['format_source'] = 'flightgearsp';
1770
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1771
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2401
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2402
+					$data['noarchive'] = true;
2403
+				}
2404
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2405
+					$SI->add($data);
2406
+				}
1772 2407
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1773 2408
 			    }
1774 2409
                         } elseif ($format === 'acars') {
1775
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2410
+                    	    if ($globalDebug) {
2411
+                    	    	echo 'ACARS : '.$buffer."\n";
2412
+                    	    }
1776 2413
 			    $ACARS->add(trim($buffer));
1777 2414
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1778 2415
 			    $ACARS->deleteLiveAcarsData();
1779 2416
 			} elseif ($format === 'acarsjsonudp') {
1780
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2417
+			    if ($globalDebug) {
2418
+			    	echo 'ACARS : '.$buffer."\n";
2419
+			    }
1781 2420
                             $line = json_decode(trim($buffer), true);
1782 2421
                             if (!empty($line)) {
1783 2422
                                 $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
@@ -1801,8 +2440,12 @@  discard block
 block discarded – undo
1801 2440
 				    $aircraft_type = $line[10];
1802 2441
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1803 2442
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1804
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1805
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2443
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2444
+				    	$data['noarchive'] = true;
2445
+				    }
2446
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2447
+				    	$SI->add($data);
2448
+				    }
1806 2449
 				}
1807 2450
 			    }
1808 2451
 			} elseif ($format === 'beast') {
@@ -1812,28 +2455,62 @@  discard block
 block discarded – undo
1812 2455
 			    foreach($buffer as $all_data) {
1813 2456
 				$line = json_decode('{'.$all_data.'}',true);
1814 2457
 				$data = array();
1815
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1816
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1817
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1818
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1819
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1820
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1821
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2458
+				if (isset($line['Icao'])) {
2459
+					$data['hex'] = $line['Icao'];
2460
+				}
2461
+				// hex
2462
+				if (isset($line['Call'])) {
2463
+					$data['ident'] = $line['Call'];
2464
+				}
2465
+				// ident
2466
+				if (isset($line['Alt'])) {
2467
+					$data['altitude'] = $line['Alt'];
2468
+				}
2469
+				// altitude
2470
+				if (isset($line['Spd'])) {
2471
+					$data['speed'] = $line['Spd'];
2472
+				}
2473
+				// speed
2474
+				if (isset($line['Trak'])) {
2475
+					$data['heading'] = $line['Trak'];
2476
+				}
2477
+				// heading
2478
+				if (isset($line['Lat'])) {
2479
+					$data['latitude'] = $line['Lat'];
2480
+				}
2481
+				// lat
2482
+				if (isset($line['Long'])) {
2483
+					$data['longitude'] = $line['Long'];
2484
+				}
2485
+				// long
1822 2486
 				//$data['verticalrate'] = $line['']; // verticale rate
1823
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2487
+				if (isset($line['Sqk'])) {
2488
+					$data['squawk'] = $line['Sqk'];
2489
+				}
2490
+				// squawk
1824 2491
 				$data['emergency'] = ''; // emergency
1825
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2492
+				if (isset($line['Reg'])) {
2493
+					$data['registration'] = $line['Reg'];
2494
+				}
1826 2495
 				/*
1827 2496
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1828 2497
 				else $data['datetime'] = date('Y-m-d H:i:s');
1829 2498
 				*/
1830 2499
 				$data['datetime'] = date('Y-m-d H:i:s');
1831
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2500
+				if (isset($line['Type'])) {
2501
+					$data['aircraft_icao'] = $line['Type'];
2502
+				}
1832 2503
 		    		$data['format_source'] = 'vrstcp';
1833 2504
 				$data['id_source'] = $id_source;
1834
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1835
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1836
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2505
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2506
+					$data['noarchive'] = true;
2507
+				}
2508
+				if (isset($value['name']) && $value['name'] != '') {
2509
+					$data['source_name'] = $value['name'];
2510
+				}
2511
+				if (isset($data['latitude']) && isset($data['hex'])) {
2512
+					$SI->add($data);
2513
+				}
1837 2514
 				unset($data);
1838 2515
 			    }
1839 2516
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1846,22 +2523,46 @@  discard block
 block discarded – undo
1846 2523
     				$data['hex'] = $lined['hexid'];
1847 2524
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1848 2525
     				$data['datetime'] = date('Y-m-d H:i:s');;
1849
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1850
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1851
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1852
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1853
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1854
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1855
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2526
+    				if (isset($lined['ident'])) {
2527
+    					$data['ident'] = $lined['ident'];
2528
+    				}
2529
+    				if (isset($lined['lat'])) {
2530
+    					$data['latitude'] = $lined['lat'];
2531
+    				}
2532
+    				if (isset($lined['lon'])) {
2533
+    					$data['longitude'] = $lined['lon'];
2534
+    				}
2535
+    				if (isset($lined['speed'])) {
2536
+    					$data['speed'] = $lined['speed'];
2537
+    				}
2538
+    				if (isset($lined['squawk'])) {
2539
+    					$data['squawk'] = $lined['squawk'];
2540
+    				}
2541
+    				if (isset($lined['alt'])) {
2542
+    					$data['altitude'] = $lined['alt'];
2543
+    				}
2544
+    				if (isset($lined['heading'])) {
2545
+    					$data['heading'] = $lined['heading'];
2546
+    				}
1856 2547
     				$data['id_source'] = $id_source;
1857 2548
     				$data['format_source'] = 'tsv';
1858
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1859
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1860
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1861
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2549
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2550
+    					$data['source_name'] = $globalSources[$nb]['name'];
2551
+    				}
2552
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2553
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2554
+    				}
2555
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2556
+					$data['noarchive'] = true;
2557
+				}
2558
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2559
+    					$SI->add($data);
2560
+    				}
1862 2561
     				unset($lined);
1863 2562
     				unset($data);
1864
-    			    } else $error = true;
2563
+    			    } else {
2564
+    			    	$error = true;
2565
+    			    }
1865 2566
 			} elseif ($format === 'aprs' && $use_aprs) {
1866 2567
 			    if ($aprs_connect === 0) {
1867 2568
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1887,47 +2588,96 @@  discard block
 block discarded – undo
1887 2588
 				    $aprs_last_tx = time();
1888 2589
 				    $data = array();
1889 2590
 				    //print_r($line);
1890
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1891
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1892
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1893
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1894
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1895
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1896
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1897
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1898
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1899
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2591
+				    if (isset($line['address'])) {
2592
+				    	$data['hex'] = $line['address'];
2593
+				    }
2594
+				    if (isset($line['mmsi'])) {
2595
+				    	$data['mmsi'] = $line['mmsi'];
2596
+				    }
2597
+				    if (isset($line['imo'])) {
2598
+				    	$data['imo'] = $line['imo'];
2599
+				    }
2600
+				    if (isset($line['squawk'])) {
2601
+				    	$data['squawk'] = $line['squawk'];
2602
+				    }
2603
+				    if (isset($line['arrival_code'])) {
2604
+				    	$data['arrival_code'] = $line['arrival_code'];
2605
+				    }
2606
+				    if (isset($line['arrival_date'])) {
2607
+				    	$data['arrival_date'] = $line['arrival_date'];
2608
+				    }
2609
+				    if (isset($line['typeid'])) {
2610
+				    	$data['type_id'] = $line['typeid'];
2611
+				    }
2612
+				    if (isset($line['statusid'])) {
2613
+				    	$data['status_id'] = $line['statusid'];
2614
+				    }
2615
+				    if (isset($line['timestamp'])) {
2616
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2617
+				    } else {
2618
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2619
+				    }
1900 2620
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1901
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2621
+				    if (isset($line['ident'])) {
2622
+				    	$data['ident'] = $line['ident'];
2623
+				    }
1902 2624
 				    $data['latitude'] = $line['latitude'];
1903 2625
 				    $data['longitude'] = $line['longitude'];
1904 2626
 				    //$data['verticalrate'] = $line[16];
1905
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2627
+				    if (isset($line['speed'])) {
2628
+				    	$data['speed'] = $line['speed'];
2629
+				    }
1906 2630
 				    //else $data['speed'] = 0;
1907
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1908
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1909
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2631
+				    if (isset($line['altitude'])) {
2632
+				    	$data['altitude'] = $line['altitude'];
2633
+				    }
2634
+				    if (isset($line['comment'])) {
2635
+				    	$data['comment'] = $line['comment'];
2636
+				    }
2637
+				    if (isset($line['symbol'])) {
2638
+				    	$data['type'] = $line['symbol'];
2639
+				    }
1910 2640
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1911 2641
 				    
1912
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2642
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2643
+				    	$data['heading'] = $line['heading'];
2644
+				    }
1913 2645
 				    //else echo 'No heading...'."\n";
1914 2646
 				    //else $data['heading'] = 0;
1915
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2647
+				    if (isset($line['stealth'])) {
2648
+				    	$data['aircraft_type'] = $line['stealth'];
2649
+				    }
1916 2650
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1917
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1918
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1919
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1920
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2651
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2652
+				    	$data['noarchive'] = true;
2653
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2654
+				    	$data['noarchive'] = false;
2655
+				    }
2656
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2657
+				    	$data['noarchive'] = true;
2658
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2659
+				    	$data['noarchive'] = false;
2660
+				    }
1921 2661
     				    $data['id_source'] = $id_source;
1922
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1923
-				    else $data['format_source'] = 'aprs';
2662
+    				    if (isset($line['format_source'])) {
2663
+    				    	$data['format_source'] = $line['format_source'];
2664
+    				    } else {
2665
+				    	$data['format_source'] = 'aprs';
2666
+				    }
1924 2667
 				    $data['source_name'] = $line['source'];
1925
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1926
-				    else $data['source_type'] = 'flarm';
1927
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2668
+				    if (isset($line['source_type'])) {
2669
+				    	$data['source_type'] = $line['source_type'];
2670
+				    } else {
2671
+				    	$data['source_type'] = 'flarm';
2672
+				    }
2673
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2674
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2675
+    				    }
1928 2676
 				    $currentdate = date('Y-m-d H:i:s');
1929 2677
 				    $aprsdate = strtotime($data['datetime']);
1930
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2678
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2679
+				    	$data['altitude_relative'] = 'AMSL';
2680
+				    }
1931 2681
 				    // Accept data if time <= system time + 20s
1932 2682
 				    //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'])))) {
1933 2683
 				    if (
@@ -1939,7 +2689,9 @@  discard block
 block discarded – undo
1939 2689
 					$send = $SI->add($data);
1940 2690
 				    } elseif ($data['source_type'] === 'ais') {
1941 2691
 					$data['type'] = '';
1942
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2692
+					if (isset($globalMarine) && $globalMarine) {
2693
+						$send = $MI->add($data);
2694
+					}
1943 2695
 				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1944 2696
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1945 2697
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
@@ -1947,8 +2699,12 @@  discard block
 block discarded – undo
1947 2699
 					    $line['symbol'] === 'Glider' || 
1948 2700
 					    $line['symbol'] === 'No. Plane' || 
1949 2701
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1950
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1951
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2702
+					    if ($line['symbol'] === 'Ballon') {
2703
+					    	$data['aircraft_icao'] = 'BALL';
2704
+					    }
2705
+					    if ($line['symbol'] === 'Glider') {
2706
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2707
+					    }
1952 2708
 					    $send = $SI->add($data);
1953 2709
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1954 2710
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1979,9 +2735,13 @@  discard block
 block discarded – undo
1979 2735
 				    //} 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') {
1980 2736
 				//    } 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') {
1981 2737
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1982
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2738
+					if (isset($globalTracker) && $globalTracker) {
2739
+						$send = $TI->add($data);
2740
+					}
1983 2741
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1984
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2742
+					if (!isset($data['altitude'])) {
2743
+						$data['altitude'] = 0;
2744
+					}
1985 2745
 					$Source->deleteOldLocationByType('gs');
1986 2746
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1987 2747
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1990,7 +2750,9 @@  discard block
 block discarded – undo
1990 2750
 					}
1991 2751
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1992 2752
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1993
-					if ($globalDebug) echo '# Weather Station added'."\n";
2753
+					if ($globalDebug) {
2754
+						echo '# Weather Station added'."\n";
2755
+					}
1994 2756
 					$Source->deleteOldLocationByType('wx');
1995 2757
 					$weather_data = json_encode($line);
1996 2758
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -2000,7 +2762,9 @@  discard block
 block discarded – undo
2000 2762
 					}
2001 2763
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2002 2764
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2003
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2765
+					if ($globalDebug) {
2766
+						echo '☈ Lightning added'."\n";
2767
+					}
2004 2768
 					$Source->deleteOldLocationByType('lightning');
2005 2769
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
2006 2770
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -2012,8 +2776,7 @@  discard block
 block discarded – undo
2012 2776
 				    	print_r($line);
2013 2777
 				    }
2014 2778
 				    unset($data);
2015
-				}
2016
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2779
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2017 2780
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2018 2781
 				}
2019 2782
 				/*
@@ -2022,7 +2785,9 @@  discard block
 block discarded – undo
2022 2785
 				}
2023 2786
 				*/
2024 2787
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2025
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2788
+				elseif ($line === true && $globalDebug) {
2789
+					echo '!! Failed : '.$buffer."!!\n";
2790
+				}
2026 2791
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2027 2792
 					$Source->deleteOldLocationByType('lightning');
2028 2793
 					$Source->deleteOldLocationByType('wx');
@@ -2059,27 +2824,47 @@  discard block
 block discarded – undo
2059 2824
     				$data['ground'] = $line[21];
2060 2825
     				$data['emergency'] = $line[19];
2061 2826
     				$data['format_source'] = 'sbs';
2062
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
2063
-				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
2064
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2065
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2827
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2828
+					$data['source_name'] = $globalSources[$nb]['name'];
2829
+				} elseif ($line[0] == 'MLAT') {
2830
+					$data['source_name'] = 'MLAT';
2831
+				}
2832
+				if (isset($globalSources[$nb]['sourcestats'])) {
2833
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2834
+				}
2835
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2836
+					$data['noarchive'] = true;
2837
+				}
2066 2838
     				$data['id_source'] = $id_source;
2067
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2068
-    				else $error = true;
2839
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2840
+    					$send = $SI->add($data);
2841
+    				} else {
2842
+    					$error = true;
2843
+    				}
2069 2844
     				unset($data);
2070
-    			    } else $error = true;
2845
+    			    } else {
2846
+    			    	$error = true;
2847
+    			    }
2071 2848
 			    if ($error) {
2072 2849
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
2073
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2850
+					if ($globalDebug) {
2851
+						echo "Not a message. Ignoring... \n";
2852
+					}
2074 2853
 				} else {
2075
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2854
+					if ($globalDebug) {
2855
+						echo "Wrong line format. Ignoring... \n";
2856
+					}
2076 2857
 					if ($globalDebug) {
2077 2858
 						echo $buffer;
2078 2859
 						//print_r($line);
2079 2860
 					}
2080 2861
 					//socket_close($r);
2081
-					if ($globalDebug) echo "Reconnect after an error...\n";
2082
-					if ($format === 'aprs') $aprs_connect = 0;
2862
+					if ($globalDebug) {
2863
+						echo "Reconnect after an error...\n";
2864
+					}
2865
+					if ($format === 'aprs') {
2866
+						$aprs_connect = 0;
2867
+					}
2083 2868
 					$sourceer[$nb] = $globalSources[$nb];
2084 2869
 					connect_all($sourceer);
2085 2870
 					$sourceer = array();
@@ -2087,10 +2872,14 @@  discard block
 block discarded – undo
2087 2872
 			    }
2088 2873
 			}
2089 2874
 			// Sleep for xxx microseconds
2090
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2875
+			if (isset($globalSBSSleep)) {
2876
+				usleep($globalSBSSleep);
2877
+			}
2091 2878
 		    } else {
2092 2879
 			if ($format === 'flightgearmp') {
2093
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2880
+			    	if ($globalDebug) {
2881
+			    		echo "Reconnect FlightGear MP...";
2882
+			    	}
2094 2883
 				//@socket_close($r);
2095 2884
 				sleep($globalMinFetch);
2096 2885
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2099,10 +2888,15 @@  discard block
 block discarded – undo
2099 2888
 				break;
2100 2889
 				
2101 2890
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2102
-			    if (isset($tt[$format])) $tt[$format]++;
2103
-			    else $tt[$format] = 0;
2891
+			    if (isset($tt[$format])) {
2892
+			    	$tt[$format]++;
2893
+			    } else {
2894
+			    	$tt[$format] = 0;
2895
+			    }
2104 2896
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
2105
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2897
+				if ($globalDebug) {
2898
+					echo "ERROR : Reconnect ".$format."...";
2899
+				}
2106 2900
 				//@socket_close($r);
2107 2901
 				sleep(2);
2108 2902
 				$aprs_connect = 0;
@@ -2120,11 +2914,17 @@  discard block
 block discarded – undo
2120 2914
 	    } else {
2121 2915
 		$error = socket_strerror(socket_last_error());
2122 2916
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2123
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2124
-			if (isset($globalDebug)) echo "Restarting...\n";
2917
+			if ($globalDebug) {
2918
+				echo "ERROR : socket_select give this error ".$error . "\n";
2919
+			}
2920
+			if (isset($globalDebug)) {
2921
+				echo "Restarting...\n";
2922
+			}
2125 2923
 			// Restart the script if possible
2126 2924
 			if (is_array($sockets)) {
2127
-			    if ($globalDebug) echo "Shutdown all sockets...";
2925
+			    if ($globalDebug) {
2926
+			    	echo "Shutdown all sockets...";
2927
+			    }
2128 2928
 			    
2129 2929
 			    foreach ($sockets as $sock) {
2130 2930
 				@socket_shutdown($sock,2);
@@ -2132,25 +2932,45 @@  discard block
 block discarded – undo
2132 2932
 			    }
2133 2933
 			    
2134 2934
 			}
2135
-			if ($globalDebug) echo "Waiting...";
2935
+			if ($globalDebug) {
2936
+				echo "Waiting...";
2937
+			}
2136 2938
 			sleep(2);
2137 2939
 			$time = time();
2138 2940
 			//connect_all($hosts);
2139 2941
 			$aprs_connect = 0;
2140
-			if ($reset%5 === 0) sleep(20);
2141
-			if ($reset%10 === 0) sleep(100);
2142
-			if ($reset%20 === 0) sleep(200);
2143
-			if ($reset > 100) exit('Too many attempts...');
2144
-			if ($globalDebug) echo "Restart all connections...";
2942
+			if ($reset%5 === 0) {
2943
+				sleep(20);
2944
+			}
2945
+			if ($reset%10 === 0) {
2946
+				sleep(100);
2947
+			}
2948
+			if ($reset%20 === 0) {
2949
+				sleep(200);
2950
+			}
2951
+			if ($reset > 100) {
2952
+				exit('Too many attempts...');
2953
+			}
2954
+			if ($globalDebug) {
2955
+				echo "Restart all connections...";
2956
+			}
2145 2957
 			connect_all($globalSources);
2146 2958
 		}
2147 2959
 	    }
2148 2960
 	}
2149 2961
 	if ($globalDaemon === false) {
2150
-	    if ($globalDebug) echo 'Check all...'."\n";
2151
-	    if (isset($SI)) $SI->checkAll();
2152
-	    if (isset($TI)) $TI->checkAll();
2153
-	    if (isset($MI)) $MI->checkAll();
2962
+	    if ($globalDebug) {
2963
+	    	echo 'Check all...'."\n";
2964
+	    }
2965
+	    if (isset($SI)) {
2966
+	    	$SI->checkAll();
2967
+	    }
2968
+	    if (isset($TI)) {
2969
+	    	$TI->checkAll();
2970
+	    }
2971
+	    if (isset($MI)) {
2972
+	    	$MI->checkAll();
2973
+	    }
2154 2974
 	}
2155 2975
     }
2156 2976
 }
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +651 added lines, -173 removed lines patch added patch discarded remove patch
@@ -4,12 +4,22 @@  discard block
 block discarded – undo
4 4
 if (isset($_SESSION['error'])) {
5 5
 	header('Content-Encoding: none;');
6 6
 	echo 'Error : '.$_SESSION['error'].' - Resetting install... You need to fix the problem and run install again.';
7
-	if (isset($_SESSION['error'])) unset($_SESSION['error']);
8
-	if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']);
9
-	if (isset($_SESSION['next'])) unset($_SESSION['next']);
10
-	if (isset($_SESSION['install'])) unset($_SESSION['install']);
11
-	if (isset($_SESSION['identitied'])) unset($_SESSION['identified']);
12
-}
7
+	if (isset($_SESSION['error'])) {
8
+		unset($_SESSION['error']);
9
+	}
10
+	if (isset($_SESSION['errorlst'])) {
11
+		unset($_SESSION['errorlst']);
12
+	}
13
+	if (isset($_SESSION['next'])) {
14
+		unset($_SESSION['next']);
15
+	}
16
+	if (isset($_SESSION['install'])) {
17
+		unset($_SESSION['install']);
18
+	}
19
+	if (isset($_SESSION['identitied'])) {
20
+		unset($_SESSION['identified']);
21
+	}
22
+	}
13 23
 /*
14 24
 if (isset($_SESSION['errorlst'])) {
15 25
 	header('Content-Encoding: none;');
@@ -131,7 +141,9 @@  discard block
 block discarded – undo
131 141
 		if (count($alllng) != count($availablelng)) {
132 142
 			$notavailable = array();
133 143
 			foreach($alllng as $lng) {
134
-				if (!isset($availablelng[$lng])) $notavailable[] = $lng;
144
+				if (!isset($availablelng[$lng])) {
145
+					$notavailable[] = $lng;
146
+				}
135 147
 			}
136 148
 			print '<div class="alert alert-warning">The following translation can\'t be used on your system: '.implode(', ',$notavailable).'. You need to add the system locales: <a href="https://github.com/Ysurac/FlightAirMap/wiki/Translation">documentation</a>.</div>';
137 149
 		}
@@ -170,7 +182,10 @@  discard block
 block discarded – undo
170 182
 			<legend>Install script configuration</legend>
171 183
 			<p>
172 184
 				<label for="installpass">Install password</label>
173
-				<input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) print $globalInstallPassword; ?>" />
185
+				<input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) {
186
+	print $globalInstallPassword;
187
+}
188
+?>" />
174 189
 			</p>
175 190
 			<p class="help-block">Password needed to access this install script. If empty, to access this script,  you will need to change the $globalInstalled setting in require/settings.php to FALSE</p>
176 191
 		</fieldset>
@@ -200,31 +215,49 @@  discard block
 block discarded – undo
200 215
 			</div>
201 216
 			<p>
202 217
 				<label for="dbhost">Database hostname</label>
203
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
218
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
219
+	print $globalDBhost;
220
+}
221
+?>" />
204 222
 			</p>
205 223
 			<p>
206 224
 				<label for="dbport">Database port</label>
207
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
225
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
226
+	print $globalDBport;
227
+}
228
+?>" />
208 229
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
209 230
 			</p>
210 231
 			<p>
211 232
 				<label for="dbname">Database name</label>
212
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
233
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
234
+	print $globalDBname;
235
+}
236
+?>" />
213 237
 			</p>
214 238
 			<p>
215 239
 				<label for="dbuser">Database user</label>
216
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
240
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
241
+	print $globalDBuser;
242
+}
243
+?>" />
217 244
 			</p>
218 245
 			<p>
219 246
 				<label for="dbuserpass">Database user password</label>
220
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
247
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
248
+	print $globalDBpass;
249
+}
250
+?>" />
221 251
 			</p>
222 252
 		</fieldset>
223 253
 		<fieldset id="site">
224 254
 			<legend>Site configuration</legend>
225 255
 			<p>
226 256
 				<label for="sitename">Site name</label>
227
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
257
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
258
+	print $globalName;
259
+}
260
+?>" />
228 261
 			</p>
229 262
 			<p>
230 263
 				<label for="siteurl">Site directory</label>
@@ -237,18 +270,27 @@  discard block
 block discarded – undo
237 270
 					}
238 271
 				    }
239 272
 				?>
240
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
273
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
274
+	print $globalURL;
275
+}
276
+?>" />
241 277
 				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
242 278
 				<p class="help-block">Can be empty</p>
243 279
 			</p>
244 280
 			<p>
245 281
 				<label for="timezone">Timezone</label>
246
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
282
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
283
+	print $globalTimezone;
284
+}
285
+?>" />
247 286
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
248 287
 			</p>
249 288
 			<p>
250 289
 				<label for="language">Language</label>
251
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
290
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
291
+	print $globalLanguage;
292
+}
293
+?>" />
252 294
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
253 295
 			</p>
254 296
 		</fieldset>
@@ -268,11 +310,17 @@  discard block
 block discarded – undo
268 310
 			<div id="mapbox_data">
269 311
 				<p>
270 312
 					<label for="mapboxid">Mapbox id</label>
271
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
313
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
314
+	print $globalMapboxId;
315
+}
316
+?>" />
272 317
 				</p>
273 318
 				<p>
274 319
 					<label for="mapboxtoken">Mapbox token</label>
275
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
320
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
321
+	print $globalMapboxToken;
322
+}
323
+?>" />
276 324
 				</p>
277 325
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
278 326
 			</div>
@@ -280,7 +328,10 @@  discard block
 block discarded – undo
280 328
 			<div id="google_data">
281 329
 				<p>
282 330
 					<label for="googlekey">Google API key</label>
283
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
331
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
332
+	print $globalGoogleAPIKey;
333
+}
334
+?>" />
284 335
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
285 336
 				</p>
286 337
 			</div>
@@ -288,7 +339,10 @@  discard block
 block discarded – undo
288 339
 			<div id="bing_data">
289 340
 				<p>
290 341
 					<label for="bingkey">Bing Map key</label>
291
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
342
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
343
+	print $globalBingMapKey;
344
+}
345
+?>" />
292 346
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
293 347
 				</p>
294 348
 			</div>
@@ -296,7 +350,10 @@  discard block
 block discarded – undo
296 350
 			<div id="mapquest_data">
297 351
 				<p>
298 352
 					<label for="mapquestkey">MapQuest key</label>
299
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
353
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
354
+	print $globalMapQuestKey;
355
+}
356
+?>" />
300 357
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
301 358
 				</p>
302 359
 			</div>
@@ -304,11 +361,17 @@  discard block
 block discarded – undo
304 361
 			<div id="here_data">
305 362
 				<p>
306 363
 					<label for="hereappid">Here App_Id</label>
307
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
364
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
365
+	print $globalHereappId;
366
+}
367
+?>" />
308 368
 				</p>
309 369
 				<p>
310 370
 					<label for="hereappcode">Here App_Code</label>
311
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
371
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
372
+	print $globalHereappCode;
373
+}
374
+?>" />
312 375
 				</p>
313 376
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
314 377
 			</div>
@@ -316,7 +379,10 @@  discard block
 block discarded – undo
316 379
 			<div id="openweathermap_data">
317 380
 				<p>
318 381
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
319
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
382
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
383
+	print $globalOpenWeatherMapKey;
384
+}
385
+?>" />
320 386
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
321 387
 				</p>
322 388
 			</div>
@@ -345,42 +411,86 @@  discard block
 block discarded – undo
345 411
 			<legend>Coverage area</legend>
346 412
 			<p>
347 413
 				<label for="latitudemax">The maximum latitude (north)</label>
348
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
414
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
415
+	print $globalLatitudeMax;
416
+}
417
+?>" />
349 418
 			</p>
350 419
 			<p>
351 420
 				<label for="latitudemin">The minimum latitude (south)</label>
352
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
421
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
422
+	print $globalLatitudeMin;
423
+}
424
+?>" />
353 425
 			</p>
354 426
 			<p>
355 427
 				<label for="longitudemax">The maximum longitude (west)</label>
356
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
428
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
429
+	print $globalLongitudeMax;
430
+}
431
+?>" />
357 432
 			</p>
358 433
 			<p>
359 434
 				<label for="longitudemin">The minimum longitude (east)</label>
360
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
435
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
436
+	print $globalLongitudeMin;
437
+}
438
+?>" />
361 439
 			</p>
362 440
 			<p>
363 441
 				<label for="latitudecenter">The latitude center</label>
364
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
442
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
443
+	print $globalCenterLatitude;
444
+}
445
+?>" />
365 446
 			</p>
366 447
 			<p>
367 448
 				<label for="longitudecenter">The longitude center</label>
368
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
449
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
450
+	print $globalCenterLongitude;
451
+}
452
+?>" />
369 453
 			</p>
370 454
 			<p>
371 455
 				<label for="livezoom">Default Zoom on live map</label>
372
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
456
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
457
+	print $globalLiveZoom;
458
+} else {
459
+	print '9';
460
+}
461
+?>" />
373 462
 			</p>
374 463
 			<p>
375 464
 				<label for="squawk_country">Country for squawk usage</label>
376 465
 				<select name="squawk_country" id="squawk_country">
377
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
378
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
379
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
380
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
381
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
382
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
383
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
466
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
467
+	print ' selected ';
468
+}
469
+?>>UK</option>
470
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
471
+	print ' selected ';
472
+}
473
+?>>NZ</option>
474
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
475
+	print ' selected ';
476
+}
477
+?>>US</option>
478
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
479
+	print ' selected ';
480
+}
481
+?>>AU</option>
482
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
483
+	print ' selected ';
484
+}
485
+?>>NL</option>
486
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
487
+	print ' selected ';
488
+}
489
+?>>FR</option>
490
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
491
+	print ' selected ';
492
+}
493
+?>>TR</option>
384 494
 				</select>
385 495
 			</p>
386 496
 		</fieldset>
@@ -389,15 +499,24 @@  discard block
 block discarded – undo
389 499
 			<p><i>Only put in DB flights that are inside a circle</i></p>
390 500
 			<p>
391 501
 				<label for="latitude">Center latitude</label>
392
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
502
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
503
+	echo $globalDistanceIgnore['latitude'];
504
+}
505
+?>" />
393 506
 			</p>
394 507
 			<p>
395 508
 				<label for="longitude">Center longitude</label>
396
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
509
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
510
+	echo $globalDistanceIgnore['longitude'];
511
+}
512
+?>" />
397 513
 			</p>
398 514
 			<p>
399 515
 				<label for="Distance">Distance (in km)</label>
400
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
516
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
517
+	echo $globalDistanceIgnore['distance'];
518
+}
519
+?>" />
401 520
 			</p>
402 521
 		</fieldset>
403 522
 		<fieldset id="sourceloc">
@@ -523,22 +642,34 @@  discard block
 block discarded – undo
523 642
 			<div id="flightaware_data">
524 643
 				<p>
525 644
 					<label for="flightawareusername">FlightAware username</label>
526
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
645
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
646
+	print $globalFlightAwareUsername;
647
+}
648
+?>" />
527 649
 				</p>
528 650
 				<p>
529 651
 					<label for="flightawarepassword">FlightAware password/API key</label>
530
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
652
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
653
+	print $globalFlightAwarePassword;
654
+}
655
+?>" />
531 656
 				</p>
532 657
 			</div>
533 658
 -->
534 659
 			<div id="sailaway_data">
535 660
 				<p>
536 661
 					<label for="sailawayemail">Sailaway email</label>
537
-					<input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) print $globalSailaway['email']; ?>" />
662
+					<input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) {
663
+	print $globalSailaway['email'];
664
+}
665
+?>" />
538 666
 				</p>
539 667
 				<p>
540 668
 					<label for="sailawaypassword">Sailaway password</label>
541
-					<input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) print $globalSailaway['password']; ?>" />
669
+					<input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) {
670
+	print $globalSailaway['password'];
671
+}
672
+?>" />
542 673
 				</p>
543 674
 			</div>
544 675
 
@@ -580,7 +711,10 @@  discard block
 block discarded – undo
580 711
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
581 712
 								?>
582 713
 								<td><input type="text" name="host[]" value="<?php print $source['host']; ?>" /></td>
583
-								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
714
+								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) {
715
+	print $source['port'];
716
+}
717
+?>" /></td>
584 718
 								<?php
585 719
 								    } else {
586 720
 									$hostport = explode(':',$source['host']);
@@ -599,40 +733,130 @@  discard block
 block discarded – undo
599 733
 								?>
600 734
 								<td>
601 735
 									<select name="format[]">
602
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
603
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
604
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
605
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
606
-										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option>
607
-										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') print 'selected'; ?>>Planefinder client</option>
608
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
609
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
610
-                                        <option value="radarcapejson" <?php if (isset($source['format']) && $source['format'] == 'radarcapejson') print 'selected'; ?>>Radarcape json</option>
611
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
612
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
613
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
614
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
615
-										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option>
616
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
617
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
618
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
619
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
620
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
621
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
622
-										<option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') print 'selected'; ?>>ACARS from acarsdec json and vdlm2dec</option>
623
-										<option value="acarsjsonudp" <?php if (isset($source['format']) && $source['format'] == 'acarsjsonudp') print 'selected'; ?>>ACARS from acarsdec json and vdlm2dec over UDP</option>
624
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
625
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
626
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
627
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
628
-										<option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') print 'selected'; ?>>Sailaway</option>
736
+										<option value="auto" <?php if (!isset($source['format'])) {
737
+	print 'selected';
738
+}
739
+?>>Auto</option>
740
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
741
+	print 'selected';
742
+}
743
+?>>SBS</option>
744
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
745
+	print 'selected';
746
+}
747
+?>>TSV</option>
748
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
749
+	print 'selected';
750
+}
751
+?>>Raw</option>
752
+										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') {
753
+	print 'selected';
754
+}
755
+?>>Dump1090 aircraft.json</option>
756
+										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') {
757
+	print 'selected';
758
+}
759
+?>>Planefinder client</option>
760
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
761
+	print 'selected';
762
+}
763
+?>>APRS</option>
764
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
765
+	print 'selected';
766
+}
767
+?>>Radarcape deltadb.txt</option>
768
+                                        <option value="radarcapejson" <?php if (isset($source['format']) && $source['format'] == 'radarcapejson') {
769
+	print 'selected';
770
+}
771
+?>>Radarcape json</option>
772
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
773
+	print 'selected';
774
+}
775
+?>>Vatsim</option>
776
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
777
+	print 'selected';
778
+}
779
+?>>Virtual Radar Server AircraftList.json</option>
780
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
781
+	print 'selected';
782
+}
783
+?>>Virtual Radar Server TCP</option>
784
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
785
+	print 'selected';
786
+}
787
+?>>phpVMS</option>
788
+										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
789
+	print 'selected';
790
+}
791
+?>>Virtual Airline Operations System (VAOS)</option>
792
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
793
+	print 'selected';
794
+}
795
+?>>Virtual Airlines Manager</option>
796
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
797
+	print 'selected';
798
+}
799
+?>>IVAO</option>
800
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
801
+	print 'selected';
802
+}
803
+?>>FlightGear Multiplayer</option>
804
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
805
+	print 'selected';
806
+}
807
+?>>FlightGear Singleplayer</option>
808
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
809
+	print 'selected';
810
+}
811
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
812
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
813
+	print 'selected';
814
+}
815
+?>>ACARS SBS-3 over TCP</option>
816
+										<option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') {
817
+	print 'selected';
818
+}
819
+?>>ACARS from acarsdec json and vdlm2dec</option>
820
+										<option value="acarsjsonudp" <?php if (isset($source['format']) && $source['format'] == 'acarsjsonudp') {
821
+	print 'selected';
822
+}
823
+?>>ACARS from acarsdec json and vdlm2dec over UDP</option>
824
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
825
+	print 'selected';
826
+}
827
+?>>NMEA AIS over TCP</option>
828
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
829
+	print 'selected';
830
+}
831
+?>>AirWhere website</option>
832
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
833
+	print 'selected';
834
+}
835
+?>>HidnSeek Callback</option>
836
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
837
+	print 'selected';
838
+}
839
+?>>Blitzortung</option>
840
+										<option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') {
841
+	print 'selected';
842
+}
843
+?>>Sailaway</option>
629 844
 									</select>
630 845
 								</td>
631 846
 								<td>
632
-									<input type="text" name="name[]" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
847
+									<input type="text" name="name[]" value="<?php if (isset($source['name'])) {
848
+	print $source['name'];
849
+}
850
+?>" />
633 851
 								</td>
634
-								<td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
635
-								<td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
852
+								<td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
853
+	print 'checked';
854
+}
855
+?> /></td>
856
+								<td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
857
+	print 'checked';
858
+}
859
+?> /></td>
636 860
 								<td>
637 861
 									<select name="timezones[]">
638 862
 								<?php
@@ -642,7 +866,9 @@  discard block
 block discarded – undo
642 866
 											print '<option selected>'.$timezones.'</option>';
643 867
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
644 868
 											print '<option selected>'.$timezones.'</option>';
645
-										} else print '<option>'.$timezones.'</option>';
869
+										} else {
870
+											print '<option>'.$timezones.'</option>';
871
+										}
646 872
 									}
647 873
 								?>
648 874
 									</select>
@@ -699,7 +925,9 @@  discard block
 block discarded – undo
699 925
 									foreach($timezonelist as $timezones){
700 926
 										if ($timezones == 'UTC') {
701 927
 											print '<option selected>'.$timezones.'</option>';
702
-										} else print '<option>'.$timezones.'</option>';
928
+										} else {
929
+											print '<option>'.$timezones.'</option>';
930
+										}
703 931
 									}
704 932
 								?>
705 933
 									</select>
@@ -724,11 +952,17 @@  discard block
 block discarded – undo
724 952
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
725 953
 					<p>
726 954
 						<label for="acarshost">ACARS UDP host</label>
727
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
955
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
956
+	print $globalACARSHost;
957
+}
958
+?>" />
728 959
 					</p>
729 960
 					<p>
730 961
 						<label for="acarsport">ACARS UDP port</label>
731
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
962
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
963
+	print $globalACARSPort;
964
+}
965
+?>" />
732 966
 					</p>
733 967
 					<p class="help-block"><i>daemon-acars.php</i> can only be run as daemon. It's an alternate script for ACARS data, <i>daemon-spotter.php</i> may be better.</p>
734 968
 				</fieldset>
@@ -755,17 +989,38 @@  discard block
 block discarded – undo
755 989
 				    <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td>
756 990
 				    <td>
757 991
 					<select name="newslang[]">
758
-					    <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option>
759
-					    <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option>
992
+					    <option value="en"<?php if ($lng == 'en') {
993
+	print ' selected';
994
+}
995
+?>>English</option>
996
+					    <option value="fr"<?php if ($lng == 'fr') {
997
+	print ' selected';
998
+}
999
+?>>French</option>
760 1000
 					</select>
761 1001
 				    </td>
762 1002
 				    <td>
763 1003
 					<select name="newstype[]">
764
-					    <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option>
765
-					    <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option>
766
-					    <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option>
767
-					    <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option>
768
-					    <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option>
1004
+					    <option value="global"<?php if ($type == 'global') {
1005
+	print ' selected';
1006
+}
1007
+?>>Global</option>
1008
+					    <option value="aircraft"<?php if ($type == 'aircraft') {
1009
+	print ' selected';
1010
+}
1011
+?>>Aircraft</option>
1012
+					    <option value="marine"<?php if ($type == 'marine') {
1013
+	print ' selected';
1014
+}
1015
+?>>Marine</option>
1016
+					    <option value="tracker"<?php if ($type == 'tracker') {
1017
+	print ' selected';
1018
+}
1019
+?>>Tracker</option>
1020
+					    <option value="satellite"<?php if ($type == 'Satellite') {
1021
+	print ' selected';
1022
+}
1023
+?>>Satellite</option>
769 1024
 					</select>
770 1025
 				    </td>
771 1026
 				    <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td>
@@ -849,7 +1104,10 @@  discard block
 block discarded – undo
849 1104
 			</p>
850 1105
 			<p>
851 1106
 				<label for="corsproxy">CORS proxy</label>
852
-				<input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) print $globalCORSproxy; else print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" />
1107
+				<input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) {
1108
+	print $globalCORSproxy;
1109
+} else {
1110
+	print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" />
853 1111
 				<p class="help-block">CORS proxy used for some WMS servers</p>
854 1112
 			</p>
855 1113
 <!--
@@ -912,13 +1170,18 @@  discard block
 block discarded – undo
912 1170
 			<div id="schedules_options">
913 1171
 				<p>
914 1172
 					<label for="britishairways">British Airways API Key</label>
915
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
1173
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey;
1174
+}
1175
+?>" />
916 1176
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
917 1177
 				</p>
918 1178
 				<!--
919 1179
 				<p>
920 1180
 					<label for="transavia">Transavia Test API Consumer Key</label>
921
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
1181
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
1182
+	print $globalTransaviaKey;
1183
+}
1184
+?>" />
922 1185
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
923 1186
 				</p>
924 1187
 				-->
@@ -927,10 +1190,16 @@  discard block
 block discarded – undo
927 1190
 						<b>Lufthansa API Key</b>
928 1191
 						<p>
929 1192
 							<label for="lufthansakey">Key</label>
930
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
1193
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
1194
+	print $globalLufthansaKey['key'];
1195
+}
1196
+?>" />
931 1197
 						</p><p>
932 1198
 							<label for="lufthansasecret">Secret</label>
933
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
1199
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
1200
+	print $globalLufthansaKey['secret'];
1201
+}
1202
+?>" />
934 1203
 						</p>
935 1204
 					</div>
936 1205
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -940,11 +1209,17 @@  discard block
 block discarded – undo
940 1209
 						<b>FlightAware API Key</b>
941 1210
 						<p>
942 1211
 							<label for="flightawareusername">Username</label>
943
-							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
1212
+							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
1213
+	print $globalFlightAwareUsername;
1214
+}
1215
+?>" />
944 1216
 						</p>
945 1217
 						<p>
946 1218
 							<label for="flightawarepassword">API key</label>
947
-							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
1219
+							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
1220
+	print $globalFlightAwarePassword;
1221
+}
1222
+?>" />
948 1223
 						</p>
949 1224
 					</div>
950 1225
 					<p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p>
@@ -961,10 +1236,22 @@  discard block
 block discarded – undo
961 1236
 				<p>
962 1237
 					<label for="mapmatchingsource">Map Matching source</label>
963 1238
 					<select name="mapmatchingsource" id="mapmatchingsource">
964
-						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option>
965
-						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option>
966
-						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') print 'selected="selected" '; ?>>OSMR</option>
967
-						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option>
1239
+						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) {
1240
+	print 'selected="selected" ';
1241
+}
1242
+?>>FlightAirMap Map Matching</option>
1243
+						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') {
1244
+	print 'selected="selected" ';
1245
+}
1246
+?>>GraphHopper</option>
1247
+						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') {
1248
+	print 'selected="selected" ';
1249
+}
1250
+?>>OSMR</option>
1251
+						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') {
1252
+	print 'selected="selected" ';
1253
+}
1254
+?>>Mapbox</option>
968 1255
 					</select>
969 1256
 					<p class="help-block">Mapbox need the API Key defined in map section.</p>
970 1257
 					<p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p>
@@ -972,7 +1259,10 @@  discard block
 block discarded – undo
972 1259
 				<br />
973 1260
 				<p>
974 1261
 					<label for="graphhopper">GraphHopper API Key</label>
975
-					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" />
1262
+					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) {
1263
+	print $globalGraphHopperKey;
1264
+}
1265
+?>" />
976 1266
 					<p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p>
977 1267
 				</p>
978 1268
 			</div>
@@ -990,7 +1280,10 @@  discard block
 block discarded – undo
990 1280
 			</p>
991 1281
 			<p>
992 1282
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
993
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
1283
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
1284
+	print $globalNOTAMSource;
1285
+}
1286
+?>" />
994 1287
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
995 1288
 			</p>
996 1289
 			<br />
@@ -1006,14 +1299,20 @@  discard block
 block discarded – undo
1006 1299
 			<div id="metarsrc">
1007 1300
 				<p>
1008 1301
 					<label for="metarsource">URL of your METAR source</label>
1009
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
1302
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
1303
+	print $globalMETARurl;
1304
+}
1305
+?>" />
1010 1306
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
1011 1307
 				</p>
1012 1308
 			</div>
1013 1309
 			<br />
1014 1310
 			<p>
1015 1311
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
1016
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
1312
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
1313
+	print $globalBitlyAccessToken;
1314
+}
1315
+?>" />
1017 1316
 			</p>
1018 1317
 			<br />
1019 1318
 			<p>
@@ -1029,11 +1328,26 @@  discard block
 block discarded – undo
1029 1328
 			<p>
1030 1329
 				<label for="geoid_source">Geoid Source</label>
1031 1330
 				<select name="geoid_source" id="geoid_source">
1032
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
1033
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
1034
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
1035
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
1036
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
1331
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
1332
+	print ' selected="selected"';
1333
+}
1334
+?>>EGM96 15' (2.1MB)</option>
1335
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
1336
+	print ' selected="selected"';
1337
+}
1338
+?>>EGM96 5' (19MB)</option>
1339
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
1340
+	print ' selected="selected"';
1341
+}
1342
+?>>EGM2008 5' (19MB)</option>
1343
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
1344
+	print ' selected="selected"';
1345
+}
1346
+?>>EGM2008 2.5' (75MB)</option>
1347
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
1348
+	print ' selected="selected"';
1349
+}
1350
+?>>EGM2008 1' (470MB)</option>
1037 1351
 				</select>
1038 1352
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
1039 1353
 			</p>
@@ -1055,7 +1369,12 @@  discard block
 block discarded – undo
1055 1369
 			</p>
1056 1370
 			<p>
1057 1371
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
1058
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
1372
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
1373
+	print $globalArchiveMonths;
1374
+} else {
1375
+	echo '1';
1376
+}
1377
+?>" />
1059 1378
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
1060 1379
 			</p>
1061 1380
 			<p>
@@ -1065,12 +1384,22 @@  discard block
 block discarded – undo
1065 1384
 			</p>
1066 1385
 			<p>
1067 1386
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
1068
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
1387
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1388
+	print $globalArchiveKeepMonths;
1389
+} else {
1390
+	echo '1';
1391
+}
1392
+?>" />
1069 1393
 				<p class="help-block">0 to disable</p>
1070 1394
 			</p>
1071 1395
 			<p>
1072 1396
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
1073
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
1397
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1398
+	print $globalArchiveKeepTrackMonths;
1399
+} else {
1400
+	echo '1';
1401
+}
1402
+?>" />
1074 1403
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
1075 1404
 			</p>
1076 1405
 			<br />
@@ -1080,7 +1409,12 @@  discard block
 block discarded – undo
1080 1409
 				<p class="help-block">Uncheck if the script is running as cron job. You should always run it as daemon when it's possible.</p>
1081 1410
 				<div id="cronends"> 
1082 1411
 					<label for="cronend">Run script for xx seconds</label>
1083
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1412
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1413
+	print $globalCronEnd;
1414
+} else {
1415
+	print '0';
1416
+}
1417
+?>" />
1084 1418
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
1085 1419
 				</div>
1086 1420
 			</p>
@@ -1139,20 +1473,40 @@  discard block
 block discarded – undo
1139 1473
 			<br />
1140 1474
 			<p>
1141 1475
 				<label for="refresh">Show flights detected since xxx seconds</label>
1142
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1476
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1477
+	echo $globalLiveInterval;
1478
+} else {
1479
+	echo '200';
1480
+}
1481
+?>" />
1143 1482
 			</p>
1144 1483
 			<p>
1145 1484
 				<label for="maprefresh">Live map refresh (in seconds)</label>
1146
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1485
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1486
+	echo $globalMapRefresh;
1487
+} else {
1488
+	echo '30';
1489
+}
1490
+?>" />
1147 1491
 			</p>
1148 1492
 			<p>
1149 1493
 				<label for="mapidle">Map idle timeout (in minutes)</label>
1150
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1494
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1495
+	echo $globalMapIdleTimeout;
1496
+} else {
1497
+	echo '30';
1498
+}
1499
+?>" />
1151 1500
 				<p class="help-block">0 to disable</p>
1152 1501
 			</p>
1153 1502
 			<p>
1154 1503
 				<label for="minfetch">HTTP/file source fetch every xxx seconds</label>
1155
-				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" />
1504
+				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) {
1505
+	echo $globalMinFetch;
1506
+} else {
1507
+	echo '20';
1508
+}
1509
+?>" />
1156 1510
 			</p>
1157 1511
 			<p>
1158 1512
 				<label for="bbox">Only display flights that we can see on screen (bounding box)</label>
@@ -1171,12 +1525,20 @@  discard block
 block discarded – undo
1171 1525
 			<br />
1172 1526
 			<p>
1173 1527
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
1174
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1528
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1529
+	echo $globalClosestMinDist;
1530
+} else {
1531
+	echo '50';
1532
+}
1533
+?>" />
1175 1534
 			</p>
1176 1535
 			<br />
1177 1536
 			<p>
1178 1537
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1179
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1538
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1539
+	echo $globalAircraftSize;
1540
+}
1541
+?>" />
1180 1542
 			</p>
1181 1543
 			<br />
1182 1544
 			<p>
@@ -1195,22 +1557,42 @@  discard block
 block discarded – undo
1195 1557
 			<br />
1196 1558
 			<p>
1197 1559
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1198
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1560
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1561
+	echo $globalAircraftIconColor;
1562
+} else {
1563
+	echo '1a3151';
1564
+}
1565
+?>" />
1199 1566
 			</p>
1200 1567
 			<br />
1201 1568
 			<p>
1202 1569
 				<label for="marineiconcolor">Color of marine icon on map</label>
1203
-				<input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) echo $globalMarineIconColor; else echo '43d1d8'; ?>" />
1570
+				<input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) {
1571
+	echo $globalMarineIconColor;
1572
+} else {
1573
+	echo '43d1d8';
1574
+}
1575
+?>" />
1204 1576
 			</p>
1205 1577
 			<br />
1206 1578
 			<p>
1207 1579
 				<label for="trackericoncolor">Color of tracker icon on map</label>
1208
-				<input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) echo $globalTrackerIconColor; else echo '1a3151'; ?>" />
1580
+				<input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) {
1581
+	echo $globalTrackerIconColor;
1582
+} else {
1583
+	echo '1a3151';
1584
+}
1585
+?>" />
1209 1586
 			</p>
1210 1587
 			<br />
1211 1588
 			<p>
1212 1589
 				<label for="satelliteiconcolor">Color of satellite icon on map</label>
1213
-				<input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) echo $globalSatelliteIconColor; else echo '1a3151'; ?>" />
1590
+				<input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) {
1591
+	echo $globalSatelliteIconColor;
1592
+} else {
1593
+	echo '1a3151';
1594
+}
1595
+?>" />
1214 1596
 			</p>
1215 1597
 			<?php
1216 1598
 				if (!is_writable('../cache')) {
@@ -1234,14 +1616,27 @@  discard block
 block discarded – undo
1234 1616
 			<p>
1235 1617
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
1236 1618
 				<div class="range">
1237
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
1238
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1619
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1620
+	echo $globalAirportZoom;
1621
+} else {
1622
+	echo '7';
1623
+}
1624
+?>" />
1625
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1626
+	echo $globalAirportZoom;
1627
+} else {
1628
+	echo '7';
1629
+}
1630
+?></output>
1239 1631
 				</div>
1240 1632
 			</p>
1241 1633
 			<br />
1242 1634
 			<p>
1243 1635
 				<label for="customcss">Custom CSS web path</label>
1244
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1636
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1637
+	echo $globalCustomCSS;
1638
+}
1639
+?>" />
1245 1640
 			</p>
1246 1641
 		</fieldset>
1247 1642
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -1271,8 +1666,12 @@  discard block
 block discarded – undo
1271 1666
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1272 1667
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1273 1668
 
1274
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1275
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1669
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1670
+		$error .= 'Mysql driver for PDO must be loaded';
1671
+	}
1672
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1673
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1674
+	}
1276 1675
 	
1277 1676
 	$_SESSION['database_root'] = $dbroot;
1278 1677
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1350,15 +1749,23 @@  discard block
 block discarded – undo
1350 1749
 	$source_city = $_POST['source_city'];
1351 1750
 	$source_country = $_POST['source_country'];
1352 1751
 	$source_ref = $_POST['source_ref'];
1353
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1354
-	else $source_id = array();
1752
+	if (isset($source_id)) {
1753
+		$source_id = $_POST['source_id'];
1754
+	} else {
1755
+		$source_id = array();
1756
+	}
1355 1757
 	
1356 1758
 	$sources = array();
1357 1759
 	foreach ($source_name as $keys => $name) {
1358
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1359
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1760
+	    if (isset($source_id[$keys])) {
1761
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1762
+	    } else {
1763
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1764
+	    }
1765
+	}
1766
+	if (count($sources) > 0) {
1767
+		$_SESSION['sources'] = $sources;
1360 1768
 	}
1361
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1362 1769
 
1363 1770
 	$newsurl = $_POST['newsurl'];
1364 1771
 	$newslng = $_POST['newslang'];
@@ -1371,7 +1778,9 @@  discard block
 block discarded – undo
1371 1778
 		$lng = $newslng[$newskey];
1372 1779
 		if (isset($newsfeeds[$type][$lng])) {
1373 1780
 		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1374
-		} else $newsfeeds[$type][$lng] = array($url);
1781
+		} else {
1782
+			$newsfeeds[$type][$lng] = array($url);
1783
+		}
1375 1784
 	    }
1376 1785
 	}
1377 1786
 	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
@@ -1396,17 +1805,29 @@  discard block
 block discarded – undo
1396 1805
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1397 1806
 
1398 1807
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1399
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1400
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1808
+	if ($globalaircraft == 'aircraft') {
1809
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1810
+	} else {
1811
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1812
+	}
1401 1813
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1402
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1403
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1814
+	if ($globaltracker == 'tracker') {
1815
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1816
+	} else {
1817
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1818
+	}
1404 1819
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1405
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1406
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1820
+	if ($globalmarine == 'marine') {
1821
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1822
+	} else {
1823
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1824
+	}
1407 1825
 	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1408
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1409
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1826
+	if ($globalsatellite == 'satellite') {
1827
+		$settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1828
+	} else {
1829
+		$settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1830
+	}
1410 1831
 
1411 1832
 /*	
1412 1833
 	$globalSBS1Hosts = array();
@@ -1428,23 +1849,37 @@  discard block
 block discarded – undo
1428 1849
 	$name = $_POST['name'];
1429 1850
 	$format = $_POST['format'];
1430 1851
 	$timezones = $_POST['timezones'];
1431
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1432
-	else $sourcestats = array();
1433
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1434
-	else $noarchive = array();
1852
+	if (isset($_POST['sourcestats'])) {
1853
+		$sourcestats = $_POST['sourcestats'];
1854
+	} else {
1855
+		$sourcestats = array();
1856
+	}
1857
+	if (isset($_POST['noarchive'])) {
1858
+		$noarchive = $_POST['noarchive'];
1859
+	} else {
1860
+		$noarchive = array();
1861
+	}
1435 1862
 	$gSources = array();
1436 1863
 	$forcepilots = false;
1437 1864
 	foreach ($host as $key => $h) {
1438
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1439
-		else $cov = 'FALSE';
1440
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1441
-		else $arch = 'FALSE';
1865
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1866
+			$cov = 'TRUE';
1867
+		} else {
1868
+			$cov = 'FALSE';
1869
+		}
1870
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1871
+			$arch = 'TRUE';
1872
+		} else {
1873
+			$arch = 'FALSE';
1874
+		}
1442 1875
 		if (strpos($format[$key],'_callback')) {
1443 1876
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1444 1877
 		} elseif ($format[$key] != 'auto' || ($h != '' || $name[$key] != '')) {
1445 1878
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1446 1879
 		}
1447
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1880
+		if ($format[$key] == 'airwhere') {
1881
+			$forcepilots = true;
1882
+		}
1448 1883
 	}
1449 1884
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1450 1885
 
@@ -1475,7 +1910,9 @@  discard block
 block discarded – undo
1475 1910
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1476 1911
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1477 1912
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1478
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1913
+	} else {
1914
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1915
+	}
1479 1916
 
1480 1917
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1481 1918
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1516,7 +1953,9 @@  discard block
 block discarded – undo
1516 1953
 
1517 1954
 	// Create in settings.php keys not yet configurable if not already here
1518 1955
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1519
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1956
+	if (!isset($globalDebug)) {
1957
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1958
+	}
1520 1959
 
1521 1960
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1522 1961
 	if ($resetyearstats == 'resetyearstats') {
@@ -1559,37 +1998,56 @@  discard block
 block discarded – undo
1559 1998
 	}
1560 1999
 */
1561 2000
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1562
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1563
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1564
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1565
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
2001
+	if ($globalsbs == 'sbs') {
2002
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
2003
+	} else {
2004
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
2005
+	}
2006
+	if ($globalaprs == 'aprs') {
2007
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
2008
+	} else {
2009
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
2010
+	}
1566 2011
 	$va = false;
1567 2012
 	if ($globalivao == 'ivao') {
1568 2013
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1569 2014
 		$va = true;
1570
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
2015
+	} else {
2016
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
2017
+	}
1571 2018
 	if ($globalvatsim == 'vatsim') {
1572 2019
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1573 2020
 		$va = true;
1574
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
2021
+	} else {
2022
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
2023
+	}
1575 2024
 	if ($globalphpvms == 'phpvms') {
1576 2025
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1577 2026
 		$va = true;
1578
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
2027
+	} else {
2028
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
2029
+	}
1579 2030
 	if ($globalvam == 'vam') {
1580 2031
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1581 2032
 		$va = true;
1582
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
2033
+	} else {
2034
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
2035
+	}
1583 2036
 	if ($va) {
1584 2037
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1585
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
2038
+	} else {
2039
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
2040
+	}
1586 2041
 	if ($globalva == 'va' || $va) {
1587 2042
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1588 2043
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1589 2044
 	} else {
1590 2045
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1591
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1592
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
2046
+		if ($forcepilots) {
2047
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
2048
+		} else {
2049
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
2050
+		}
1593 2051
 	}
1594 2052
 	if ($globalvm == 'vm') {
1595 2053
 		$settings = array_merge($settings,array('globalVM' => 'TRUE'));
@@ -1849,7 +2307,9 @@  discard block
 block discarded – undo
1849 2307
 	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1850 2308
 	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1851 2309
 
1852
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2310
+	if (!isset($globalTransaction)) {
2311
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2312
+	}
1853 2313
 
1854 2314
 	// Set some defaults values...
1855 2315
 	if (!isset($globalAircraftImageSources)) {
@@ -1864,15 +2324,23 @@  discard block
 block discarded – undo
1864 2324
 
1865 2325
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1866 2326
 
1867
-	if ($error == '') settings::modify_settings($settings);
1868
-	if ($error == '') settings::comment_settings($settings_comment);
2327
+	if ($error == '') {
2328
+		settings::modify_settings($settings);
2329
+	}
2330
+	if ($error == '') {
2331
+		settings::comment_settings($settings_comment);
2332
+	}
1869 2333
 	if ($error != '') {
1870 2334
 		print '<div class="info column">'.$error.'</div>';
1871 2335
 		require('../footer.php');
1872 2336
 		exit;
1873 2337
 	} else {
1874
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1875
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
2338
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
2339
+			$_SESSION['waypoints'] = 1;
2340
+		}
2341
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
2342
+			$_SESSION['owner'] = 1;
2343
+		}
1876 2344
 		if (isset($_POST['createdb'])) {
1877 2345
 			$_SESSION['install'] = 'database_create';
1878 2346
 		} else {
@@ -1909,10 +2377,18 @@  discard block
 block discarded – undo
1909 2377
 	$popw = false;
1910 2378
 	foreach ($_SESSION['done'] as $done) {
1911 2379
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1912
-	    if ($done == 'Create database') $pop = true;
1913
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1914
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1915
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
2380
+	    if ($done == 'Create database') {
2381
+	    	$pop = true;
2382
+	    }
2383
+	    if ($_SESSION['install'] == 'database_create') {
2384
+	    	$pop = true;
2385
+	    }
2386
+	    if ($_SESSION['install'] == 'database_import') {
2387
+	    	$popi = true;
2388
+	    }
2389
+	    if ($_SESSION['install'] == 'waypoints') {
2390
+	    	$popw = true;
2391
+	    }
1916 2392
 	}
1917 2393
 	if ($pop) {
1918 2394
 	    sleep(5);
@@ -1923,7 +2399,9 @@  discard block
 block discarded – undo
1923 2399
 	} else if ($popw) {
1924 2400
 	    sleep(5);
1925 2401
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1926
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2402
+	} else {
2403
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2404
+	}
1927 2405
 	print '</div></ul>';
1928 2406
 	print '<div id="error"></div>';
1929 2407
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.