Issues (843)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

install/index.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
@session_start();
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
3
//print_r($_SESSION);
4
if (isset($_SESSION['error'])) {
5
	header('Content-Encoding: none;');
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
}
13
/*
14
if (isset($_SESSION['errorlst'])) {
15
	header('Content-Encoding: none;');
16
	echo 'Error : Resetting install... You need to fix the problem and run install again.';
17
	if (isset($_SESSION['error'])) unset($_SESSION['error']);
18
	if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']);
19
	if (isset($_SESSION['next'])) unset($_SESSION['next']);
20
	if (isset($_SESSION['install'])) unset($_SESSION['install']);
21
}
22
*/
23
require_once(dirname(__FILE__).'/class.create_db.php');
24
require_once(dirname(__FILE__).'/class.update_schema.php');
25
require_once(dirname(__FILE__).'/class.settings.php');
26
$title="Install";
27
require(dirname(__FILE__).'/../require/settings.php');
28
require_once(dirname(__FILE__).'/../require/class.Common.php');
29
require(dirname(__FILE__).'/header.php');
30
31
if (!isset($_SESSION['install']) && !isset($_SESSION['identified'])) {
32
	$password = filter_input(INPUT_POST,'password',FILTER_SANITIZE_STRING);
33
	if ($password == '') {
34
		if ($globalInstalled === TRUE && (!isset($globalInstallPassword) || $globalInstallPassword == '')) {
35
			print '<div class="alert alert-danger">You need to change $globalInstalled in settings.php to FALSE if you want to access setup again.</div>';
36
			require('../footer.php');
37
			exit;
38
		} elseif (isset($globalInstallPassword) && $globalInstallPassword != '') {
39
			print '<div class="col-md-6 col-md-offset-3"><form method="post" class="form-horizontal"><fieldset id="askpass"><legend>Install script access</legend><div class="form-group"><label for="password" class="col-sm-2 control-label"><b>Password</b></label><div class="col-sm-10"><input type="password" name="password" id="password" class="form-control" placeholder="Password" value="" /></div></div></fieldset><div class="form-group"><div class="col-sm-offset-2 col-sm-10"><button type="submit" class="btn btn-default">Submit</button></div></div></form></div>';
40
			require('../footer.php');
41
			exit;
42
		}
43
	} elseif (!isset($globalInstallPassword) || $globalInstallPassword == '' || $password != $globalInstallPassword) {
44
			print '<div class="alert alert-danger">Wrong password.</div>';
45
			require('../footer.php');
46
			exit;
47
	}
48
}
49
$_SESSION['identified'] = true;
50
$writable = false;
51
$error = array();
52
if (!isset($_SESSION['install']) && !isset($_POST['dbtype'])) {
53
	if (!is_writable('../require/settings.php')) {
54
		print '<div class="alert alert-danger"><strong>Error</strong> The file <i>require/settings.php</i> must be writable.</div>';
55
		require('../footer.php');
56
		exit;
57
	}
58
	$Common = new Common();
59
	if (!$Common->is__writable('tmp/')) {
60
		print '<div class="alert alert-danger"><strong>Error</strong> The directory <i>install/tmp</i> must be writable to the current user.</div>';
61
		require('../footer.php');
62
		exit;
63
	}
64
	if (!$Common->is__writable('../data/')) {
65
		print '<div class="alert alert-danger"><strong>Error</strong> The directory <i>data</i> must be writable from this page or at least to <i>scripts/update_db.php</i> user.</div>';
66
	}
67
	if (!$Common->is__writable('../images/airlines')) {
68
		print '<div class="alert alert-warning">The directory <i>images/airlines</i> must be writable for virtual airlines IVAO (else you can ignore this warning).</div>';
69
	}
70
	if (!set_time_limit(0)) {
71
		print '<div class="alert alert-info">You may need to update the maximum execution time.</div>';
72
	}
73
	/*
74
	if (!function_exists('pcntl_fork')) {
75
		print '<div class="info column"><p><strong>pcntl_fork is not available. Schedules will not be fetched.</strong></p></div>';
76
	}
77
	*/
78
	/*
79
	if (!extension_loaded('SimpleXML')) {
80
		$error[] = "SimpleXML is not loaded.";
81
	}
82
	if (!extension_loaded('dom')) {
83
		$error[] = "Dom is not loaded. Needed for aircraft schedule";
84
	}
85
	*/
86
	if (!extension_loaded('PDO')) {
87
		$error[] = "PDO is not loaded.";
88
	}
89
	/*
90
	if (!extension_loaded('pdo_sqlite')) {
91
		$error[] = "PDO SQLite is not loaded. Needed to populate database for SBS.";
92
	}
93
	*/
94
	if (!extension_loaded('zip')) {
95
		//$error[] = "ZIP is not loaded. Needed to populate database for SBS.";
96
		print '<div class="alert alert-info">ZIP is not loaded. Needed to populate database for IVAO.</div>';
97
	}
98
	if (!extension_loaded('xml') && !extension_loaded('xmlreader')) {
99
		print '<div class="alert alert-warning"><strong>Alert</strong> XML is not loaded. Needed to parse RSS for News pages and if you want tsk files support.</div>';
100
	}
101
	if (!extension_loaded('json')) {
102
		$error[] = "Json is not loaded. Needed for aircraft schedule and bitly.";
103
	}
104
	if (!extension_loaded('sockets')) {
105
		$error[] = "Sockets is not loaded. Needed to populate DB from spotter_daemon.php script.";
106
	}
107
	if (!extension_loaded('curl')) {
108
		$error[] = "Curl is not loaded.";
109
	}
110
	if (!file_exists(dirname(__FILE__).'/../.htaccess')) {
111
		$error[] = dirname(__FILE__).'/../.htaccess'." doesn't exist. The provided .htaccess must exist if you use Apache.";
112
	}
113
	if(function_exists('apache_get_modules') ){
114
		if(!in_array('mod_rewrite',apache_get_modules())) {
115
			$error[] = "mod_rewrite is not available.";
116
		}
117
	/*
118
		if (!isset($_SERVER['HTTP_FAMHTACCESS'])) {
119
			$error[] = "htaccess is not interpreted. Check your Apache configuration";
120
		}
121
	*/
122
	}
123
124
	if (!function_exists("gettext")) {
125
		print '<div class="alert alert-warning"><strong>Alert</strong> gettext doesn\'t exist. Site translation not available.</div>';
126
	} else {
127
		require_once(dirname(__FILE__).'/../require/class.Language.php');
128
		$Language = new Language();
129
		$availablelng = $Language->getLanguages();
130
		$alllng = $Language->listLocaleDir();
131
		if (count($alllng) != count($availablelng)) {
132
			$notavailable = array();
133
			foreach($alllng as $lng) {
134
				if (!isset($availablelng[$lng])) $notavailable[] = $lng;
135
			}
136
			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
		}
138
	}
139
	print '<div class="alert alert-info">If you use MySQL or MariaDB, check that <i>max_allowed_packet</i> >= 8M, else import of some tables can fail.</div>';
140
	if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
141
		if (function_exists('get_headers')) {
142
			//$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'search',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
143
			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'live/geojson?test',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
144
			if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
145
				print '<div class="alert alert-danger"><strong>Error</strong> Check your configuration, rewrite don\'t seems to work well. If using Apache, you need to desactivate MultiViews <a href="https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration">https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration</a></div>';
146
			} else {
147
				$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'search',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
148
				if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
149
					print '<div class="alert alert-danger"><strong>Error</strong> Check your configuration, rewrite don\'t seems to work well. If using Apache, you need to desactivate MultiViews <a href="https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration">https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration</a></div>';
150
				}
151
			}
152
		}
153
	}
154
	if (count($error) > 0) {
155
		print '<div class="alert alert-danger"><ul>';
156
		foreach ($error as $err) {
157
			print '<li>'.$err.'</li>';
158
		}
159
		print '</ul>You <strong>must</strong> add these modules/fix errors.</div>';
160
	//	require('../footer.php');
161
	//	exit;
162
	}
163
}
164
//if (isset($_SESSION['install'])) echo 'My session';
165
if (!isset($_SESSION['install']) && !isset($_POST['dbtype']) && (count($error) == 0)) {
166
	?>
167
	<div class="info column install">
168
	<form method="post" class="form-horizontal">
169
		<fieldset id="install">
170
			<legend>Install script configuration</legend>
171
			<p>
172
				<label for="installpass">Install password</label>
173
				<input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) print $globalInstallPassword; ?>" />
174
			</p>
175
			<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
		</fieldset>
177
		<fieldset id="database">
178
			<legend>Database configuration</legend>
179
			<p>
180
				<label for="dbtype">Database type</label>
181
				<select name="dbtype" id="dbtype">
182
					<option value="mysql" <?php if (isset($globalDBdriver) && $globalDBdriver == 'mysql') { ?>selected="selected" <?php } ?>>MySQL</option>
183
					<option value="pgsql" <?php if (isset($globalDBdriver) && $globalDBdriver == 'pgsql') { ?>selected="selected" <?php } ?>>PostgreSQL</option>
184
				</select>
185
			</p>
186
			<p>
187
				<label for="createdb">Create database</label>
188
				<input type="checkbox" name="createdb" id="createdb" value="createdb" onClick="create_database_js()" />
189
				<p class="help-block">Create database will not work for MySQL >= 5.7 and MariaDB >= 10.1, you need to create DB and user manually</p>
190
			</p>
191
			<div id="createdb_data">
192
				<p>
193
					<label for="dbroot">Database admin user</label>
194
					<input type="text" name="dbroot" id="dbroot" />
195
				</p>
196
				<p>
197
					<label for="dbrootpass">Database admin password</label>
198
					<input type="password" name="dbrootpass" id="dbrootpass" />
199
				</p>
200
			</div>
201
			<p>
202
				<label for="dbhost">Database hostname</label>
203
				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
204
			</p>
205
			<p>
206
				<label for="dbport">Database port</label>
207
				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
208
				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
209
			</p>
210
			<p>
211
				<label for="dbname">Database name</label>
212
				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
213
			</p>
214
			<p>
215
				<label for="dbuser">Database user</label>
216
				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
217
			</p>
218
			<p>
219
				<label for="dbuserpass">Database user password</label>
220
				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
221
			</p>
222
		</fieldset>
223
		<fieldset id="site">
224
			<legend>Site configuration</legend>
225
			<p>
226
				<label for="sitename">Site name</label>
227
				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
228
			</p>
229
			<p>
230
				<label for="siteurl">Site directory</label>
231
				<?php
232
				    // Try to detect site directory
233
				    if ((!isset($globalURL) || $globalURL == '') && (!isset($globalDBuser) || $globalDBuser == '')) {
234
					if (isset($_SERVER['REQUEST_URI'])) {
235
						$URL = $_SERVER['REQUEST_URI'];
236
						$globalURL = str_replace('/install','',str_replace('/install/','',str_replace('/install/index.php','',$URL)));
237
					}
238
				    }
239
				?>
240
				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
241
				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
242
				<p class="help-block">Can be empty</p>
243
			</p>
244
			<p>
245
				<label for="timezone">Timezone</label>
246
				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
247
				<p class="help-block">ex : UTC, Europe/Paris,...</p>
248
			</p>
249
			<p>
250
				<label for="language">Language</label>
251
				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
252
				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
253
			</p>
254
		</fieldset>
255
		<fieldset id="mapprov">
256
			<legend>Map provider</legend>
257
			<p>
258
				<label for="mapprovider">Default map Provider</label>
259
				<select name="mapprovider" id="mapprovider">
260
					<option value="OpenStreetMap" <?php if (isset($globalMapProvider) && $globalMapProvider == 'OpenStreetMap') { ?>selected="selected" <?php } ?>>OpenStreetMap</option>
261
					<option value="Mapbox" <?php if (isset($globalMapProvider) && $globalMapProvider == 'Mapbox') { ?>selected="selected" <?php } ?>>Mapbox</option>
262
					<option value="MapQuest-OSM" <?php if (isset($globalMapProvider) && $globalMapProvider == 'MapQuest-OSM') { ?>selected="selected" <?php } ?>>MapQuest-OSM</option>
263
					<option value="MapQuest-Aerial" <?php if (isset($globalMapProvider) && $globalMapProvider == 'MapQuest-Aerial') { ?>selected="selected" <?php } ?>>MapQuest-Aerial</option>
264
					<option value="Bing-Hybrid" <?php if (isset($globalMapProvider) && $globalMapProvider == 'Bing-Hybrid') { ?>selected="selected" <?php } ?>>Bing Hybrid</option>
265
					<option value="Yandex" <?php if (isset($globalMapProvider) && $globalMapProvider == 'Yandex') { ?>selected="selected" <?php } ?>>Yandex</option>
266
				</select>
267
			</p>
268
			<div id="mapbox_data">
269
				<p>
270
					<label for="mapboxid">Mapbox id</label>
271
					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
272
				</p>
273
				<p>
274
					<label for="mapboxtoken">Mapbox token</label>
275
					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
276
				</p>
277
				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
278
			</div>
279
			<br />
280
			<div id="google_data">
281
				<p>
282
					<label for="googlekey">Google API key</label>
283
					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
284
					<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
				</p>
286
			</div>
287
			<br />
288
			<div id="bing_data">
289
				<p>
290
					<label for="bingkey">Bing Map key</label>
291
					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
292
					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
293
				</p>
294
			</div>
295
			<br />
296
			<div id="mapquest_data">
297
				<p>
298
					<label for="mapquestkey">MapQuest key</label>
299
					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
300
					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
301
				</p>
302
			</div>
303
			<br />
304
			<div id="here_data">
305
				<p>
306
					<label for="hereappid">Here App_Id</label>
307
					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
308
				</p>
309
				<p>
310
					<label for="hereappcode">Here App_Code</label>
311
					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
312
				</p>
313
				<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
			</div>
315
			<br />
316
			<div id="openweathermap_data">
317
				<p>
318
					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
319
					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
320
					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
321
				</p>
322
			</div>
323
			<br />
324
		</fieldset>
325
		<fieldset id="offline">
326
			<legend>Offline mode</legend>
327
		<?php
328
			if (file_exists(dirname(__FILE__).'/../js/Cesium/Cesium.js')) {
329
		?>
330
			<p>
331
				<input type="checkbox" name="mapoffline" id="mapoffline" value="mapoffline" <?php if (isset($globalMapOffline) && $globalMapOffline) { ?>checked="checked" <?php } ?>/>
332
				<label for="mapoffline">Map offline mode</label>
333
				<p class="help-block">Map offline mode will not use network to display map but Natural Earth</p>
334
			</p>
335
		<?php
336
			}
337
		?>
338
			<p>
339
				<input type="checkbox" name="globaloffline" id="globaloffline" value="globaloffline" <?php if (isset($globalOffline) && $globalOffline) { ?>checked="checked" <?php } ?>/>
340
				<label for="globaloffline">Offline mode</label>
341
				<p class="help-block">Backend will not use network</p>
342
			</p>
343
		</fieldset>
344
		<fieldset id="coverage">
345
			<legend>Coverage area</legend>
346
			<p>
347
				<label for="latitudemax">The maximum latitude (north)</label>
348
				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
349
			</p>
350
			<p>
351
				<label for="latitudemin">The minimum latitude (south)</label>
352
				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
353
			</p>
354
			<p>
355
				<label for="longitudemax">The maximum longitude (west)</label>
356
				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
357
			</p>
358
			<p>
359
				<label for="longitudemin">The minimum longitude (east)</label>
360
				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
361
			</p>
362
			<p>
363
				<label for="latitudecenter">The latitude center</label>
364
				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
365
			</p>
366
			<p>
367
				<label for="longitudecenter">The longitude center</label>
368
				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
369
			</p>
370
			<p>
371
				<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'; ?>" />
373
			</p>
374
			<p>
375
				<label for="squawk_country">Country for squawk usage</label>
376
				<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>
384
				</select>
385
			</p>
386
		</fieldset>
387
		<fieldset id="zone">
388
			<legend>Zone of interest</legend>
389
			<p><i>Only put in DB flights that are inside a circle</i></p>
390
			<p>
391
				<label for="latitude">Center latitude</label>
392
				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
393
			</p>
394
			<p>
395
				<label for="longitude">Center longitude</label>
396
				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
397
			</p>
398
			<p>
399
				<label for="Distance">Distance (in km)</label>
400
				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
401
			</p>
402
		</fieldset>
403
		<fieldset id="sourceloc">
404
			<legend>Sources location</legend>
405
			<table class="sources">
406
				<thead>
407
				<tr>
408
					<th>Name</th>
409
					<th>Latitude</th>
410
					<th>Longitude</th>
411
					<th>Altitude (in m)</th>
412
					<th>City</th>
413
					<th>Country</th>
414
					<th>Source name</th>
415
				</tr>
416
				</thead>
417
				<tbody>
418
		<?php
419
		    if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') {
420
		?>
421
		<!--
422
		<?php
423
			    require_once(dirname(__FILE__).'/../require/class.Connection.php');
424
			    $Connection = new Connection();
425
		?>
426
		-->
427
		<?php
428
			if ($Connection->db != NULL) {
429
			    if ($Connection->tableExists('source_location')) {
430
				require_once(dirname(__FILE__).'/../require/class.Source.php');
431
				$Source = new Source();
432
				//$alllocations = $Source->getAllLocationInfo();
433
				$alllocations = $Source->getLocationInfobyType('');
434
				foreach ($alllocations as $location) {
435
		?>
436
				<tr>
437
	    				<input type="hidden" name="source_id[]" value="<?php print $location['id']; ?>" />
438
					<td><input type="text" name="source_name[]" value="<?php print $location['name']; ?>" /></td>
439
					<td><input type="text" name="source_latitude[]" value="<?php print $location['latitude']; ?>" /></td>
440
					<td><input type="text" name="source_longitude[]" value="<?php print $location['longitude']; ?>" /></td>
441
					<td><input type="text" name="source_altitude[]" value="<?php print $location['altitude']; ?>" /></td>
442
					<td><input type="text" name="source_city[]" value="<?php print $location['city']; ?>" /></td>
443
					<td><input type="text" name="source_country[]" value="<?php print $location['country']; ?>" /></td>
444
					<td><input type="text" name="source_ref[]" value="<?php print $location['source']; ?>" /></td>
445
				</tr>
446
		
447
		<?php
448
				}
449
			    }
450
			}
451
		    }
452
		?>
453
454
				<tr>
455
					<td><input type="text" name="source_name[]" value="" /></td>
456
					<td><input type="text" name="source_latitude[]" value="" /></td>
457
					<td><input type="text" name="source_longitude[]" value="" /></td>
458
					<td><input type="text" name="source_altitude[]" value="" /></td>
459
					<td><input type="text" name="source_city[]" value="" /></td>
460
					<td><input type="text" name="source_country[]" value="" /></td>
461
					<td><input type="text" name="source_ref[]" value="" /></td>
462
				</tr>
463
				</tbody>
464
			</table>
465
			<center>
466
				<input type="button" value="Add a row" class="add-row-source" />
467
				<input type="button" value="Remove last row" class="del-row-source" />
468
			</center>
469
		</fieldset>
470
		<fieldset>
471
			<legend>Source Type</legend>
472
			<p>
473
				<input type="checkbox" name="globalaircraft" id="aircraft" value="aircraft" <?php if (!isset($globalAircraft) || $globalAircraft) { ?>checked="checked" <?php } ?>/>
474
				<label for="aircraft">Aircrafts</label>
475
				<input type="checkbox" name="globaltracker" id="tracker" value="tracker" <?php if (isset($globalTracker) && $globalTracker) { ?>checked="checked" <?php } ?>/>
476
				<label for="tracker">Trackers</label>
477
				<input type="checkbox" name="globalmarine" id="marine" value="marine" <?php if (isset($globalMarine) && $globalMarine) { ?>checked="checked" <?php } ?>/>
478
				<label for="marine">Ships/Vessels</label>
479
				<input type="checkbox" name="globalsatellite" id="satellite" value="satellite" <?php if (isset($globalSatellite) && $globalSatellite) { ?>checked="checked" <?php } ?>/>
480
				<label for="satellite">Satellites</label>
481
			</p>
482
		</fieldset>
483
		<fieldset id="datasource">
484
			<legend>Data source</legend>
485
			<p>
486
				<b>Virtual flights</b>
487
				<p>
488
				<p><i>If you choose IVAO, airlines names and logos will come from ivao.aero (you have to run install/populate_ivao.php to populate table with IVAO data)</i></p>
489
				<input type="checkbox" name="globalva" id="va" value="va" onClick="datasource_js()" <?php if (isset($globalVA) && $globalVA) { ?>checked="checked" <?php } ?>/>
490
				<label for="va">Virtual Airlines</label>
491
				<input type="checkbox" name="globalivao" id="ivao" value="ivao" onClick="datasource_js()" <?php if (isset($globalIVAO) && $globalIVAO) { ?>checked="checked" <?php } ?>/>
492
				<label for="ivao">IVAO</label>
493
				<input type="checkbox" name="globalvatsim" id="vatsim" value="vatsim" onClick="datasource_js()" <?php if (isset($globalVATSIM) && $globalVATSIM) { ?>checked="checked" <?php } ?>/>
494
				<label for="vatsim">VATSIM</label>
495
				<input type="checkbox" name="globalphpvms" id="phpvms" value="phpvms" onClick="datasource_js()" <?php if (isset($globalphpVMS) && $globalphpVMS) { ?>checked="checked" <?php } ?>/>
496
				<label for="phpvms">phpVMS</label>
497
				<input type="checkbox" name="globalvam" id="vam" value="vam" onClick="datasource_js()" <?php if (isset($globalVAM) && $globalVAM) { ?>checked="checked" <?php } ?>/>
498
				<label for="vam">Virtual Airline Manager</label>
499
				</p>
500
			</p><p>
501
				<b>Real flights</b>
502
				<p>
503
<!--
504
				<input type="radio" name="datasource" id="flightaware" value="flightaware" onClick="datasource_js()" <?php if (isset($globalFlightAware) && $globalFlightAware) { ?>checked="checked" <?php } ?>/>
505
				<label for="flightaware">FlightAware (not tested, no more supported no data feed available for test)</label>
506
-->
507
				<input type="checkbox" name="globalsbs" id="sbs" value="sbs" onClick="datasource_js()" <?php if (isset($globalSBS1) && $globalSBS1) { ?>checked="checked" <?php } ?> />
508
				<label for="sbs">ADS-B, SBS-1 format (dump1090 or SBS-1 compatible format)</label>
509
				<input type="checkbox" name="globalaprs" id="aprs" value="aprs" onClick="datasource_js()" <?php if (isset($globalAPRS) && $globalAPRS) { ?>checked="checked" <?php } ?> />
510
				<label for="sbs">APRS from glidernet</label>
511
				<input type="checkbox" name="acars" id="acars" value="acars" onClick="datasource_js()" <?php if (isset($globalACARS) && $globalACARS) { ?>checked="checked" <?php } ?> />
512
				<label for="acars">ACARS</label>
513
				</p>
514
			</p>
515
			<p>
516
				<b>Virtual marine</b>
517
				<p>
518
				<input type="checkbox" name="globalvm" id="globalvm" value="vm" onClick="datasource_js()" <?php if (isset($globalVM) && $globalVM) { ?>checked="checked" <?php } ?>/>
519
				<label for="globalvm">Virtual Marine</label>
520
			</p>
521
522
<!--
523
			<div id="flightaware_data">
524
				<p>
525
					<label for="flightawareusername">FlightAware username</label>
526
					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
527
				</p>
528
				<p>
529
					<label for="flightawarepassword">FlightAware password/API key</label>
530
					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
531
				</p>
532
			</div>
533
-->
534
			<div id="sailaway_data">
535
				<p>
536
					<label for="sailawayemail">Sailaway email</label>
537
					<input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) print $globalSailaway['email']; ?>" />
538
					<p class="help-block">Only needed for Sailaway full format</p>
539
				</p>
540
				<p>
541
					<label for="sailawaypassword">Sailaway password</label>
542
					<input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) print $globalSailaway['password']; ?>" />
543
					<p class="help-block">Only needed for Sailaway full format</p>
544
				</p>
545
				<p>
546
					<label for="sailawaykey">Sailaway API key</label>
547
					<input type="text" name="sailawaykey" id="sailawaykey" value="<?php if (isset($globalSailaway['key'])) print $globalSailaway['key']; ?>" />
548
				</p>
549
			</div>
550
551
<!--			<div id="sbs_data">
552
-->
553
				<fieldset id="sources">
554
					<legend>Sources</legend>
555
					<table id="SourceTable" class="table">
556
						<thead>
557
							<tr>
558
								<th>Host/URL</th>
559
								<th>Port/Callback pass</th>
560
								<th>Format</th>
561
								<th>Name</th>
562
								<th>Source Stats</th>
563
								<th>No archive</th>
564
								<th>Source TimeZone</th>
565
								<th>Action</th>
566
							</tr>
567
						</thead>
568
						<tbody>
569
<?php
570
571
		if (!isset($globalSources) && isset($globalSBS1Hosts)) {
572
			if (!is_array($globalSBS1Hosts)) {
573
				$globalSources[] = array('host' => $globalSBS1Hosts);
574
			} else {
575
				foreach ($globalSBS1Hosts as $host) {
576
					$globalSources[] = array('host' => $host);
577
				}
578
			}
579
		}
580
		$i = 0;
581
		if (isset($globalSources)) {
582
			foreach ($globalSources as $source) {
583
?>
584
							<tr>
585
								<?php
586
								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
587
								?>
588
								<td><input type="text" name="host[]" value="<?php print $source['host']; ?>" /></td>
589
								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
590
								<?php
591
								    } else {
592
									$hostport = explode(':',$source['host']);
593
									if (isset($hostport[1])) {
594
										$host = $hostport[0];
595
										$port = $hostport[1];
596
									} else {
597
										$host = $source['host'];
598
										$port = $source['port'];
599
									}
600
								?>
601
								<td><input type="text" name="host[]" value="<?php print $host; ?>" /></td>
602
								<td><input type="text" name="port[]" class="col-xs-2" value="<?php print $port; ?>" /></td>
603
								<?php
604
								    }
605
								?>
606
								<td>
607
									<select name="format[]">
608
										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
609
										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
610
										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
611
										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
612
										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option>
613
										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') print 'selected'; ?>>Planefinder client</option>
614
										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
615
										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
616
                                        <option value="radarcapejson" <?php if (isset($source['format']) && $source['format'] == 'radarcapejson') print 'selected'; ?>>Radarcape json</option>
617
										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
618
										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
619
										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
620
										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
621
										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option>
622
										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
623
										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
624
										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
625
										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
626
										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
627
										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
628
										<option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') print 'selected'; ?>>ACARS from acarsdec json and vdlm2dec</option>
629
										<option value="acarsjsonudp" <?php if (isset($source['format']) && $source['format'] == 'acarsjsonudp') print 'selected'; ?>>ACARS from acarsdec json and vdlm2dec over UDP</option>
630
										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
631
										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
632
										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
633
										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
634
										<option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') print 'selected'; ?>>Sailaway</option>
635
										<option value="sailawayfull" <?php if (isset($source['format']) && $source['format'] == 'sailawayfull') print 'selected'; ?>>Sailaway with missions, races,...</option>
636
									</select>
637
								</td>
638
								<td>
639
									<input type="text" name="name[]" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
640
								</td>
641
								<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>
642
								<td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
643
								<td>
644
									<select name="timezones[]">
645
								<?php
646
									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
647
									foreach($timezonelist as $timezones){
648
										if (isset($source['timezone']) && $source['timezone'] == $timezones) {
649
											print '<option selected>'.$timezones.'</option>';
650
										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
651
											print '<option selected>'.$timezones.'</option>';
652
										} else print '<option>'.$timezones.'</option>';
653
									}
654
								?>
655
									</select>
656
								</td>
657
								<td><input type="button" value="Delete" onclick="deleteRow(this)" /> <input type="button" value="Add" onclick="insRow()" /></td>
658
							</tr>
659
<?php
660
			}
661
		}
662
?>
663
							<tr>
664
								<td><input type="text" name="host[]" value="" /></td>
665
								<td><input type="text" name="port[]" class="col-xs-2" value="" /></td>
666
								<td>
667
									<select name="format[]">
668
										<option value="auto">Auto</option>
669
										<option value="sbs">SBS</option>
670
										<option value="tsv">TSV</option>
671
										<option value="raw">Raw</option>
672
										<option value="aircraftjson">Dump1090 aircraft.json</option>
673
										<option value="planefinderclient">Planefinder client</option>
674
										<option value="aprs">APRS</option>
675
										<option value="deltadbtxt">Radarcape deltadb.txt</option>
676
										<option value="radarcapejson">Radarcape json</option>
677
										<option value="vatsimtxt">Vatsim</option>
678
										<option value="aircraftlistjson">Virtual Radar Server AircraftList.json</option>
679
										<option value="vrstcp">Virtual Radar Server TCP</option>
680
										<option value="phpvmacars">phpVMS</option>
681
										<option value="vaos">Virtual Airline Operations System (VAOS)</option>
682
										<option value="vam">Virtual Airlines Manager</option>
683
										<option value="whazzup">IVAO</option>
684
										<option value="flightgearmp">FlightGear Multiplayer</option>
685
										<option value="flightgearsp">FlightGear Singleplayer</option>
686
										<option value="acars">ACARS from acarsdec/acarsdeco2 over UDP</option>
687
										<option value="acarssbs3">ACARS SBS-3 over TCP</option>
688
										<option value="acarsjson">ACARS from acarsdec json and vdlm2dec</option>
689
										<option value="acarsjsonudp">ACARS from acarsdec json and vdlm2dec over UDP</option>
690
										<option value="ais">NMEA AIS over TCP</option>
691
										<option value="airwhere">AirWhere website</option>
692
										<option value="hidnseek_callback">HidnSeek Callback</option>
693
										<option value="blitzortung">Blitzortung</option>
694
										<option value="sailaway">Sailaway</option>
695
										<option value="sailawayfull">Sailaway with missions, races,...</option>
696
									</select>
697
								</td>
698
								<td>
699
									<input type="text" name="name[]" value="" id="name" />
700
								</td>
701
								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" /></td>
702
								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" /></td>
703
								<td>
704
									<select name="timezones[]" id="timezones">
705
								<?php
706
									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
707
									foreach($timezonelist as $timezones){
708
										if ($timezones == 'UTC') {
709
											print '<option selected>'.$timezones.'</option>';
710
										} else print '<option>'.$timezones.'</option>';
711
									}
712
								?>
713
									</select>
714
								</td>
715
								<td><input type="button" id="delhosti" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhosti" value="Add" onclick="insRow()" /></td>
716
							</tr>
717
						</tbody>
718
					</table>
719
					<p class="help-block">Source timezone is to define timezone used by a source if not UTC (not your timezone).</p>
720
					<p class="help-block">For working source statistics, the name of the source <b>MUST</b> be the same as the source name of a source location, else center coverage latitude and longitude is used as source position. This is not available/usable with virtual airlines.</p>
721
					<p class="help-block">FlightGear Singleplayer open an UDP server, the host should be <i>0.0.0.0</i>.</p>
722
					<p class="help-block">Virtual Airlines Manager need to use the file <i>install/vAM/VAM-json.php</i> and the url <i>http://yourvaminstall/VAM-json.php</i>.</p>
723
					<p class="help-block">For a local file, you should use file:// before the path.</p>
724
					<p class="help-block">URL and TCP sources can't be used at the same time.</p>
725
					<!-- ' -->
726
					<p class="help-block">Callback script is in <i>import/callback.php</i>. In host you can restrict access to some IP, Callback pass to restrict by a pass using <i>import/callback.php?pass=yourpass</i>.</p>
727
				</fieldset>
728
			</fieldset>
729
			<div id="acars_data">
730
				<fieldset>
731
					<legend>Source ACARS</legend>
732
					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
733
					<p>
734
						<label for="acarshost">ACARS UDP host</label>
735
						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
736
					</p>
737
					<p>
738
						<label for="acarsport">ACARS UDP port</label>
739
						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
740
					</p>
741
					<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>
742
				</fieldset>
743
			</div>
744
		</fieldset>
745
		<fieldset id="newsi">
746
			<legend>News</legend>
747
			<table class="newsi table" id="NewsTable">
748
			    <thead>
749
				<tr>
750
				    <td>RSS/Atom URL</td>
751
				    <td>Language</td>
752
				    <td>Type</td>
753
				    <td>Action</td>
754
			    </thead>
755
			    <tbody>
756
				<?php
757
				    if (isset($globalNewsFeeds) && !empty($globalNewsFeeds)) {
758
					foreach ($globalNewsFeeds as $type => $feedslng) {
759
					    foreach ($feedslng as $lng => $feeds) {
760
						foreach ($feeds as $feed) {
761
				?>
762
				<tr>
763
				    <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td>
764
				    <td>
765
					<select name="newslang[]">
766
					    <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option>
767
					    <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option>
768
					</select>
769
				    </td>
770
				    <td>
771
					<select name="newstype[]">
772
					    <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option>
773
					    <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option>
774
					    <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option>
775
					    <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option>
776
					    <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option>
777
					</select>
778
				    </td>
779
				    <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td>
780
				</tr>
781
				
782
				<?php
783
						}
784
					    }
785
					}
786
				    }
787
				?>
788
				<tr>
789
				    <td><input type="url" name="newsurl[]" /></td>
790
				    <td>
791
					<select name="newslang[]">
792
					    <option value="en">English</option>
793
					    <option value="fr">French</option>
794
					</select>
795
				    </td>
796
				    <td>
797
					<select name="newstype[]">
798
					    <option value="global">Global</option>
799
					    <option value="aircraft">Aircraft</option>
800
					    <option value="marine">Marine</option>
801
					    <option value="tracker">Tracker</option>
802
					    <option value="satellite">Satellite</option>
803
					</select>
804
				    </td>
805
				    <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td>
806
				</tr>
807
			    </tbody>
808
			</table>
809
			<p class="help-block"><i>News</i> page syndicate RSS/Atom feeds. If you only use one mode, use type global.</p>
810
		</fieldset>
811
		
812
		<fieldset id="optional">
813
			<legend>Optional configuration</legend>
814
			<p>
815
				<label for="crash">Add accident/incident support for real flights</label>
816
				<input type="checkbox" name="crash" id="crash" value="crash"<?php if ((isset($globalAccidents) && $globalAccidents) || !isset($globalAccidents)) { ?> checked="checked"<?php } ?> />
817
			</p>
818
			<br />
819
			<p>
820
				<label for="firessupport">Add fires support</label>
821
				<input type="checkbox" name="firessupport" id="firessupport" value="firessupport"<?php if (isset($globalFires) && $globalFires) { ?> checked="checked"<?php } ?> />
822
				<p class="help-block">Fires are updated via <i>update_db.php</i> script.</p>
823
			</p>
824
			<p>
825
				<label for="fires">Display fires on map</label>
826
				<input type="checkbox" name="fires" id="fires" value="fires"<?php if (isset($globalMapFires) && $globalMapFires) { ?> checked="checked"<?php } ?> />
827
				<p class="help-block">Display all fires on map by default.</p>
828
			</p>
829
			<br />
830
			<p>
831
				<label for="map3d">Enable map in 3D</label>
832
				<input type="checkbox" name="map3d" id="map3d" value="map3d"<?php if ((isset($globalMap3D) && $globalMap3D) || !isset($globalMap3D)) { ?> checked="checked"<?php } ?> />
833
				<p class="help-block">Bing map key is needed. <i>scripts/update_db.php</i> will download 3d models needed, about 400Mo is needed for all models.</p>
834
			</p>
835
			<p>
836
				<label for="map3ddefault">Default to map in 3D</label>
837
				<input type="checkbox" name="map3ddefault" id="map3ddefault" value="map3ddefault"<?php if (isset($globalMap3Ddefault) && $globalMap3Ddefault) { ?> checked="checked"<?php } ?> />
838
			</p>
839
			<p>
840
				<label for="one3dmodel">Use same 3D model for all aircraft</label>
841
				<input type="checkbox" name="one3dmodel" id="one3dmodel" value="one3dmodel"<?php if (isset($globalMap3DOneModel) && $globalMap3DOneModel) { ?> checked="checked"<?php } ?> />
842
				<p class="help-block">Use less resources</p>
843
			</p>
844
			<p>
845
				<label for="map3dliveries">Display real liveries</label>
846
				<input type="checkbox" name="map3dliveries" id="map3dliveries" value="map3dliveries"<?php if (isset($globalMap3DLiveries) && $globalMap3DLiveries) { ?> checked="checked"<?php } ?> />
847
				<p class="help-block">Liveries will be loaded when you click on a flight (about 300Mo is needed for all liveries)</p>
848
			</p>
849
			<p>
850
				<label for="map3dtileset">3D Tiles</label>
851
				<input type="text" name="map3dtileset" id="map3dtileset" value="<?php if (isset($globalMap3DTiles) && $globalMap3DTiles) { print $globalMap3DTiles; } ?>" />
852
				<p class="help-block">Set the url of your 3D Tiles</p>
853
			</p>
854
			<p>
855
				<label for="map3dshadows">Use sun shadows on 3D models</label>
856
				<input type="checkbox" name="map3dshadows" id="map3dshadows" value="map3dshadows"<?php if (!isset($globalMap3DShadows) || (isset($globalMap3DShadows) && $globalMap3DShadows)) { ?> checked="checked" <?php } ?> />
857
			</p>
858
			<p>
859
				<label for="corsproxy">CORS proxy</label>
860
				<input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) print $globalCORSproxy; else print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" />
861
				<p class="help-block">CORS proxy used for some WMS servers</p>
862
			</p>
863
<!--
864
			<p>
865
				<label for="mapsatellites">Enable satellites in 3D map</label>
866
				<input type="checkbox" name="mapsatellites" id="mapsatellites" value="mapsatellites"<?php if ((isset($globalMapSatellites) && $globalMapSatellites) || !isset($globalMapSatellites)) { ?> checked="checked"<?php } ?> />
867
				<p class="help-block">Bing map key is needed.</p>
868
			</p>
869
-->
870
			<br />
871
			<p>
872
				<label for="translate">Allow site translation</label>
873
				<input type="checkbox" name="translate" id="translate" value="translate"<?php if (isset($globalTranslate) && $globalTranslate) { ?> checked="checked"<?php } ?> />
874
				<p class="help-block">Display language available, else the site is only available in english.</p>
875
			</p>
876
			<br />
877
			<p>
878
				<label for="realairlines">Always use real airlines</label>
879
				<input type="checkbox" name="realairlines" id="realairlines" value="realairlines"<?php if (isset($globalUseRealAirlines) && $globalUseRealAirlines) { ?> checked="checked"<?php } ?> />
880
				<p class="help-block">Use real airlines for IVAO or VATSIM.</p>
881
			</p>
882
			<br />
883
			<p>
884
				<label for="estimation">Planes animate between updates</label>
885
				<input type="checkbox" name="estimation" id="estimation" value="estimation"<?php if (isset($globalMapEstimation) && $globalMapEstimation) { ?> checked="checked"<?php } ?> />
886
				<p class="help-block">Estimate plane track between flights refresh.</p>
887
			</p>
888
			<br />
889
			<p>
890
				<label for="unitdistance">Unit for distance</label>
891
				<select name="unitdistance" id="unitdistance">
892
					<option value="km" <?php if (isset($globalUnitDistance) && $globalUnitDistance == 'km') { ?>selected="selected" <?php } ?>>Kilometres</option>
893
					<option value="nm" <?php if (isset($globalUnitDistance) && $globalUnitDistance == 'nm') { ?>selected="selected" <?php } ?>>Nautical Miles</option>
894
					<option value="mi" <?php if (isset($globalUnitDistance) && $globalUnitDistance == 'mi') { ?>selected="selected" <?php } ?>>Statute Miles</option>
895
				</select>
896
			</p>
897
			<p>
898
				<label for="unitaltitude">Unit for altitude</label>
899
				<select name="unitaltitude" id="unitaltitude">
900
					<option value="m" <?php if (isset($globalUnitAltitude) && $globalUnitAltitude == 'm') { ?>selected="selected" <?php } ?>>Metres</option>
901
					<option value="feet" <?php if (isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') { ?>selected="selected" <?php } ?>>Feet</option>
902
				</select>
903
			</p>
904
			<p>
905
				<label for="unitspeed">Unit for speed</label>
906
				<select name="unitspeed" id="unitspeed">
907
					<option value="kmh" <?php if (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh') { ?>selected="selected" <?php } ?>>Kilometres/Hour</option>
908
					<option value="mph" <?php if (isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') { ?>selected="selected" <?php } ?>>Miles/Hour</option>
909
					<option value="knots" <?php if (isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') { ?>selected="selected" <?php } ?>>Knots</option>
910
				</select>
911
			</p>
912
			<br />
913
			<div id="optional_sbs">
914
			<p>
915
				<label for="schedules">Retrieve schedules from external websites</label>
916
				<input type="checkbox" name="schedules" id="schedules" value="schedules"<?php if (isset($globalSchedulesFetch) && $globalSchedulesFetch || !isset($globalSchedulesFetch)) { ?> checked="checked"<?php } ?> onClick="schedule_js()" />
917
				<p class="help-block">Not available for IVAO</p>
918
			</p>
919
			<br />
920
			<div id="schedules_options">
921
				<p>
922
					<label for="britishairways">British Airways API Key</label>
923
					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
924
					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
925
				</p>
926
				<!--
927
				<p>
928
					<label for="transavia">Transavia Test API Consumer Key</label>
929
					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
930
					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
931
				</p>
932
				-->
933
				<p>
934
					<div class="form-group">
935
						<b>Lufthansa API Key</b>
936
						<p>
937
							<label for="lufthansakey">Key</label>
938
							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
939
						</p><p>
940
							<label for="lufthansasecret">Secret</label>
941
							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
942
						</p>
943
					</div>
944
					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
945
				</p>
946
				<p>
947
					<div class="form-group">
948
						<b>FlightAware API Key</b>
949
						<p>
950
							<label for="flightawareusername">Username</label>
951
							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
952
						</p>
953
						<p>
954
							<label for="flightawarepassword">API key</label>
955
							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
956
						</p>
957
					</div>
958
					<p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p>
959
				</p>
960
			</div>
961
			<br />
962
			<p>
963
				<label for="mapmatching">Map Matching</label>
964
				<input type="checkbox" name="mapmatching" id="mapmatching" value="mapmatching"<?php if (isset($globalMapMatching) && $globalMapMatching) { ?> checked="checked"<?php } ?> onClick="mapmatching_js()" />
965
				<p class="help-block">Only for Tracker mode</p>
966
			</p>
967
			<br />
968
			<div id="mapmatching_options">
969
				<p>
970
					<label for="mapmatchingsource">Map Matching source</label>
971
					<select name="mapmatchingsource" id="mapmatchingsource">
972
						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option>
973
						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option>
974
						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') print 'selected="selected" '; ?>>OSMR</option>
975
						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option>
976
					</select>
977
					<p class="help-block">Mapbox need the API Key defined in map section.</p>
978
					<p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p>
979
				</p>
980
				<br />
981
				<p>
982
					<label for="graphhopper">GraphHopper API Key</label>
983
					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" />
984
					<p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p>
985
				</p>
986
			</div>
987
			<br />
988
			<p>
989
				<label for="owner">Add private owners of aircrafts</label>
990
				<input type="checkbox" name="owner" id="owner" value="owner"<?php if (isset($globalOwner) && $globalOwner) { ?> checked="checked"<?php } ?> />
991
				<p class="help-block">Display also private owners of aircrafts, else only commercial owners are available</p>
992
			</p>
993
			</div>
994
			<br />
995
			<p>
996
				<label for="notam">Activate NOTAM support</label>
997
				<input type="checkbox" name="notam" id="notam" value="notam"<?php if (isset($globalNOTAM) && $globalNOTAM) { ?> checked="checked"<?php } ?> />
998
			</p>
999
			<p>
1000
				<label for="notamsource">URL of your feed from notaminfo.com</label>
1001
				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
1002
				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
1003
			</p>
1004
			<br />
1005
			<p>
1006
				<label for="metar">Activate METAR support</label>
1007
				<input type="checkbox" name="metar" id="metar" value="metar"<?php if (isset($globalMETAR) && $globalMETAR) { ?> checked="checked"<?php } ?> />
1008
			</p>
1009
			<p>
1010
				<label for="metarcycle">Activate METAR cycle support</label>
1011
				<input type="checkbox" name="metarcycle" id="metarcycle" onClick="metarcycle_js()" value="metarcycle"<?php if (isset($globalMETARcycle) && $globalMETARcycle) { ?> checked="checked"<?php } ?> />
1012
				<p class="help-block">Download feed from NOAA every hour. Need <i>scripts/update_db.php</i> in cron</p>
1013
			</p>
1014
			<div id="metarsrc">
1015
				<p>
1016
					<label for="metarsource">URL of your METAR source</label>
1017
					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
1018
					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
1019
				</p>
1020
			</div>
1021
			<br />
1022
			<!--
1023
			<div id="podaac">
1024
				<p>
1025
					<label for="podaccuser">PO.DAAC username (used for waves)</label>
1026
					<input type="text" name="podaccuser" id="podaccuser" value="<?php if (isset($globalPODAACuser)) print $globalPODAACuser; ?>" />
1027
				</p>
1028
				<p>
1029
					<label for="podaccpass">PO.DAAC password</label>
1030
					<input type="text" name="podaccpass" id="podaccpass" value="<?php if (isset($globalPODAACpass)) print $globalPODAACpass; ?>" />
1031
				</p>
1032
				<p class="help-block">Register an account on <a href="https://podaac-tools.jpl.nasa.gov/drive/">https://podaac-tools.jpl.nasa.gov/drive/</a>, an encoded password is available on this page after registration (not the same as the one used for registration).</p>
1033
			</div>
1034
			<br />
1035
			-->
1036
			<p>
1037
				<label for="bitly">Bit.ly access token api (used in search page)</label>
1038
				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
1039
			</p>
1040
			<br />
1041
			<p>
1042
				<label for="waypoints">Add Waypoints, Airspace and countries data (about 45Mio in DB) <i>Need PostGIS if you use PostgreSQL</i></label>
1043
				<input type="checkbox" name="waypoints" id="waypoints" value="waypoints"<?php if (!isset($globalWaypoints) || (isset($globalWaypoints) && $globalWaypoints)) { ?> checked="checked"<?php } ?> />
1044
			</p>
1045
			<br />
1046
			<p>
1047
				<label for="geoid">Geoid support</label>
1048
				<input type="checkbox" name="geoid" id="geoid" value="geoid"<?php if (!isset($globalGeoid) || (isset($globalGeoid) && $globalGeoid)) { ?> checked="checked"<?php } ?> />
1049
				<p class="help-block">Calculate the height of the geoid above WGS84 ellipsoid. Needed when source give altitute based on above mean sea level.</p>
1050
			</p>
1051
			<p>
1052
				<label for="geoid_source">Geoid Source</label>
1053
				<select name="geoid_source" id="geoid_source">
1054
					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
1055
					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
1056
					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
1057
					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
1058
					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
1059
				</select>
1060
				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
1061
			</p>
1062
			<br />
1063
			<p>
1064
				<label for="resetyearstats">Reset stats every years</label>
1065
				<input type="checkbox" name="resetyearstats" id="resetyearsats" value="1"<?php if ((isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) || !isset($globalDeleteLastYearStats)) { ?> checked="checked"<?php } ?> />
1066
				<p class="help-block">Reset count of aircraft types, airlines, registrations, callsigns, owners, pilots, departure and arrival airports</p>
1067
			</p>
1068
			<br />
1069
			<p>
1070
				<label for="archive">Archive all flights data</label>
1071
				<input type="checkbox" name="archive" id="archive" value="archive"<?php if ((isset($globalArchive) && $globalArchive) || !isset($globalArchive)) { ?> checked="checked"<?php } ?> />
1072
				<p class="help-block">You will need to put <i>update_db.php</i> in cron. But all should be faster when archive is enabled.</p>
1073
			</p>
1074
			<p>
1075
				<label for="archiveresults">Use archive to display results</label>
1076
				<input type="checkbox" name="archiveresults" id="archiveresults" value="archiveresults"<?php if ((isset($globalArchiveResults) && $globalArchiveResults) || !isset($globalArchiveResults)) { ?> checked="checked"<?php } ?> />
1077
			</p>
1078
			<p>
1079
				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
1080
				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
1081
				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
1082
			</p>
1083
			<p>
1084
				<label for="archiveyear">Generate statistics, delete or put in archive flights from previous year</label>
1085
				<input type="checkbox" name="archiveyear" id="archiveyear" value="archiveyear"<?php if (isset($globalArchiveYear) && $globalArchiveYear) { ?> checked="checked"<?php } ?> />
1086
				<p class="help-block">delete old flight if <i>Archive all flights data</i> is disabled</p>
1087
			</p>
1088
			<p>
1089
				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
1090
				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
1091
				<p class="help-block">0 to disable</p>
1092
			</p>
1093
			<p>
1094
				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
1095
				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
1096
				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
1097
			</p>
1098
			<br />
1099
			<p>
1100
				<label for="daemon">Use daemon-spotter.php as daemon</label>
1101
				<input type="checkbox" name="daemon" id="daemon" value="daemon"<?php if ((isset($globalDaemon) && $globalDaemon) || !isset($globalDaemon)) { ?> checked="checked"<?php } ?> onClick="daemon_js()" />
1102
				<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>
1103
				<div id="cronends"> 
1104
					<label for="cronend">Run script for xx seconds</label>
1105
					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1106
					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
1107
				</div>
1108
			</p>
1109
			<br />
1110
			<p>
1111
				<label for="updatecheck">Disable update started check</label>
1112
				<input type="checkbox" name="updatecheck" id="updatecheck" value="updatecheck"<?php if (isset($globalDisableUpdateCheck) && $globalDisableUpdateCheck) { ?> checked="checked"<?php } ?> />
1113
				<p class="help-block">Disable check if <i>scripts/update_db.php</i> is already running</p>
1114
			</p>
1115
			<br />
1116
<!--
1117
			<p>
1118
				<label for="fork">Allow processes fork</label>
1119
				<input type="checkbox" name="fork" id="fork" value="fork"<?php if ((isset($globalFork) && $globalFork) || !isset($globalFork)) { ?> checked="checked"<?php } ?> />
1120
				<p class="help-block">Used for schedule</p>
1121
			</p>
1122
			<br />
1123
-->
1124
			<p>
1125
				<label for="colormap">Show altitudes on map with several colors</label>
1126
				<input type="checkbox" name="colormap" id="colormap" value="colormap"<?php if ((isset($globalMapAltitudeColor) && $globalMapAltitudeColor) || !isset($globalMapAltitudeColor)) { ?> checked="checked"<?php } ?> />
1127
			</p>
1128
<!--
1129
			<p>
1130
				<label for="mappopup">Show flights info in popup</label>
1131
				<input type="checkbox" name="mappopup" id="mappopup" value="mappopup"<?php if ((isset($globalMapPopup) && $globalMapPopup)) { ?> checked="checked"<?php } ?> />
1132
			</p>
1133
			<p>
1134
				<label for="airportpopup">Show airport info in popup</label>
1135
				<input type="checkbox" name="airportpopup" id="airportpopup" value="airportpopup"<?php if ((isset($globalAirportPopup) && $globalAirportPopup)) { ?> checked="checked"<?php } ?> />
1136
			</p>
1137
-->
1138
			<p>
1139
				<label for="maptooltip">Always display callsign (only in 2D and can be slow)</label>
1140
				<input type="checkbox" name="maptooltip" id="maptooltip" value="maptooltip"<?php if ((isset($globalMapPermanentTooltip) && $globalMapPermanentTooltip)) { ?> checked="checked"<?php } ?> />
1141
			</p>
1142
			<br />
1143
			<p>
1144
				<label for="maphistory">Always show path of flights (else only when flight is selected)</label>
1145
				<input type="checkbox" name="maphistory" id="maphistory" value="maphistory"<?php if ((isset($globalMapHistory) && $globalMapHistory) || !isset($globalMapHistory)) { ?> checked="checked"<?php } ?> />
1146
			</p>
1147
			<br />
1148
			<p>
1149
				<label for="flightroute">Show route of flights when selected</label>
1150
				<input type="checkbox" name="flightroute" id="flightroute" value="flightroute"<?php if (isset($globalMapRoute) && $globalMapRoute) { ?> checked="checked"<?php } ?> />
1151
			</p>
1152
			<p>
1153
				<label for="flightremainingroute">Show remaining route of flights when selected</label>
1154
				<input type="checkbox" name="flightremainingroute" id="flightremainingroute" value="flightremainingroute"<?php if ((isset($globalMapRemainingRoute) && $globalMapRemainingRoute) || !isset($globalMapRemainingRoute)) { ?> checked="checked"<?php } ?> />
1155
			</p>
1156
			<br />
1157
			<p>
1158
				<label for="allflights">Put all flights in DB even without coordinates</label>
1159
				<input type="checkbox" name="allflights" id="allflights" value="allflights"<?php if ((isset($globalAllFlights) && $globalAllFlights) || !isset($globalAllFlights)) { ?> checked="checked"<?php } ?> />
1160
			</p>
1161
			<br />
1162
			<p>
1163
				<label for="refresh">Show flights detected since xxx seconds</label>
1164
				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1165
			</p>
1166
			<p>
1167
				<label for="maprefresh">Live map refresh (in seconds)</label>
1168
				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1169
			</p>
1170
			<p>
1171
				<label for="mapidle">Map idle timeout (in minutes)</label>
1172
				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1173
				<p class="help-block">0 to disable</p>
1174
			</p>
1175
			<p>
1176
				<label for="minfetch">HTTP/file source fetch every xxx seconds</label>
1177
				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" />
1178
			</p>
1179
			<p>
1180
				<label for="bbox">Only display flights that we can see on screen (bounding box)</label>
1181
				<input type="checkbox" name="bbox" id="bbox" value="bbox"<?php if (isset($globalMapUseBbox) && $globalMapUseBbox) { ?> checked="checked"<?php } ?> />
1182
			</p>
1183
			<br />
1184
			<p>
1185
				<label for="singlemodel">By default, only display selected model on 3D mode</label>
1186
				<input type="checkbox" name="singlemodel" id="singlemodel" value="singlemodel"<?php if (isset($globalMap3DSelected) && $globalMap3DSelected) { ?> checked="checked"<?php } ?> />
1187
			</p>
1188
			<br />
1189
			<p>
1190
				<label for="groundaltitude">Display and calculate ground altitude (can take lot of disk space)</label>
1191
				<input type="checkbox" name="groundaltitude" id="groundaltitude" value="groundaltitude"<?php if (isset($globalGroundAltitude) && $globalGroundAltitude) { ?> checked="checked"<?php } ?> />
1192
			</p>
1193
			<br />
1194
			<p>
1195
				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
1196
				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1197
			</p>
1198
			<br />
1199
			<p>
1200
				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1201
				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1202
			</p>
1203
			<br />
1204
			<p>
1205
				<label for="noairlines">No airlines check and display (can be used for OGN or Virtual Flights without airlines)</label>
1206
				<input type="checkbox" name="noairlines" id="noairlines" value="noairlines"<?php if (isset($globalNoAirlines) && $globalNoAirlines) { ?> checked="checked"<?php } ?> />
1207
			</p>
1208
			<br />
1209
			<p>
1210
				<label for="tsk">Enable support of XCSoar task (.tsk) files</label>
1211
				<input type="checkbox" name="tsk" id="tsk" value="tsk"<?php if (isset($globalTSK) && $globalTSK) { ?> checked="checked"<?php } ?> />
1212
				<p class="help-block">tsk file can be loaded using http://yourflightairmap/tsk=http://yourtskfile</p>
1213
			</p>
1214
			<?php 
1215
			    if (extension_loaded('gd') && function_exists('gd_info')) {
1216
			?>
1217
			<br />
1218
			<p>
1219
				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1220
				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1221
			</p>
1222
			<br />
1223
			<p>
1224
				<label for="marineiconcolor">Color of marine icon on map</label>
1225
				<input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) echo $globalMarineIconColor; else echo '43d1d8'; ?>" />
1226
			</p>
1227
			<br />
1228
			<p>
1229
				<label for="trackericoncolor">Color of tracker icon on map</label>
1230
				<input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) echo $globalTrackerIconColor; else echo '1a3151'; ?>" />
1231
			</p>
1232
			<br />
1233
			<p>
1234
				<label for="satelliteiconcolor">Color of satellite icon on map</label>
1235
				<input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) echo $globalSatelliteIconColor; else echo '1a3151'; ?>" />
1236
			</p>
1237
			<?php
1238
				if (!is_writable('../cache')) {
1239
			?>
1240
			<br />
1241
			<p>
1242
				<b>The directory cache is not writable, aircraft icon will not be cached</b>
1243
			</p>
1244
			<?php
1245
				}
1246
			    } else {
1247
			?>
1248
			<br />
1249
			<p>
1250
				<b>PHP GD is not installed, you can't change color of aircraft icon on map</b>
1251
			</p>
1252
			<?php
1253
			    }
1254
			?>
1255
			<br />
1256
			<p>
1257
				<label for="airportzoom">Zoom level minimum to see airports icons</label>
1258
				<div class="range">
1259
					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
1260
					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1261
				</div>
1262
			</p>
1263
			<br />
1264
			<p>
1265
				<label for="customcss">Custom CSS web path</label>
1266
				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1267
			</p>
1268
		</fieldset>
1269
		<input type="submit" name="submit" value="Create/Update database & write setup" />
1270
	</form>
1271
	<p>
1272
	    If it fails to populate tables, you can run inside console <i>install/install_db.php</i> or <i>install/install_db.sh</i>.
1273
	</p>
1274
<?php
1275
	require('../footer.php');
1276
        exit;
1277
}
1278
// '	
1279
$settings = array();
1280
$settings_comment = array();
1281
$error = '';
1282
1283
if (isset($_POST['dbtype'])) {
1284
	$installpass = filter_input(INPUT_POST,'installpass',FILTER_SANITIZE_STRING);
1285
	$settings = array_merge($settings,array('globalInstallPassword' => $installpass));
1286
1287
	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
1288
	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
1289
	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
1290
	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
1291
	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
1292
	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
1293
	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1294
	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1295
1296
	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1297
	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1298
	
1299
	$_SESSION['database_root'] = $dbroot;
1300
	$_SESSION['database_rootpass'] = $dbrootpass;
1301
	/*
1302
	if ($error == '' && isset($_POST['createdb']) && $dbname != '' && $dbuser != '' && $dbuserpass != '') {
1303
		if ($dbroot != '' && $dbrootpass != '') {
1304
			$result = create_db::create_database($dbroot,$dbrootpass,$dbuser,$dbuserpass,$dbname,$dbtype,$dbhost);
1305
			if ($result != '') $error .= $result;
1306
		}
1307
		if ($error == '') {
1308
			//$error .= create_db::import_all_db('../db/');
1309
			$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBport' => $dbport,'globalDBuser' => $dbuser,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1310
		}
1311
	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1312
	*/
1313
	
1314
	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1315
1316
	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
1317
	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
1318
	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
1319
	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
1320
	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
1321
1322
	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
1323
	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
1324
	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
1325
	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
1326
	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
1327
	$openweathermapkey = filter_input(INPUT_POST,'openweathermapkey',FILTER_SANITIZE_STRING);
1328
	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
1329
	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
1330
	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
1331
	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey,'globalOpenWeatherMapKey' => $openweathermapkey));
1332
	
1333
	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
1334
	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
1335
	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
1336
	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
1337
	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
1338
	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
1339
1340
	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
1341
	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
1342
1343
	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
1344
	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
1345
	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
1346
1347
	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
1348
	if ($acars == 'acars') {
1349
		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
1350
	} else {
1351
		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
1352
	}
1353
	$updatecheck = filter_input(INPUT_POST,'updatecheck',FILTER_SANITIZE_STRING);
1354
	if ($updatecheck == 'updatecheck') {
1355
		$settings = array_merge($settings,array('globalDisableUpdateCheck' => 'TRUE'));
1356
	} else {
1357
		$settings = array_merge($settings,array('globalDisableUpdateCheck' => 'FALSE'));
1358
	}
1359
1360
	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
1361
	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
1362
	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
1363
	
1364
	$sailawayemail = filter_input(INPUT_POST,'sailawayemail',FILTER_SANITIZE_STRING);
1365
	$sailawaypass = filter_input(INPUT_POST,'sailawaypassword',FILTER_SANITIZE_STRING);
1366
	$sailawaykey = filter_input(INPUT_POST,'sailawaykey',FILTER_SANITIZE_STRING);
1367
	$settings = array_merge($settings,array('globalSailaway' => array('email' => $sailawayemail,'password' => $sailawaypass,'key' => $sailawaykey)));
1368
	
1369
	$source_name = $_POST['source_name'];
1370
	$source_latitude = $_POST['source_latitude'];
1371
	$source_longitude = $_POST['source_longitude'];
1372
	$source_altitude = $_POST['source_altitude'];
1373
	$source_city = $_POST['source_city'];
1374
	$source_country = $_POST['source_country'];
1375
	$source_ref = $_POST['source_ref'];
1376
	if (isset($source_id)) $source_id = $_POST['source_id'];
1377
	else $source_id = array();
1378
	
1379
	$sources = array();
1380
	foreach ($source_name as $keys => $name) {
1381
	    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]);
1382
	    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]);
1383
	}
1384
	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1385
1386
	$newsurl = $_POST['newsurl'];
1387
	$newslng = $_POST['newslang'];
1388
	$newstype = $_POST['newstype'];
1389
	
1390
	$newsfeeds = array();
1391
	foreach($newsurl as $newskey => $url) {
1392
	    if ($url != '') {
1393
		$type = $newstype[$newskey];
1394
		$lng = $newslng[$newskey];
1395
		if (isset($newsfeeds[$type][$lng])) {
1396
		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1397
		} else $newsfeeds[$type][$lng] = array($url);
1398
	    }
1399
	}
1400
	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
1401
1402
	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
1403
	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
1404
	//$sbsurl = filter_input(INPUT_POST,'sbsurl',FILTER_SANITIZE_URL);
1405
	/*
1406
	$sbshost = $_POST['sbshost'];
1407
	$sbsport = $_POST['sbsport'];
1408
	$sbsurl = $_POST['sbsurl'];
1409
	*/
1410
1411
	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
1412
	$globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING);
1413
	$globalvm = filter_input(INPUT_POST,'globalvm',FILTER_SANITIZE_STRING);
1414
	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
1415
	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
1416
	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
1417
	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
1418
	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
1419
	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1420
1421
	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1422
	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1423
	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1424
	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1425
	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1426
	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1427
	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1428
	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1429
	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1430
	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1431
	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1432
	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1433
1434
/*	
1435
	$globalSBS1Hosts = array();
1436
//	if ($datasource != 'ivao' && $datasource != 'vatsim') {
1437
	if ($globalsbs == 'sbs') {
1438
	    foreach ($sbshost as $key => $host) {
1439
		if ($host != '') $globalSBS1Hosts[] = $host.':'.$sbsport[$key];
1440
	    }
1441
	}
1442
	if (count($sbsurl) > 0 && $sbsurl[0] != '') {
1443
	    $sbsurl = array_filter($sbsurl);
1444
	    $globalSBS1Hosts = array_merge($globalSBS1Hosts,$sbsurl);
1445
	}
1446
	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
1447
*/
1448
	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
1449
	$host = $_POST['host'];
1450
	$port = $_POST['port'];
1451
	$name = $_POST['name'];
1452
	$format = $_POST['format'];
1453
	$timezones = $_POST['timezones'];
1454
	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1455
	else $sourcestats = array();
1456
	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1457
	else $noarchive = array();
1458
	$gSources = array();
1459
	$forcepilots = false;
1460
	foreach ($host as $key => $h) {
1461
		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1462
		else $cov = 'FALSE';
1463
		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1464
		else $arch = 'FALSE';
1465
		if (strpos($format[$key],'_callback')) {
1466
			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1467
		} elseif ($format[$key] != 'auto' || ($h != '' || $name[$key] != '')) {
1468
			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1469
		}
1470
		if ($format[$key] == 'airwhere') $forcepilots = true;
1471
	}
1472
	$settings = array_merge($settings,array('globalSources' => $gSources));
1473
1474
/*
1475
	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
1476
	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
1477
*/
1478
	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
1479
	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
1480
	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
1481
1482
	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
1483
	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
1484
1485
	$podaccuser = filter_input(INPUT_POST,'podaccuser',FILTER_SANITIZE_STRING);
1486
	$settings = array_merge($settings,array('globalPODACCuser' => $podaccuser));
1487
	$podaccpass = filter_input(INPUT_POST,'podaccpass',FILTER_SANITIZE_STRING);
1488
	$settings = array_merge($settings,array('globalPODACCpass' => $podaccpass));
1489
1490
	$customcss = filter_input(INPUT_POST,'customcss',FILTER_SANITIZE_STRING);
1491
	$settings = array_merge($settings,array('globalCustomCSS' => $customcss));
1492
1493
	$map3dtile = filter_input(INPUT_POST,'map3dtileset',FILTER_SANITIZE_STRING);
1494
	$settings = array_merge($settings,array('globalMap3DTiles' => $map3dtile));
1495
1496
	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
1497
	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
1498
	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
1499
	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
1500
1501
	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
1502
	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
1503
	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1504
	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1505
		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1506
	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1507
1508
	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1509
	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
1510
	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
1511
	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
1512
	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
1513
	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
1514
	$minfetch = filter_input(INPUT_POST,'minfetch',FILTER_SANITIZE_NUMBER_INT);
1515
	$settings = array_merge($settings,array('globalMinFetch' => $minfetch));
1516
	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
1517
	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
1518
1519
	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
1520
	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
1521
1522
	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
1523
	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
1524
	
1525
	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
1526
	if ($archiveyear == "archiveyear") {
1527
		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
1528
	} else {
1529
		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
1530
	}
1531
	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
1532
	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
1533
	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
1534
	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1535
1536
	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
1537
	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
1538
	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
1539
	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
1540
1541
	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1542
	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1543
	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1544
1545
	// Create in settings.php keys not yet configurable if not already here
1546
	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1547
	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1548
1549
	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1550
	if ($resetyearstats == 'resetyearstats') {
1551
		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1552
	} else {
1553
		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1554
	}
1555
1556
	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1557
	if ($archive == 'archive') {
1558
		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1559
	} else {
1560
		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1561
	}
1562
	$archiveresults = filter_input(INPUT_POST,'archiveresults',FILTER_SANITIZE_STRING);
1563
	if ($archiveresults == 'archiveresults') {
1564
		$settings = array_merge($settings,array('globalArchiveResults' => 'TRUE'));
1565
	} else {
1566
		$settings = array_merge($settings,array('globalArchiveResults' => 'FALSE'));
1567
	}
1568
	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1569
	if ($daemon == 'daemon') {
1570
		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1571
	} else {
1572
		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1573
	}
1574
	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1575
	if ($schedules == 'schedules') {
1576
		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1577
	} else {
1578
		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1579
	}
1580
1581
/*
1582
	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1583
	if ($datasource == 'flightaware') {
1584
		$settings = array_merge($settings,array('globalFlightAware' => 'TRUE','globalSBS1' => 'FALSE'));
1585
	} else {
1586
		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1587
	}
1588
*/
1589
	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1590
	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1591
	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1592
	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1593
	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1594
	$va = false;
1595
	if ($globalivao == 'ivao') {
1596
		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1597
		$va = true;
1598
	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1599
	if ($globalvatsim == 'vatsim') {
1600
		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1601
		$va = true;
1602
	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1603
	if ($globalphpvms == 'phpvms') {
1604
		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1605
		$va = true;
1606
	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1607
	if ($globalvam == 'vam') {
1608
		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1609
		$va = true;
1610
	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1611
	if ($va) {
1612
		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1613
	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1614
	if ($globalva == 'va' || $va) {
1615
		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1616
		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1617
	} else {
1618
		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1619
		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1620
		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1621
	}
1622
	if ($globalvm == 'vm') {
1623
		$settings = array_merge($settings,array('globalVM' => 'TRUE'));
1624
	} else {
1625
		$settings = array_merge($settings,array('globalVM' => 'FALSE'));
1626
	}
1627
	
1628
	$mapoffline = filter_input(INPUT_POST,'mapoffline',FILTER_SANITIZE_STRING);
1629
	if ($mapoffline == 'mapoffline') {
1630
		$settings = array_merge($settings,array('globalMapOffline' => 'TRUE'));
1631
	} else {
1632
		$settings = array_merge($settings,array('globalMapOffline' => 'FALSE'));
1633
	}
1634
	$globaloffline = filter_input(INPUT_POST,'globaloffline',FILTER_SANITIZE_STRING);
1635
	if ($globaloffline == 'globaloffline') {
1636
		$settings = array_merge($settings,array('globalOffline' => 'TRUE'));
1637
	} else {
1638
		$settings = array_merge($settings,array('globalOffline' => 'FALSE'));
1639
	}
1640
1641
	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1642
	if ($notam == 'notam') {
1643
		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1644
	} else {
1645
		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1646
	}
1647
	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1648
	if ($owner == 'owner') {
1649
		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1650
	} else {
1651
		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1652
	}
1653
	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1654
	if ($map3d == 'map3d') {
1655
		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1656
	} else {
1657
		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1658
	}
1659
	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1660
	if ($crash == 'crash') {
1661
		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1662
	} else {
1663
		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1664
	}
1665
	$fires = filter_input(INPUT_POST,'fires',FILTER_SANITIZE_STRING);
1666
	if ($fires == 'fires') {
1667
		$settings = array_merge($settings,array('globalMapFires' => 'TRUE'));
1668
	} else {
1669
		$settings = array_merge($settings,array('globalMapFires' => 'FALSE'));
1670
	}
1671
	$firessupport = filter_input(INPUT_POST,'firessupport',FILTER_SANITIZE_STRING);
1672
	if ($firessupport == 'firessupport') {
1673
		$settings = array_merge($settings,array('globalFires' => 'TRUE'));
1674
	} else {
1675
		$settings = array_merge($settings,array('globalFires' => 'FALSE'));
1676
	}
1677
	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1678
	if ($mapsatellites == 'mapsatellites') {
1679
		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1680
	} else {
1681
		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1682
	}
1683
	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1684
	if ($map3ddefault == 'map3ddefault') {
1685
		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1686
	} else {
1687
		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1688
	}
1689
	$one3dmodel = filter_input(INPUT_POST,'one3dmodel',FILTER_SANITIZE_STRING);
1690
	if ($one3dmodel == 'one3dmodel') {
1691
		$settings = array_merge($settings,array('globalMap3DOneModel' => 'TRUE'));
1692
	} else {
1693
		$settings = array_merge($settings,array('globalMap3DOneModel' => 'FALSE'));
1694
	}
1695
	$map3dliveries = filter_input(INPUT_POST,'map3dliveries',FILTER_SANITIZE_STRING);
1696
	if ($map3dliveries == 'map3dliveries') {
1697
		$settings = array_merge($settings,array('globalMap3DLiveries' => 'TRUE'));
1698
	} else {
1699
		$settings = array_merge($settings,array('globalMap3DLiveries' => 'FALSE'));
1700
	}
1701
	$map3dshadows = filter_input(INPUT_POST,'map3dshadows',FILTER_SANITIZE_STRING);
1702
	if ($map3dshadows == 'map3dshadows') {
1703
		$settings = array_merge($settings,array('globalMap3DShadows' => 'TRUE'));
1704
	} else {
1705
		$settings = array_merge($settings,array('globalMap3DShadows' => 'FALSE'));
1706
	}
1707
	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1708
	if ($translate == 'translate') {
1709
		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1710
	} else {
1711
		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1712
	}
1713
	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1714
	if ($realairlines == 'realairlines') {
1715
		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1716
	} else {
1717
		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1718
	}
1719
	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1720
	if ($estimation == 'estimation') {
1721
		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1722
	} else {
1723
		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1724
	}
1725
	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1726
	if ($metar == 'metar') {
1727
		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1728
	} else {
1729
		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1730
	}
1731
	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1732
	if ($metarcycle == 'metarcycle') {
1733
		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1734
	} else {
1735
		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1736
	}
1737
	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1738
	if ($fork == 'fork') {
1739
		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1740
	} else {
1741
		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1742
	}
1743
1744
	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1745
	if ($colormap == 'colormap') {
1746
		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1747
	} else {
1748
		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1749
	}
1750
	
1751
	if (isset($_POST['aircrafticoncolor'])) {
1752
		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1753
		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1754
	}
1755
	if (isset($_POST['marineiconcolor'])) {
1756
		$marineiconcolor = filter_input(INPUT_POST,'marineiconcolor',FILTER_SANITIZE_STRING);
1757
		$settings = array_merge($settings,array('globalMarineIconColor' => substr($marineiconcolor,1)));
1758
	}
1759
	if (isset($_POST['trackericoncolor'])) {
1760
		$trackericoncolor = filter_input(INPUT_POST,'trackericoncolor',FILTER_SANITIZE_STRING);
1761
		$settings = array_merge($settings,array('globalTrackerIconColor' => substr($trackericoncolor,1)));
1762
	}
1763
	if (isset($_POST['satelliteiconcolor'])) {
1764
		$satelliteiconcolor = filter_input(INPUT_POST,'satelliteiconcolor',FILTER_SANITIZE_STRING);
1765
		$settings = array_merge($settings,array('globalSatelliteIconColor' => substr($satelliteiconcolor,1)));
1766
	}
1767
1768
	$corsproxy = filter_input(INPUT_POST,'corsproxy',FILTER_SANITIZE_STRING);
1769
	$settings = array_merge($settings,array('globalCORSproxy' => $corsproxy));
1770
1771
	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1772
	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1773
1774
	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1775
	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1776
	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1777
	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1778
	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1779
	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1780
1781
	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1782
	if ($mappopup == 'mappopup') {
1783
		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1784
	} else {
1785
		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1786
	}
1787
	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1788
	if ($airportpopup == 'airportpopup') {
1789
		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1790
	} else {
1791
		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1792
	}
1793
	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1794
	if ($maphistory == 'maphistory') {
1795
		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1796
	} else {
1797
		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1798
	}
1799
	$maptooltip = filter_input(INPUT_POST,'maptooltip',FILTER_SANITIZE_STRING);
1800
	if ($maptooltip == 'maptooltip') {
1801
		$settings = array_merge($settings,array('globalMapTooltip' => 'TRUE'));
1802
	} else {
1803
		$settings = array_merge($settings,array('globalMapTooltip' => 'FALSE'));
1804
	}
1805
	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1806
	if ($flightroute == 'flightroute') {
1807
		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1808
	} else {
1809
		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1810
	}
1811
	$flightremainingroute = filter_input(INPUT_POST,'flightremainingroute',FILTER_SANITIZE_STRING);
1812
	if ($flightremainingroute == 'flightremainingroute') {
1813
		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'TRUE'));
1814
	} else {
1815
		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'FALSE'));
1816
	}
1817
	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1818
	if ($allflights == 'allflights') {
1819
		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1820
	} else {
1821
		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1822
	}
1823
	$bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING);
1824
	if ($bbox == 'bbox') {
1825
		$settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE'));
1826
	} else {
1827
		$settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE'));
1828
	}
1829
	$singlemodel = filter_input(INPUT_POST,'singlemodel',FILTER_SANITIZE_STRING);
1830
	if ($singlemodel == 'singlemodel') {
1831
		$settings = array_merge($settings,array('globalMap3DSelected' => 'TRUE'));
1832
	} else {
1833
		$settings = array_merge($settings,array('globalMap3DSelected' => 'FALSE'));
1834
	}
1835
	$groundaltitude = filter_input(INPUT_POST,'groundaltitude',FILTER_SANITIZE_STRING);
1836
	if ($groundaltitude == 'groundaltitude') {
1837
		$settings = array_merge($settings,array('globalGroundAltitude' => 'TRUE'));
1838
	} else {
1839
		$settings = array_merge($settings,array('globalGroundAltitude' => 'FALSE'));
1840
	}
1841
	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1842
	if ($waypoints == 'waypoints') {
1843
		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1844
	} else {
1845
		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1846
	}
1847
	$geoid = filter_input(INPUT_POST,'geoid',FILTER_SANITIZE_STRING);
1848
	if ($geoid == 'geoid') {
1849
		$settings = array_merge($settings,array('globalGeoid' => 'TRUE'));
1850
	} else {
1851
		$settings = array_merge($settings,array('globalGeoid' => 'FALSE'));
1852
	}
1853
	$geoid_source = filter_input(INPUT_POST,'geoid_source',FILTER_SANITIZE_STRING);
1854
	$settings = array_merge($settings,array('globalGeoidSource' => $geoid_source));
1855
1856
	$noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING);
1857
	if ($noairlines == 'noairlines') {
1858
		$settings = array_merge($settings,array('globalNoAirlines' => 'TRUE'));
1859
	} else {
1860
		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1861
	}
1862
1863
	$tsk = filter_input(INPUT_POST,'tsk',FILTER_SANITIZE_STRING);
1864
	if ($tsk == 'tsk') {
1865
		$settings = array_merge($settings,array('globalTSK' => 'TRUE'));
1866
	} else {
1867
		$settings = array_merge($settings,array('globalTSK' => 'FALSE'));
1868
	}
1869
	$mapmatching = filter_input(INPUT_POST,'mapmatching',FILTER_SANITIZE_STRING);
1870
	if ($mapmatching == 'mapmatching') {
1871
		$settings = array_merge($settings,array('globalMapMatching' => 'TRUE'));
1872
	} else {
1873
		$settings = array_merge($settings,array('globalMapMatching' => 'FALSE'));
1874
	}
1875
	$mapmatchingsource = filter_input(INPUT_POST,'mapmatchingsource',FILTER_SANITIZE_STRING);
1876
	$settings = array_merge($settings,array('globalMapMatchingSource' => $mapmatchingsource));
1877
	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1878
	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1879
1880
	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1881
1882
	// Set some defaults values...
1883
	if (!isset($globalAircraftImageSources)) {
1884
	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1885
	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1886
	}
1887
1888
	if (!isset($globalSchedulesSources)) {
1889
	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1890
    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1891
    	}
1892
1893
	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1894
1895
	if ($error == '') settings::modify_settings($settings);
1896
	if ($error == '') settings::comment_settings($settings_comment);
1897
	if ($error != '') {
1898
		print '<div class="info column">'.$error.'</div>';
1899
		require('../footer.php');
1900
		exit;
1901
	} else {
1902
		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1903
		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1904
		if (isset($_POST['createdb'])) {
1905
			$_SESSION['install'] = 'database_create';
1906
		} else {
1907
			require_once(dirname(__FILE__).'/../require/class.Connection.php');
1908
			$Connection = new Connection();
1909
			if ($Connection->latest() && isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1910
				if ($Connection->tableExists('airspace') === false) {
1911
					$_SESSION['install'] = 'waypoints';
1912
				} else {
1913
					$_SESSION['install'] = 'database_import';
1914
				}
1915
			} else {
1916
				$_SESSION['install'] = 'database_import';
1917
			}
1918
		}
1919
		//require('../footer.php');
1920
		print '<div class="info column"><ul>';
1921
		 /*
1922
		if (isset($_POST['createdb'])) {
1923
			$_SESSION['done'] = array('Create database','Write configuration');
1924
			print '<li>Create database....<strong>SUCCESS</strong></li>';
1925
		} else $_SESSION['done'] = array('Write configuration');
1926
		*/
1927
		$_SESSION['done'] = array('Write configuration');
1928
		$_SESSION['errorlst'] = array();
1929
		print '<li>Write configuration....<img src="../images/loading.gif" /></li></ul></div>';
1930
		print "<script>console.log('Configuration writed...');setTimeout(window.location = 'index.php?".rand()."&next=".$_SESSION['install']."',10000);</script>";
1931
	}
1932
} else if (isset($_SESSION['install']) && $_SESSION['install'] != 'finish') {
1933
	print '<div class="info column">';
1934
	print '<ul><div id="step">';
1935
	$pop = false;
1936
	$popi = false;
1937
	$popw = false;
1938
	foreach ($_SESSION['done'] as $done) {
1939
	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1940
	    if ($done == 'Create database') $pop = true;
1941
	    if ($_SESSION['install'] == 'database_create') $pop = true;
1942
	    if ($_SESSION['install'] == 'database_import') $popi = true;
1943
	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1944
	}
1945
	if ($pop) {
1946
	    sleep(5);
1947
	    print '<li>Create database....<img src="../images/loading.gif" /></li>';
1948
	} else if ($popi) {
1949
	    sleep(5);
1950
	    print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1951
	} else if ($popw) {
1952
	    sleep(5);
1953
	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1954
	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1955
	print '</div></ul>';
1956
	print '<div id="error"></div>';
1957
/*	foreach ($_SESSION['done'] as $done) {
1958
	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1959
	}
1960
	print '<li>'.$SESSION['next'].'....<img src="../images/loading.gif" /></li>';
1961
1962
	if ($error != '') {
1963
		print '<div class="info column"><span class="error"><strong>Error</strong>'.$error.'</span></div>';
1964
		require('../footer.php');
1965
                exit;
1966
	}
1967
*/
1968
?>
1969
    <script language="JavaScript">
1970
		function installaction() {
1971
		    $.ajax({
1972
			url:'install-action.php',
1973
			dataType: 'json',
1974
			async: true,
1975
			success: function(result) {
1976
			    console.log(result);
1977
			    $('#step').html('');
1978
			    result['done'].forEach(function(done) {
1979
				$('#step').append('<li>'+ done +'....<strong>SUCCESS</strong></li>');
1980
			    });
1981
			    result['errorlst'].forEach(function(done) {
1982
				$('#step').append('<li>'+ done +'....<strong>FAILED</strong></li>');
1983
			    });
1984
			    if (result['error'] != '') {
1985
				setTimeout(function(){
1986
				    console.log('error !');
1987
				    $('#error').html('<p><b>Error : </b> ' + result['error'] + '</p>');
1988
				}, 1000);
1989
				loop = false;
1990
			    } else if (result['next'] != 'finish') {
1991
				$('#step').append('<li>'+ result['next'] +'....<img src="../images/loading.gif" /></li>');
1992
				installaction();
1993
			    } else if (result['install'] == 'finish') {
1994
				console.log('finish !!!');
1995
				$('#step').append('<li>Reloading page to check all is now ok....<img src="../images/loading.gif" /></li>');
1996
				$(location).attr('href','index.php?next=finish');
1997
				loop = false;
1998
			    }
1999
			},
2000
			error: function(XMLHttpRequest, textStatus, errorThrown) { 
2001
				console.log('error !');
2002
				console.log(XMLHttpRequest);
2003
				$('#error').html('<p><b>Error : </b> ' + textStatus + ' - ' + errorThrown + '</p><p><i>If the error is a time-out, you have to increase PHP script execution time-out</i></p>');
2004
			}
2005
		    });
2006
		}
2007
2008
2009
	$(document).ready(function() {
2010
		installaction();
2011
	});
2012
    </script>
2013
<?php
2014
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'finish') {
2015
	unset($_SESSION['install']);
2016
	unset($_SESSION['identified']);
2017
	unset($_COOKIE['install']);
2018
	print '<div class="info column"><ul>';
2019
	foreach ($_SESSION['done'] as $done) {
2020
	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
2021
	}
2022
	print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>';
2023
	print '</ul></div>';
2024
	print '<br /><p>All is now installed ! Thanks</p>';
2025
	if ($globalSBS1) {
2026
		print '<p>You need to run <b>scripts/daemon-spotter.php</b> as a daemon. You can use init script in the install/init directory.</p>';
2027
	} else {
2028
		print '<p>You need to run <b>scripts/daemon-spotter.php</b>. You can use init script in the install/init directory to run it as daemon.</p>';
2029
	}
2030
	if ($globalACARS) {
2031
		print '<p>You need to run <b>scripts/daemon-acars.php</b> as a daemon. You can use init script in the install/init directory.</p>';
2032
	}
2033
	if ($globalFlightAware && ($globalFlightAwareUsername == '' || $globalFlightAwarePassword == '')) {
2034
		print '<p>You <strong>must</strong> have a FlightAware API account to use FlightAware source</p>';
2035
	}
2036
	if (isset($globalVATSIM) && $globalVATSIM) {
2037
		print '<p>Airline table is populated with VATSIM data</p>';
2038
	}
2039
	if (isset($globalIVAO) && $globalIVAO) {
2040
		print '<p>You need to run install/populate_ivao.php if you want to have IVAO airlines</p>';
2041
	}
2042
	if (isset($globalMap3D) && $globalMap3D) {
2043
		print '<p>You need to run <b>scripts/update_db.php</b> first time manually, this will update all and download 3D models.</p>';
2044
	}
2045
	if (isset($globalVAM) && $globalVAM) {
2046
		print '<p>You need to copy <b>install/VAM/VAM-json.php</b> to your Virtual Airline Manager directory and use this URL as source.</p>';
2047
	}
2048
	if (isset($globalGeoid) && $globalGeoid) {
2049
		print '<p>You need to run <b>scripts/update_db.php</b> to update Geoid file if needed (or first time).</p>';
2050
	}
2051
	print '<p>If you want to keep external data updated, you have to add <b>scripts/update_db.php</b> in cron (every hour or 30 minutes if computer is fast enough).</p>';
2052
	print '<p>If <b>scripts/daemon-spotter.php</b> is already running, you have to restart it.</p>';
2053
	print '</div>';
2054
} else {
2055
	unset($_SESSION['install']);
2056
	unset($_SESSION['identified']);
2057
//	header("Location: index.php");
2058
}
2059
require('../footer.php');
2060
?>