Completed
Push — master ( 492b3e...b38f26 )
by Yannick
29:43
created

install/index.php (1 issue)

Labels
Severity

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();
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
}
12
/*
13
if (isset($_SESSION['errorlst'])) {
14
	header('Content-Encoding: none;');
15
	echo 'Error : Resetting install... You need to fix the problem and run install again.';
16
	if (isset($_SESSION['error'])) unset($_SESSION['error']);
17
	if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']);
18
	if (isset($_SESSION['next'])) unset($_SESSION['next']);
19
	if (isset($_SESSION['install'])) unset($_SESSION['install']);
20
}
21
*/
22
require_once(dirname(__FILE__).'/class.create_db.php');
23
require_once(dirname(__FILE__).'/class.update_schema.php');
24
require_once(dirname(__FILE__).'/class.settings.php');
25
$title="Install";
26
require(dirname(__FILE__).'/../require/settings.php');
27
require_once(dirname(__FILE__).'/../require/class.Common.php');
28
require(dirname(__FILE__).'/header.php');
29
30
if ($globalInstalled && !isset($_SESSION['install'])) {
31
	print '<div class="info column"><p>You need to change $globalInstalled in settings.php to FALSE if you want to access setup again.</p></div>';
32
	require('../footer.php');
33
	exit;
34
}
35
36
$writable = false;
37
$error = array();
38
if (!isset($_SESSION['install']) && !isset($_POST['dbtype'])) {
39
	if (!is_writable('../require/settings.php')) {
40
		print '<div class="info column"><p><strong>The file <i>require/settings.php</i> must be writable.</strong></p></div>';
41
		require('../footer.php');
42
		exit;
43
	}
44
	$Common = new Common();
45
	if (!$Common->is__writable('tmp/')) {
46
		print '<div class="info column"><p><strong>The directory <i>install/tmp</i> must be writable to the current user.</strong></p></div>';
47
		require('../footer.php');
48
		exit;
49
	}
50
	/*
51
	if (!is_writable('../data')) {
52
		print '<div class="info column"><p><strong>The directory <i>data</i> must be writable to <i>scripts/update_db.php</i> user.</strong></p></div>';
53
	}
54
	*/
55
	if (!is_writable('../images/airlines')) {
56
		print '<div class="info column"><p><strong>The directory <i>images/airlines</i> must be writable for IVAO.</strong></p></div>';
57
	}
58
	if (!set_time_limit(0)) {
59
		print '<div class="info column"><p><strong>You may need to update the maximum execution time.</strong></p></div>';
60
	}
61
	/*
62
	if (!function_exists('pcntl_fork')) {
63
		print '<div class="info column"><p><strong>pcntl_fork is not available. Schedules will not be fetched.</strong></p></div>';
64
	}
65
	*/
66
	/*
67
	if (!extension_loaded('SimpleXML')) {
68
		$error[] = "SimpleXML is not loaded.";
69
	}
70
	if (!extension_loaded('dom')) {
71
		$error[] = "Dom is not loaded. Needed for aircraft schedule";
72
	}
73
	*/
74
	if (!extension_loaded('PDO')) {
75
		$error[] = "PDO is not loaded.";
76
	}
77
	/*
78
	if (!extension_loaded('pdo_sqlite')) {
79
		$error[] = "PDO SQLite is not loaded. Needed to populate database for SBS.";
80
	}
81
	*/
82
	if (!extension_loaded('zip')) {
83
		//$error[] = "ZIP is not loaded. Needed to populate database for SBS.";
84
		print '<div class="info column"><p><strong>ZIP is not loaded. Needed to populate database for IVAO.</strong></p></div>';
85
	}
86
	if (!extension_loaded('xml') && !extension_loaded('xmlreader')) {
87
		print '<div class="info column"><p><strong>XML is not loaded. Needed to parse RSS for News pages and if you want tsk files support.</strong></p></div>';
88
	}
89
	if (!extension_loaded('json')) {
90
		$error[] = "Json is not loaded. Needed for aircraft schedule and bitly.";
91
	}
92
	if (!extension_loaded('sockets')) {
93
		$error[] = "Sockets is not loaded. Needed to populate DB from spotter_daemon.php script.";
94
	}
95
	if (!extension_loaded('curl')) {
96
		$error[] = "Curl is not loaded.";
97
	}
98
	if(function_exists('apache_get_modules') ){
99
		if(!in_array('mod_rewrite',apache_get_modules())) {
100
			$error[] = "mod_rewrite is not available.";
101
		}
102
	/*
103
		if (!isset($_SERVER['HTTP_FAMHTACCESS'])) {
104
			$error[] = "htaccess is not interpreted. Check your Apache configuration";
105
		}
106
	*/
107
	}
108
109
	if (!function_exists("gettext")) {
110
		print '<div class="info column"><p><strong>gettext doesn\'t exist. Site translation not available.</strong></p></div>';
111
	}
112
	print '<div class="info column"><p><strong>If you use MySQL or MariaDB, check that <i>max_allowed_packet</i> >= 8M, else import of some table can fail.</strong></p></div>';
113
	if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
114
		if (function_exists('get_headers')) {
115
			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"])));
116
			if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
117
				print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>';
118
			}
119
		}
120
	}
121
	if (count($error) > 0) {
122
		print '<div class="info column"><ul>';
123
		foreach ($error as $err) {
124
			print '<li>'.$err.'</li>';
125
		}
126
		print '</ul>You <strong>must</strong> add these modules/fix errors.</div>';
127
	//	require('../footer.php');
128
	//	exit;
129
	}
130
}
131
//if (isset($_SESSION['install'])) echo 'My session';
132
if (!isset($_SESSION['install']) && !isset($_POST['dbtype']) && (count($error) == 0)) {
133
	?>
134
	<div class="info column install">
135
	<form method="post" class="form-horizontal">
136
		<fieldset id="database">
137
			<legend>Database configuration</legend>
138
			<p>
139
				<label for="dbtype">Database type</label>
140
				<select name="dbtype" id="dbtype">
141
					<option value="mysql" <?php if (isset($globalDBdriver) && $globalDBdriver == 'mysql') { ?>selected="selected" <?php } ?>>MySQL</option>
142
					<option value="pgsql" <?php if (isset($globalDBdriver) && $globalDBdriver == 'pgsql') { ?>selected="selected" <?php } ?>>PostgreSQL</option>
143
				</select>
144
			</p>
145
			<p>
146
				<label for="createdb">Create database</label>
147
				<input type="checkbox" name="createdb" id="createdb" value="createdb" onClick="create_database_js()" />
148
				<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>
149
			</p>
150
			<div id="createdb_data">
151
				<p>
152
					<label for="dbroot">Database admin user</label>
153
					<input type="text" name="dbroot" id="dbroot" />
154
				</p>
155
				<p>
156
					<label for="dbrootpass">Database admin password</label>
157
					<input type="password" name="dbrootpass" id="dbrootpass" />
158
				</p>
159
			</div>
160
			<p>
161
				<label for="dbhost">Database hostname</label>
162
				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
163
			</p>
164
			<p>
165
				<label for="dbport">Database port</label>
166
				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
167
				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
168
			</p>
169
			<p>
170
				<label for="dbname">Database name</label>
171
				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
172
			</p>
173
			<p>
174
				<label for="dbuser">Database user</label>
175
				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
176
			</p>
177
			<p>
178
				<label for="dbuserpass">Database user password</label>
179
				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
180
			</p>
181
		</fieldset>
182
		<fieldset id="site">
183
			<legend>Site configuration</legend>
184
			<p>
185
				<label for="sitename">Site name</label>
186
				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
187
			</p>
188
			<p>
189
				<label for="siteurl">Site directory</label>
190
				<?php
191
				    // Try to detect site directory
192
				    if ((!isset($globalURL) || $globalURL == '') && (!isset($globalDBuser) || $globalDBuser == '')) {
193
					if (isset($_SERVER['REQUEST_URI'])) {
194
						$URL = $_SERVER['REQUEST_URI'];
195
						$globalURL = str_replace('/install','',str_replace('/install/','',str_replace('/install/index.php','',$URL)));
196
					}
197
				    }
198
				?>
199
				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
200
				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
201
				<p class="help-block">Can be empty</p>
202
			</p>
203
			<p>
204
				<label for="timezone">Timezone</label>
205
				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
206
				<p class="help-block">ex : UTC, Europe/Paris,...</p>
207
			</p>
208
			<p>
209
				<label for="language">Language</label>
210
				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
211
				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
212
			</p>
213
		</fieldset>
214
		<fieldset id="mapprov">
215
			<legend>Map provider</legend>
216
			<p>
217
				<label for="mapprovider">Default map Provider</label>
218
				<select name="mapprovider" id="mapprovider">
219
					<option value="OpenStreetMap" <?php if (isset($globalMapProvider) && $globalMapProvider == 'OpenStreetMap') { ?>selected="selected" <?php } ?>>OpenStreetMap</option>
220
					<option value="Mapbox" <?php if (isset($globalMapProvider) && $globalMapProvider == 'Mapbox') { ?>selected="selected" <?php } ?>>Mapbox</option>
221
					<option value="MapQuest-OSM" <?php if (isset($globalMapProvider) && $globalMapProvider == 'MapQuest-OSM') { ?>selected="selected" <?php } ?>>MapQuest-OSM</option>
222
					<option value="MapQuest-Aerial" <?php if (isset($globalMapProvider) && $globalMapProvider == 'MapQuest-Aerial') { ?>selected="selected" <?php } ?>>MapQuest-Aerial</option>
223
					<option value="Bing-Hybrid" <?php if (isset($globalMapProvider) && $globalMapProvider == 'Bing-Hybrid') { ?>selected="selected" <?php } ?>>Bing Hybrid</option>
224
					<option value="Yandex" <?php if (isset($globalMapProvider) && $globalMapProvider == 'Yandex') { ?>selected="selected" <?php } ?>>Yandex</option>
225
				</select>
226
			</p>
227
			<div id="mapbox_data">
228
				<p>
229
					<label for="mapboxid">Mapbox id</label>
230
					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
231
				</p>
232
				<p>
233
					<label for="mapboxtoken">Mapbox token</label>
234
					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
235
				</p>
236
				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
237
			</div>
238
			<br />
239
			<div id="google_data">
240
				<p>
241
					<label for="googlekey">Google API key</label>
242
					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
243
					<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>
244
				</p>
245
			</div>
246
			<br />
247
			<div id="bing_data">
248
				<p>
249
					<label for="bingkey">Bing Map key</label>
250
					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
251
					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
252
				</p>
253
			</div>
254
			<br />
255
			<div id="mapquest_data">
256
				<p>
257
					<label for="mapquestkey">MapQuest key</label>
258
					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
259
					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
260
				</p>
261
			</div>
262
			<br />
263
			<div id="here_data">
264
				<p>
265
					<label for="hereappid">Here App_Id</label>
266
					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
267
				</p>
268
				<p>
269
					<label for="hereappcode">Here App_Code</label>
270
					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
271
				</p>
272
				<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>
273
			</div>
274
			<br />
275
			<div id="openweathermap_data">
276
				<p>
277
					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
278
					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
279
					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
280
				</p>
281
			</div>
282
			<br />
283
		</fieldset>
284
		<fieldset id="offline">
285
			<legend>Offline mode</legend>
286
		<?php
287
			if (file_exists(dirname(__FILE__).'/../js/Cesium/Cesium.js')) {
288
		?>
289
			<p>
290
				<input type="checkbox" name="mapoffline" id="mapoffline" value="mapoffline" <?php if (isset($globalMapOffline) && $globalMapOffline) { ?>checked="checked" <?php } ?>/>
291
				<label for="mapoffline">Map offline mode</label>
292
				<p class="help-block">Map offline mode will not use network to display 3D map but Natural Earth (2D map not available)</p>
293
			</p>
294
		<?php
295
			}
296
		?>
297
			<p>
298
				<input type="checkbox" name="globaloffline" id="globaloffline" value="globaloffline" <?php if (isset($globalOffline) && $globalOffline) { ?>checked="checked" <?php } ?>/>
299
				<label for="globaloffline">Offline mode</label>
300
				<p class="help-block">Backend will not use network</p>
301
			</p>
302
		</fieldset>
303
		<fieldset id="coverage">
304
			<legend>Coverage area</legend>
305
			<p>
306
				<label for="latitudemax">The maximum latitude (north)</label>
307
				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
308
			</p>
309
			<p>
310
				<label for="latitudemin">The minimum latitude (south)</label>
311
				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
312
			</p>
313
			<p>
314
				<label for="longitudemax">The maximum longitude (west)</label>
315
				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
316
			</p>
317
			<p>
318
				<label for="longitudemin">The minimum longitude (east)</label>
319
				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
320
			</p>
321
			<p>
322
				<label for="latitudecenter">The latitude center</label>
323
				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
324
			</p>
325
			<p>
326
				<label for="longitudecenter">The longitude center</label>
327
				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
328
			</p>
329
			<p>
330
				<label for="livezoom">Default Zoom on live map</label>
331
				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
332
			</p>
333
			<p>
334
				<label for="squawk_country">Country for squawk usage</label>
335
				<select name="squawk_country" id="squawk_country">
336
					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
337
					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
338
					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
339
					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
340
					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
341
					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
342
					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
343
				</select>
344
			</p>
345
		</fieldset>
346
		<fieldset id="zone">
347
			<legend>Zone of interest</legend>
348
			<p><i>Only put in DB flights that are inside a circle</i></p>
349
			<p>
350
				<label for="latitude">Center latitude</label>
351
				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
352
			</p>
353
			<p>
354
				<label for="longitude">Center longitude</label>
355
				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
356
			</p>
357
			<p>
358
				<label for="Distance">Distance (in km)</label>
359
				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
360
			</p>
361
		</fieldset>
362
		<fieldset id="sourceloc">
363
			<legend>Sources location</legend>
364
			<table class="sources">
365
				<tr>
366
					<th>Name</th>
367
					<th>Latitude</th>
368
					<th>Longitude</th>
369
					<th>Altitude (in m)</th>
370
					<th>City</th>
371
					<th>Country</th>
372
					<th>Source name</th>
373
				</tr>
374
				
375
		<?php
376
		    if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') {
377
		?>
378
		<!--
379
		<?php
380
			    require_once(dirname(__FILE__).'/../require/class.Connection.php');
381
			    $Connection = new Connection();
382
		?>
383
		-->
384
		<?php
385
			if ($Connection->db != NULL) {
386
			    if ($Connection->tableExists('source_location')) {
387
				require_once(dirname(__FILE__).'/../require/class.Source.php');
388
				$Source = new Source();
389
				//$alllocations = $Source->getAllLocationInfo();
390
				$alllocations = $Source->getLocationInfobyType('');
391
				foreach ($alllocations as $location) {
392
		?>
393
				<tr>
394
	    				<input type="hidden" name="source_id[]" value="<?php print $location['id']; ?>" />
395
					<td><input type="text" name="source_name[]" value="<?php print $location['name']; ?>" /></td>
396
					<td><input type="text" name="source_latitude[]" value="<?php print $location['latitude']; ?>" /></td>
397
					<td><input type="text" name="source_longitude[]" value="<?php print $location['longitude']; ?>" /></td>
398
					<td><input type="text" name="source_altitude[]" value="<?php print $location['altitude']; ?>" /></td>
399
					<td><input type="text" name="source_city[]" value="<?php print $location['city']; ?>" /></td>
400
					<td><input type="text" name="source_country[]" value="<?php print $location['country']; ?>" /></td>
401
					<td><input type="text" name="source_ref[]" value="<?php print $location['source']; ?>" /></td>
402
				</tr>
403
		
404
		<?php
405
				}
406
			    }
407
			}
408
		    }
409
		?>
410
411
				<tr>
412
					<td><input type="text" name="source_name[]" value="" /></td>
413
					<td><input type="text" name="source_latitude[]" value="" /></td>
414
					<td><input type="text" name="source_longitude[]" value="" /></td>
415
					<td><input type="text" name="source_altitude[]" value="" /></td>
416
					<td><input type="text" name="source_city[]" value="" /></td>
417
					<td><input type="text" name="source_country[]" value="" /></td>
418
					<td><input type="text" name="source_ref[]" value="" /></td>
419
				</tr>
420
			</table>
421
			<center>
422
				<input type="button" value="Add a row" class="add-row-source" />
423
				<input type="button" value="Remove last row" class="del-row-source" />
424
			</center>
425
		</fieldset>
426
		<fieldset>
427
			<legend>Source Type</legend>
428
			<p>
429
				<input type="checkbox" name="globalaircraft" id="aircraft" value="aircraft" <?php if (!isset($globalAircraft) || $globalAircraft) { ?>checked="checked" <?php } ?>/>
430
				<label for="aircraft">Aircrafts</label>
431
				<input type="checkbox" name="globaltracker" id="tracker" value="tracker" <?php if (isset($globalTracker) && $globalTracker) { ?>checked="checked" <?php } ?>/>
432
				<label for="tracker">Trackers</label>
433
				<input type="checkbox" name="globalmarine" id="marine" value="marine" <?php if (isset($globalMarine) && $globalMarine) { ?>checked="checked" <?php } ?>/>
434
				<label for="marine">Ships/Vessels</label>
435
				<input type="checkbox" name="globalsatellite" id="satellite" value="satellite" <?php if (isset($globalSatellite) && $globalSatellite) { ?>checked="checked" <?php } ?>/>
436
				<label for="satellite">Satellites</label>
437
			</p>
438
		</fieldset>
439
		<fieldset id="datasource">
440
			<legend>Data source</legend>
441
			<p>
442
				<b>Virtual flights</b>
443
				<p>
444
				<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>
445
				<input type="checkbox" name="globalva" id="va" value="va" onClick="datasource_js()" <?php if (isset($globalVA) && $globalVA) { ?>checked="checked" <?php } ?>/>
446
				<label for="va">Virtual Airlines</label>
447
				<input type="checkbox" name="globalivao" id="ivao" value="ivao" onClick="datasource_js()" <?php if (isset($globalIVAO) && $globalIVAO) { ?>checked="checked" <?php } ?>/>
448
				<label for="ivao">IVAO</label>
449
				<input type="checkbox" name="globalvatsim" id="vatsim" value="vatsim" onClick="datasource_js()" <?php if (isset($globalVATSIM) && $globalVATSIM) { ?>checked="checked" <?php } ?>/>
450
				<label for="vatsim">VATSIM</label>
451
				<input type="checkbox" name="globalphpvms" id="phpvms" value="phpvms" onClick="datasource_js()" <?php if (isset($globalphpVMS) && $globalphpVMS) { ?>checked="checked" <?php } ?>/>
452
				<label for="phpvms">phpVMS</label>
453
				<input type="checkbox" name="globalvam" id="vam" value="vam" onClick="datasource_js()" <?php if (isset($globalVAM) && $globalVAM) { ?>checked="checked" <?php } ?>/>
454
				<label for="vam">Virtual Airline Manager</label>
455
				</p>
456
			</p><p>
457
				<b>Real flights</b>
458
				<p>
459
<!--
460
				<input type="radio" name="datasource" id="flightaware" value="flightaware" onClick="datasource_js()" <?php if (isset($globalFlightAware) && $globalFlightAware) { ?>checked="checked" <?php } ?>/>
461
				<label for="flightaware">FlightAware (not tested, no more supported no data feed available for test)</label>
462
-->
463
				<input type="checkbox" name="globalsbs" id="sbs" value="sbs" onClick="datasource_js()" <?php if (isset($globalSBS1) && $globalSBS1) { ?>checked="checked" <?php } ?> />
464
				<label for="sbs">ADS-B, SBS-1 format (dump1090 or SBS-1 compatible format)</label>
465
				<input type="checkbox" name="globalaprs" id="aprs" value="aprs" onClick="datasource_js()" <?php if (isset($globalAPRS) && $globalAPRS) { ?>checked="checked" <?php } ?> />
466
				<label for="sbs">APRS from glidernet</label>
467
				<input type="checkbox" name="acars" id="acars" value="acars" onClick="datasource_js()" <?php if (isset($globalACARS) && $globalACARS) { ?>checked="checked" <?php } ?> />
468
				<label for="acars">ACARS</label>
469
				</p>
470
			</p>
471
<!--
472
			<div id="flightaware_data">
473
				<p>
474
					<label for="flightawareusername">FlightAware username</label>
475
					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
476
				</p>
477
				<p>
478
					<label for="flightawarepassword">FlightAware password/API key</label>
479
					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
480
				</p>
481
			</div>
482
-->
483
<!--			<div id="sbs_data">
484
-->
485
				<fieldset id="sources">
486
					<legend>Sources</legend>
487
					<table id="SourceTable" class="table">
488
						<thead>
489
							<tr>
490
								<th>Host/URL</th>
491
								<th>Port/Callback pass</th>
492
								<th>Format</th>
493
								<th>Name</th>
494
								<th>Source Stats</th>
495
								<th>No archive</th>
496
								<th>Source TimeZone</th>
497
								<th>Action</th>
498
							</tr>
499
						</thead>
500
						<tbody>
501
<?php
502
503
		if (!isset($globalSources) && isset($globalSBS1Hosts)) {
504
			if (!is_array($globalSBS1Hosts)) {
505
				$globalSources[] = array('host' => $globalSBS1Hosts);
506
			} else {
507
				foreach ($globalSBS1Hosts as $host) {
508
					$globalSources[] = array('host' => $host);
509
				}
510
			}
511
		}
512
		$i = 0;
513
		if (isset($globalSources)) {
514
			foreach ($globalSources as $source) {
515
?>
516
							<tr>
517
								<?php
518
								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
519
								?>
520
								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
521
								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
522
								<?php
523
								    } else {
524
									$hostport = explode(':',$source['host']);
525
									if (isset($hostport[1])) {
526
										$host = $hostport[0];
527
										$port = $hostport[1];
528
									} else {
529
										$host = $source['host'];
530
										$port = $source['port'];
531
									}
532
								?>
533
								<td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td>
534
								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php print $port; ?>" /></td>
535
								<?php
536
								    }
537
								?>
538
								<td>
539
									<select name="format[]" id="format">
540
										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
541
										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
542
										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
543
										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
544
										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option>
545
										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
546
										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
547
										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
548
										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
549
										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
550
										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
551
										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option>
552
										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
553
										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
554
										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
555
										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
556
										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
557
										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
558
										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
559
										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
560
										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
561
										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
562
									</select>
563
								</td>
564
								<td>
565
									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
566
								</td>
567
								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
568
								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
569
								<td>
570
									<select name="timezones[]" id="timezones">
571
								<?php
572
									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
573
									foreach($timezonelist as $timezones){
574
										if (isset($source['timezone']) && $source['timezone'] == $timezones) {
575
											print '<option selected>'.$timezones.'</option>';
576
										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
577
											print '<option selected>'.$timezones.'</option>';
578
										} else print '<option>'.$timezones.'</option>';
579
									}
580
								?>
581
									</select>
582
								</td>
583
								<td><input type="button" id="delhost" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhost" value="Add" onclick="insRow()" /></td>
584
							</tr>
585
<?php
586
			}
587
		}
588
?>
589
							<tr>
590
								<td><input type="text" id="host" name="host[]" value="" /></td>
591
								<td><input type="text" id="port" name="port[]" class="col-xs-2" value="" /></td>
592
								<td>
593
									<select name="format[]" id="format">
594
										<option value="auto">Auto</option>
595
										<option value="sbs">SBS</option>
596
										<option value="tsv">TSV</option>
597
										<option value="raw">Raw</option>
598
										<option value="aircraftjson">Dump1090 aircraft.json</option>
599
										<option value="aprs">APRS</option>
600
										<option value="deltadbtxt">Radarcape deltadb.txt</option>
601
										<option value="vatsimtxt">Vatsim</option>
602
										<option value="aircraftlistjson">Virtual Radar Server AircraftList.json</option>
603
										<option value="vrstcp">Virtual Radar Server TCP</option>
604
										<option value="phpvmacars">phpVMS</option>
605
										<option value="vaos">Virtual Airline Operations System (VAOS)</option>
606
										<option value="vam">Virtual Airlines Manager</option>
607
										<option value="whazzup">IVAO</option>
608
										<option value="flightgearmp">FlightGear Multiplayer</option>
609
										<option value="flightgearsp">FlightGear Singleplayer</option>
610
										<option value="acars">ACARS from acarsdec/acarsdeco2 over UDP</option>
611
										<option value="acarssbs3">ACARS SBS-3 over TCP</option>
612
										<option value="ais">NMEA AIS over TCP</option>
613
										<option value="airwhere">AirWhere website</option>
614
										<option value="hidnseek_callback">HidnSeek Callback</option>
615
										<option value="blitzortung">Blitzortung</option>
616
									</select>
617
								</td>
618
								<td>
619
									<input type="text" name="name[]" value="" id="name" />
620
								</td>
621
								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" /></td>
622
								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" /></td>
623
								<td>
624
									<select name="timezones[]" id="timezones">
625
								<?php
626
									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
627
									foreach($timezonelist as $timezones){
628
										if ($timezones == 'UTC') {
629
											print '<option selected>'.$timezones.'</option>';
630
										} else print '<option>'.$timezones.'</option>';
631
									}
632
								?>
633
									</select>
634
								</td>
635
								<td><input type="button" id="addhost" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhost" value="Add" onclick="insRow()" /></td>
636
							</tr>
637
						</tbody>
638
					</table>
639
					<p class="help-block">Source timezone is to define timezone used by a source if not UTC (not your timezone).</p>
640
					<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>
641
					<p class="help-block">FlightGear Singleplayer open an UDP server, the host should be <i>0.0.0.0</i>.</p>
642
					<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>
643
					<p class="help-block">For a local file, you should use file:// before the path.</p>
644
					<p class="help-block">URL and TCP sources can't be used at the same time.</p>
645
					<!-- ' -->
646
					<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>
647
				</fieldset>
648
			</fieldset>
649
			<div id="acars_data">
650
				<fieldset>
651
					<legend>Source ACARS</legend>
652
					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
653
					<p>
654
						<label for="acarshost">ACARS UDP host</label>
655
						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
656
					</p>
657
					<p>
658
						<label for="acarsport">ACARS UDP port</label>
659
						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
660
					</p>
661
				</fieldset>
662
			</div>
663
		</fieldset>
664
		<fieldset id="newsi">
665
			<legend>News</legend>
666
			<table class="newsi table" id="NewsTable">
667
			    <thead>
668
				<tr>
669
				    <td>RSS/Atom URL</td>
670
				    <td>Language</td>
671
				    <td>Type</td>
672
				    <td>Action</td>
673
			    </thead>
674
			    <tbody>
675
				<?php
676
				    if (isset($globalNewsFeeds) && !empty($globalNewsFeeds)) {
677
					foreach ($globalNewsFeeds as $type => $feedslng) {
678
					    foreach ($feedslng as $lng => $feeds) {
679
						foreach ($feeds as $feed) {
680
				?>
681
				<tr>
682
				    <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td>
683
				    <td>
684
					<select name="newslang[]">
685
					    <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option>
686
					    <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option>
687
					</select>
688
				    </td>
689
				    <td>
690
					<select name="newstype[]">
691
					    <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option>
692
					    <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option>
693
					    <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option>
694
					    <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option>
695
					    <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option>
696
					</select>
697
				    </td>
698
				    <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td>
699
				</tr>
700
				
701
				<?php
702
						}
703
					    }
704
					}
705
				    }
706
				?>
707
				<tr>
708
				    <td><input type="url" name="newsurl[]" /></td>
709
				    <td>
710
					<select name="newslang[]">
711
					    <option value="en">English</option>
712
					    <option value="fr">French</option>
713
					</select>
714
				    </td>
715
				    <td>
716
					<select name="newstype[]">
717
					    <option value="global">Global</option>
718
					    <option value="aircraft">Aircraft</option>
719
					    <option value="marine">Marine</option>
720
					    <option value="tracker">Tracker</option>
721
					    <option value="satellite">Satellite</option>
722
					</select>
723
				    </td>
724
				    <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td>
725
				</tr>
726
			    </tbody>
727
			</table>
728
			<p class="help-block"><i>News</i> page syndicate RSS/Atom feeds. If you only use one mode, use type global.</p>
729
		</fieldset>
730
		
731
		<fieldset id="optional">
732
			<legend>Optional configuration</legend>
733
			<p>
734
				<label for="crash">Add accident/incident support for real flights</label>
735
				<input type="checkbox" name="crash" id="crash" value="crash"<?php if ((isset($globalAccidents) && $globalAccidents) || !isset($globalAccidents)) { ?> checked="checked"<?php } ?> />
736
			</p>
737
			<br />
738
			<p>
739
				<label for="firessupport">Add fires support</label>
740
				<input type="checkbox" name="firessupport" id="firessupport" value="firessupport"<?php if (isset($globalFires) && $globalFires) { ?> checked="checked"<?php } ?> />
741
				<p class="help-block">Fires are updated via <i>update_db.php</i> script.</p>
742
			</p>
743
			<p>
744
				<label for="fires">Display fires on map</label>
745
				<input type="checkbox" name="fires" id="fires" value="fires"<?php if (isset($globalMapFires) && $globalMapFires) { ?> checked="checked"<?php } ?> />
746
				<p class="help-block">Display all fires on map by default.</p>
747
			</p>
748
			<br />
749
			<p>
750
				<label for="map3d">Enable map in 3D</label>
751
				<input type="checkbox" name="map3d" id="map3d" value="map3d"<?php if ((isset($globalMap3D) && $globalMap3D) || !isset($globalMap3D)) { ?> checked="checked"<?php } ?> />
752
				<p class="help-block">Bing map key is needed.</p>
753
			</p>
754
			<p>
755
				<label for="map3ddefault">Default to map in 3D</label>
756
				<input type="checkbox" name="map3ddefault" id="map3ddefault" value="map3ddefault"<?php if (isset($globalMap3Ddefault) && $globalMap3Ddefault) { ?> checked="checked"<?php } ?> />
757
			</p>
758
			<p>
759
				<label for="map3dliveries">Display real liveries</label>
760
				<input type="checkbox" name="map3dliveries" id="map3dliveries" value="map3dliveries"<?php if (isset($globalMap3DLiveries) && $globalMap3DLiveries) { ?> checked="checked"<?php } ?> />
761
				<p class="help-block">Liveries will be loaded when you click on a flight</p>
762
			</p>
763
			<p>
764
				<label for="map3dtileset">3D Tiles</label>
765
				<input type="text" name="map3dtileset" id="map3dtileset" value="<?php if (isset($globalMap3DTiles) && $globalMap3DTiles) { print $globalMap3DTiles; } ?>" />
766
				<p class="help-block">Set the url of your 3D Tiles</p>
767
			</p>
768
<!--
769
			<p>
770
				<label for="mapsatellites">Enable satellites in 3D map</label>
771
				<input type="checkbox" name="mapsatellites" id="mapsatellites" value="mapsatellites"<?php if ((isset($globalMapSatellites) && $globalMapSatellites) || !isset($globalMapSatellites)) { ?> checked="checked"<?php } ?> />
772
				<p class="help-block">Bing map key is needed.</p>
773
			</p>
774
-->
775
			<br />
776
			<p>
777
				<label for="translate">Allow site translation</label>
778
				<input type="checkbox" name="translate" id="translate" value="translate"<?php if (isset($globalTranslate) && $globalTranslate) { ?> checked="checked"<?php } ?> />
779
				<p class="help-block">Display language available, else the site is only available in english.</p>
780
			</p>
781
			<br />
782
			<p>
783
				<label for="realairlines">Always use real airlines</label>
784
				<input type="checkbox" name="realairlines" id="realairlines" value="realairlines"<?php if (isset($globalUseRealAirlines) && $globalUseRealAirlines) { ?> checked="checked"<?php } ?> />
785
				<p class="help-block">Use real airlines even for IVAO or VATSIM.</p>
786
			</p>
787
			<br />
788
			<p>
789
				<label for="estimation">Planes animate between updates</label>
790
				<input type="checkbox" name="estimation" id="estimation" value="estimation"<?php if (isset($globalMapEstimation) && $globalMapEstimation) { ?> checked="checked"<?php } ?> />
791
				<p class="help-block">Estimate plane track between flights refresh.</p>
792
			</p>
793
			<br />
794
			<p>
795
				<label for="unitdistance">Unit for distance</label>
796
				<select name="unitdistance" id="unitdistance">
797
					<option value="km" <?php if (isset($globalUnitDistance) && $globalUnitDistance == 'km') { ?>selected="selected" <?php } ?>>Kilometres</option>
798
					<option value="nm" <?php if (isset($globalUnitDistance) && $globalUnitDistance == 'nm') { ?>selected="selected" <?php } ?>>Nautical Miles</option>
799
					<option value="mi" <?php if (isset($globalUnitDistance) && $globalUnitDistance == 'mi') { ?>selected="selected" <?php } ?>>Statute Miles</option>
800
				</select>
801
			</p>
802
			<p>
803
				<label for="unitaltitude">Unit for altitude</label>
804
				<select name="unitaltitude" id="unitaltitude">
805
					<option value="m" <?php if (isset($globalUnitAltitude) && $globalUnitAltitude == 'm') { ?>selected="selected" <?php } ?>>Metres</option>
806
					<option value="feet" <?php if (isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') { ?>selected="selected" <?php } ?>>Feet</option>
807
				</select>
808
			</p>
809
			<p>
810
				<label for="unitspeed">Unit for speed</label>
811
				<select name="unitspeed" id="unitspeed">
812
					<option value="kmh" <?php if (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh') { ?>selected="selected" <?php } ?>>Kilometres/Hour</option>
813
					<option value="mph" <?php if (isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') { ?>selected="selected" <?php } ?>>Miles/Hour</option>
814
					<option value="knots" <?php if (isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') { ?>selected="selected" <?php } ?>>Knots</option>
815
				</select>
816
			</p>
817
			<br />
818
			<div id="optional_sbs">
819
			<p>
820
				<label for="schedules">Retrieve schedules from external websites</label>
821
				<input type="checkbox" name="schedules" id="schedules" value="schedules"<?php if (isset($globalSchedulesFetch) && $globalSchedulesFetch || !isset($globalSchedulesFetch)) { ?> checked="checked"<?php } ?> onClick="schedule_js()" />
822
				<p class="help-block">Not available for IVAO</p>
823
			</p>
824
			<br />
825
			<div id="schedules_options">
826
				<p>
827
					<label for="britishairways">British Airways API Key</label>
828
					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
829
					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
830
				</p>
831
				<!--
832
				<p>
833
					<label for="transavia">Transavia Test API Consumer Key</label>
834
					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
835
					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
836
				</p>
837
				-->
838
				<p>
839
					<div class="form-group">
840
						<b>Lufthansa API Key</b>
841
						<p>
842
							<label for="lufthansakey">Key</label>
843
							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
844
						</p><p>
845
							<label for="lufthansasecret">Secret</label>
846
							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
847
						</p>
848
					</div>
849
					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
850
				</p>
851
				<p>
852
					<div class="form-group">
853
						<b>FlightAware API Key</b>
854
						<p>
855
							<label for="flightawareusername">Username</label>
856
							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
857
						</p>
858
						<p>
859
							<label for="flightawarepassword">API key</label>
860
							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
861
						</p>
862
					</div>
863
					<p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p>
864
				</p>
865
			</div>
866
			<br />
867
			<p>
868
				<label for="mapmatching">Map Matching</label>
869
				<input type="checkbox" name="mapmatching" id="mapmatching" value="mapmatching"<?php if (isset($globalMapMatching) && $globalMapMatching) { ?> checked="checked"<?php } ?> onClick="mapmatching_js()" />
870
				<p class="help-block">Only for Tracker mode</p>
871
			</p>
872
			<br />
873
			<div id="mapmatching_options">
874
				<p>
875
					<label for="mapmatchingsource">Map Matching source</label>
876
					<select name="mapmatchingsource" id="mapmatchingsource">
877
						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option>
878
						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option>
879
						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr')) print 'selected="selected" '; ?>>OSMR</option>
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected ')'
Loading history...
880
						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option>
881
					</select>
882
					<p class="help-block">Mapbox need the API Key defined in map section.</p>
883
					<p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p>
884
				</p>
885
				<br />
886
				<p>
887
					<label for="graphhopper">GraphHopper API Key</label>
888
					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" />
889
					<p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p>
890
				</p>
891
			</div>
892
			<br />
893
			<p>
894
				<label for="owner">Add private owners of aircrafts</label>
895
				<input type="checkbox" name="owner" id="owner" value="owner"<?php if (isset($globalOwner) && $globalOwner) { ?> checked="checked"<?php } ?> />
896
				<p class="help-block">Display also private owners of aircrafts, else only commercial owners are available</p>
897
			</p>
898
			</div>
899
			<br />
900
			<p>
901
				<label for="notam">Activate NOTAM support</label>
902
				<input type="checkbox" name="notam" id="notam" value="notam"<?php if (isset($globalNOTAM) && $globalNOTAM) { ?> checked="checked"<?php } ?> />
903
			</p>
904
			<p>
905
				<label for="notamsource">URL of your feed from notaminfo.com</label>
906
				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
907
				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
908
			</p>
909
			<br />
910
			<p>
911
				<label for="metar">Activate METAR support</label>
912
				<input type="checkbox" name="metar" id="metar" value="metar"<?php if (isset($globalMETAR) && $globalMETAR) { ?> checked="checked"<?php } ?> />
913
			</p>
914
			<p>
915
				<label for="metarcycle">Activate METAR cycle support</label>
916
				<input type="checkbox" name="metarcycle" id="metarcycle" onClick="metarcycle_js()" value="metarcycle"<?php if (isset($globalMETARcycle) && $globalMETARcycle) { ?> checked="checked"<?php } ?> />
917
				<p class="help-block">Download feed from NOAA every hour. Need <i>scripts/update_db.php</i> in cron</p>
918
			</p>
919
			<div id="metarsrc">
920
				<p>
921
					<label for="metarsource">URL of your METAR source</label>
922
					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
923
					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
924
				</p>
925
			</div>
926
			<br />
927
			<p>
928
				<label for="bitly">Bit.ly access token api (used in search page)</label>
929
				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
930
			</p>
931
			<br />
932
			<p>
933
				<label for="waypoints">Add Waypoints, Airspace and countries data (about 45Mio in DB) <i>Need PostGIS if you use PostgreSQL</i></label>
934
				<input type="checkbox" name="waypoints" id="waypoints" value="waypoints"<?php if (!isset($globalWaypoints) || (isset($globalWaypoints) && $globalWaypoints)) { ?> checked="checked"<?php } ?> />
935
			</p>
936
			<br />
937
			<p>
938
				<label for="geoid">Geoid support</label>
939
				<input type="checkbox" name="geoid" id="geoid" value="geoid"<?php if (!isset($globalGeoid) || (isset($globalGeoid) && $globalGeoid)) { ?> checked="checked"<?php } ?> />
940
				<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>
941
			</p>
942
			<p>
943
				<label for="geoid_source">Geoid Source</label>
944
				<select name="geoid_source" id="geoid_source">
945
					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
946
					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
947
					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
948
					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
949
					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
950
				</select>
951
				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
952
			</p>
953
			<br />
954
			<p>
955
				<label for="resetyearstats">Reset stats every years</label>
956
				<input type="checkbox" name="resetyearstats" id="resetyearsats" value="1"<?php if ((isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) || !isset($globalDeleteLastYearStats)) { ?> checked="checked"<?php } ?> />
957
				<p class="help-block">Reset count of aircraft types, airlines, registrations, callsigns, owners, pilots, departure and arrival airports</p>
958
			</p>
959
			<br />
960
			<p>
961
				<label for="archive">Archive all flights data</label>
962
				<input type="checkbox" name="archive" id="archive" value="archive"<?php if ((isset($globalArchive) && $globalArchive) || !isset($globalArchive)) { ?> checked="checked"<?php } ?> />
963
				<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>
964
			</p>
965
			<p>
966
				<label for="archiveresults">Use archive to display results</label>
967
				<input type="checkbox" name="archiveresults" id="archiveresults" value="archiveresults"<?php if ((isset($globalArchiveResults) && $globalArchiveResults) || !isset($globalArchiveResults)) { ?> checked="checked"<?php } ?> />
968
			</p>
969
			<p>
970
				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
971
				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
972
				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
973
			</p>
974
			<p>
975
				<label for="archiveyear">Generate statistics, delete or put in archive flights from previous year</label>
976
				<input type="checkbox" name="archiveyear" id="archiveyear" value="archiveyear"<?php if (isset($globalArchiveYear) && $globalArchiveYear) { ?> checked="checked"<?php } ?> />
977
				<p class="help-block">delete old flight if <i>Archive all flights data</i> is disabled</p>
978
			</p>
979
			<p>
980
				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
981
				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
982
				<p class="help-block">0 to disable</p>
983
			</p>
984
			<p>
985
				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
986
				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
987
				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
988
			</p>
989
			<br />
990
			<p>
991
				<label for="daemon">Use daemon-spotter.php as daemon</label>
992
				<input type="checkbox" name="daemon" id="daemon" value="daemon"<?php if ((isset($globalDaemon) && $globalDaemon) || !isset($globalDaemon)) { ?> checked="checked"<?php } ?> onClick="daemon_js()" />
993
				<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>
994
				<div id="cronends"> 
995
					<label for="cronend">Run script for xx seconds</label>
996
					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
997
					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
998
				</div>
999
			</p>
1000
			<br />
1001
<!--
1002
			<p>
1003
				<label for="fork">Allow processes fork</label>
1004
				<input type="checkbox" name="fork" id="fork" value="fork"<?php if ((isset($globalFork) && $globalFork) || !isset($globalFork)) { ?> checked="checked"<?php } ?> />
1005
				<p class="help-block">Used for schedule</p>
1006
			</p>
1007
			<br />
1008
-->
1009
			<p>
1010
				<label for="colormap">Show altitudes on map with several colors</label>
1011
				<input type="checkbox" name="colormap" id="colormap" value="colormap"<?php if ((isset($globalMapAltitudeColor) && $globalMapAltitudeColor) || !isset($globalMapAltitudeColor)) { ?> checked="checked"<?php } ?> />
1012
			</p>
1013
<!--
1014
			<p>
1015
				<label for="mappopup">Show flights info in popup</label>
1016
				<input type="checkbox" name="mappopup" id="mappopup" value="mappopup"<?php if ((isset($globalMapPopup) && $globalMapPopup)) { ?> checked="checked"<?php } ?> />
1017
			</p>
1018
			<p>
1019
				<label for="airportpopup">Show airport info in popup</label>
1020
				<input type="checkbox" name="airportpopup" id="airportpopup" value="airportpopup"<?php if ((isset($globalAirportPopup) && $globalAirportPopup)) { ?> checked="checked"<?php } ?> />
1021
			</p>
1022
-->
1023
			<p>
1024
				<label for="maptooltip">Always display callsign (only in 2D and can be slow)</label>
1025
				<input type="checkbox" name="maptooltip" id="maptooltip" value="maptooltip"<?php if ((isset($globalMapPermanentTooltip) && $globalMapPermanentTooltip)) { ?> checked="checked"<?php } ?> />
1026
			</p>
1027
			<br />
1028
			<p>
1029
				<label for="maphistory">Always show path of flights (else only when flight is selected)</label>
1030
				<input type="checkbox" name="maphistory" id="maphistory" value="maphistory"<?php if ((isset($globalMapHistory) && $globalMapHistory) || !isset($globalMapHistory)) { ?> checked="checked"<?php } ?> />
1031
			</p>
1032
			<br />
1033
			<p>
1034
				<label for="flightroute">Show route of flights when selected</label>
1035
				<input type="checkbox" name="flightroute" id="flightroute" value="flightroute"<?php if (isset($globalMapRoute) && $globalMapRoute) { ?> checked="checked"<?php } ?> />
1036
			</p>
1037
			<p>
1038
				<label for="flightremainingroute">Show remaining route of flights when selected</label>
1039
				<input type="checkbox" name="flightremainingroute" id="flightremainingroute" value="flightremainingroute"<?php if ((isset($globalMapRemainingRoute) && $globalMapRemainingRoute) || !isset($globalMapRemainingRoute)) { ?> checked="checked"<?php } ?> />
1040
			</p>
1041
			<br />
1042
			<p>
1043
				<label for="allflights">Put all flights in DB even without coordinates</label>
1044
				<input type="checkbox" name="allflights" id="allflights" value="allflights"<?php if ((isset($globalAllFlights) && $globalAllFlights) || !isset($globalAllFlights)) { ?> checked="checked"<?php } ?> />
1045
			</p>
1046
			<br />
1047
			<p>
1048
				<label for="refresh">Show flights detected since xxx seconds</label>
1049
				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1050
			</p>
1051
			<p>
1052
				<label for="maprefresh">Live map refresh (in seconds)</label>
1053
				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1054
			</p>
1055
			<p>
1056
				<label for="mapidle">Map idle timeout (in minutes)</label>
1057
				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1058
				<p class="help-block">0 to disable</p>
1059
			</p>
1060
			<p>
1061
				<label for="minfetch">HTTP/file source fetch every xxx seconds</label>
1062
				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" />
1063
			</p>
1064
			<p>
1065
				<label for="bbox">Only display flights that we can see on screen (bounding box)</label>
1066
				<input type="checkbox" name="bbox" id="bbox" value="bbox"<?php if (isset($globalMapUseBbox) && $globalMapUseBbox) { ?> checked="checked"<?php } ?> />
1067
			</p>
1068
			<br />
1069
			<p>
1070
				<label for="groundaltitude">Display and calculate ground altitude (can take lot of disk space)</label>
1071
				<input type="checkbox" name="groundaltitude" id="groundaltitude" value="groundaltitude"<?php if (isset($globalGroundAltitude) && $globalGroundAltitude) { ?> checked="checked"<?php } ?> />
1072
			</p>
1073
			<br />
1074
			<p>
1075
				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
1076
				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1077
			</p>
1078
			<br />
1079
			<p>
1080
				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1081
				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1082
			</p>
1083
			<br />
1084
			<p>
1085
				<label for="noairlines">No airlines check and display (can be used for OGN or Virtual Flights without airlines)</label>
1086
				<input type="checkbox" name="noairlines" id="noairlines" value="noairlines"<?php if (isset($globalNoAirlines) && $globalNoAirlines) { ?> checked="checked"<?php } ?> />
1087
			</p>
1088
			<br />
1089
			<p>
1090
				<label for="tsk">Enable support of XCSoar task (.tsk) files</label>
1091
				<input type="checkbox" name="tsk" id="tsk" value="tsk"<?php if (isset($globalTSK) && $globalTSK) { ?> checked="checked"<?php } ?> />
1092
				<p class="help-block">tsk file can be loaded using http://yourflightairmap/tsk=http://yourtskfile</p>
1093
			</p>
1094
			<br />
1095
			<p>
1096
			<?php 
1097
			    if (extension_loaded('gd') && function_exists('gd_info')) {
1098
			?>
1099
				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1100
				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1101
			<?php
1102
				if (!is_writable('../cache')) {
1103
			?>
1104
				<b>The directory cache is not writable, aircraft icon will not be cached</b>
1105
			<?php
1106
				}
1107
			    } else {
1108
			?>
1109
				<b>PHP GD is not installed, you can't change color of aircraft icon on map</b>
1110
			<?php
1111
			    }
1112
			?>
1113
			</p>
1114
			<br />
1115
			<p>
1116
				<label for="airportzoom">Zoom level minimum to see airports icons</label>
1117
				<div class="range">
1118
					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
1119
					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1120
				</div>
1121
			</p>
1122
			<br />
1123
			<p>
1124
				<label for="customcss">Custom CSS web path</label>
1125
				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1126
			</p>
1127
		</fieldset>
1128
		<input type="submit" name="submit" value="Create/Update database & write setup" />
1129
	</form>
1130
	<p>
1131
	    If it fails to populate tables, you can run inside console <i>install/install_db.php</i> or <i>install/install_db.sh</i>.
1132
	</p>
1133
<?php
1134
	require('../footer.php');
1135
        exit;
1136
}
1137
// '	
1138
$settings = array();
1139
$settings_comment = array();
1140
$error = '';
1141
1142
if (isset($_POST['dbtype'])) {
1143
	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
1144
	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
1145
	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
1146
	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
1147
	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
1148
	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
1149
	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1150
	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1151
1152
	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1153
	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1154
	
1155
	$_SESSION['database_root'] = $dbroot;
1156
	$_SESSION['database_rootpass'] = $dbrootpass;
1157
	/*
1158
	if ($error == '' && isset($_POST['createdb']) && $dbname != '' && $dbuser != '' && $dbuserpass != '') {
1159
		if ($dbroot != '' && $dbrootpass != '') {
1160
			$result = create_db::create_database($dbroot,$dbrootpass,$dbuser,$dbuserpass,$dbname,$dbtype,$dbhost);
1161
			if ($result != '') $error .= $result;
1162
		}
1163
		if ($error == '') {
1164
			//$error .= create_db::import_all_db('../db/');
1165
			$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBport' => $dbport,'globalDBuser' => $dbuser,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1166
		}
1167
	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1168
	*/
1169
	
1170
	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1171
1172
	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
1173
	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
1174
	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
1175
	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
1176
	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
1177
1178
	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
1179
	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
1180
	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
1181
	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
1182
	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
1183
	$openweathermapkey = filter_input(INPUT_POST,'openweathermapkey',FILTER_SANITIZE_STRING);
1184
	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
1185
	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
1186
	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
1187
	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey,'globalOpenWeatherMapKey' => $openweathermapkey));
1188
	
1189
	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
1190
	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
1191
	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
1192
	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
1193
	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
1194
	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
1195
1196
	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
1197
	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
1198
1199
	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
1200
	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
1201
	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
1202
1203
	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
1204
	if ($acars == 'acars') {
1205
		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
1206
	} else {
1207
		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
1208
	}
1209
1210
	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
1211
	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
1212
	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
1213
	
1214
	$source_name = $_POST['source_name'];
1215
	$source_latitude = $_POST['source_latitude'];
1216
	$source_longitude = $_POST['source_longitude'];
1217
	$source_altitude = $_POST['source_altitude'];
1218
	$source_city = $_POST['source_city'];
1219
	$source_country = $_POST['source_country'];
1220
	$source_ref = $_POST['source_ref'];
1221
	if (isset($source_id)) $source_id = $_POST['source_id'];
1222
	else $source_id = array();
1223
	
1224
	$sources = array();
1225
	foreach ($source_name as $keys => $name) {
1226
	    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]);
1227
	    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]);
1228
	}
1229
	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1230
1231
	$newsurl = $_POST['newsurl'];
1232
	$newslng = $_POST['newslang'];
1233
	$newstype = $_POST['newstype'];
1234
	
1235
	$newsfeeds = array();
1236
	foreach($newsurl as $newskey => $url) {
1237
	    if ($url != '') {
1238
		$type = $newstype[$newskey];
1239
		$lng = $newslng[$newskey];
1240
		if (isset($newsfeeds[$type][$lng])) {
1241
		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1242
		} else $newsfeeds[$type][$lng] = array($url);
1243
	    }
1244
	}
1245
	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
1246
1247
	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
1248
	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
1249
	//$sbsurl = filter_input(INPUT_POST,'sbsurl',FILTER_SANITIZE_URL);
1250
	/*
1251
	$sbshost = $_POST['sbshost'];
1252
	$sbsport = $_POST['sbsport'];
1253
	$sbsurl = $_POST['sbsurl'];
1254
	*/
1255
1256
	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
1257
	$globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING);
1258
	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
1259
	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
1260
	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
1261
	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
1262
	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
1263
	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1264
1265
	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1266
	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1267
	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1268
	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1269
	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1270
	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1271
	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1272
	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1273
	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1274
	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1275
	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1276
	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1277
1278
/*	
1279
	$globalSBS1Hosts = array();
1280
//	if ($datasource != 'ivao' && $datasource != 'vatsim') {
1281
	if ($globalsbs == 'sbs') {
1282
	    foreach ($sbshost as $key => $host) {
1283
		if ($host != '') $globalSBS1Hosts[] = $host.':'.$sbsport[$key];
1284
	    }
1285
	}
1286
	if (count($sbsurl) > 0 && $sbsurl[0] != '') {
1287
	    $sbsurl = array_filter($sbsurl);
1288
	    $globalSBS1Hosts = array_merge($globalSBS1Hosts,$sbsurl);
1289
	}
1290
	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
1291
*/
1292
	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
1293
	$host = $_POST['host'];
1294
	$port = $_POST['port'];
1295
	$name = $_POST['name'];
1296
	$format = $_POST['format'];
1297
	$timezones = $_POST['timezones'];
1298
	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1299
	else $sourcestats = array();
1300
	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1301
	else $noarchive = array();
1302
	$gSources = array();
1303
	$forcepilots = false;
1304
	foreach ($host as $key => $h) {
1305
		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1306
		else $cov = 'FALSE';
1307
		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1308
		else $arch = 'FALSE';
1309
		if (strpos($format[$key],'_callback')) {
1310
			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1311
		} elseif ($h != '' || $name[$key] != '') {
1312
			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1313
		}
1314
		if ($format[$key] == 'airwhere') $forcepilots = true;
1315
	}
1316
	$settings = array_merge($settings,array('globalSources' => $gSources));
1317
1318
/*
1319
	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
1320
	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
1321
*/
1322
	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
1323
	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
1324
	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
1325
1326
	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
1327
	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
1328
1329
	$customcss = filter_input(INPUT_POST,'customcss',FILTER_SANITIZE_STRING);
1330
	$settings = array_merge($settings,array('globalCustomCSS' => $customcss));
1331
1332
	$map3dtile = filter_input(INPUT_POST,'map3dtileset',FILTER_SANITIZE_STRING);
1333
	$settings = array_merge($settings,array('globalMap3DTiles' => $map3dtile));
1334
1335
	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
1336
	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
1337
	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
1338
	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
1339
1340
	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
1341
	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
1342
	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1343
	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1344
		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1345
	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1346
1347
	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1348
	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
1349
	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
1350
	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
1351
	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
1352
	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
1353
	$minfetch = filter_input(INPUT_POST,'minfetch',FILTER_SANITIZE_NUMBER_INT);
1354
	$settings = array_merge($settings,array('globalMinFetch' => $minfetch));
1355
	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
1356
	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
1357
1358
	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
1359
	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
1360
1361
	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
1362
	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
1363
	
1364
	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
1365
	if ($archiveyear == "archiveyear") {
1366
		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
1367
	} else {
1368
		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
1369
	}
1370
	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
1371
	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
1372
	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
1373
	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1374
1375
	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
1376
	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
1377
	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
1378
	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
1379
1380
	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1381
	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1382
	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1383
1384
	// Create in settings.php keys not yet configurable if not already here
1385
	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1386
	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1387
1388
	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1389
	if ($resetyearstats == 'resetyearstats') {
1390
		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1391
	} else {
1392
		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1393
	}
1394
1395
	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1396
	if ($archive == 'archive') {
1397
		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1398
	} else {
1399
		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1400
	}
1401
	$archiveresults = filter_input(INPUT_POST,'archiveresults',FILTER_SANITIZE_STRING);
1402
	if ($archiveresults == 'archiveresults') {
1403
		$settings = array_merge($settings,array('globalArchiveResults' => 'TRUE'));
1404
	} else {
1405
		$settings = array_merge($settings,array('globalArchiveResults' => 'FALSE'));
1406
	}
1407
	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1408
	if ($daemon == 'daemon') {
1409
		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1410
	} else {
1411
		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1412
	}
1413
	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1414
	if ($schedules == 'schedules') {
1415
		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1416
	} else {
1417
		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1418
	}
1419
1420
/*
1421
	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1422
	if ($datasource == 'flightaware') {
1423
		$settings = array_merge($settings,array('globalFlightAware' => 'TRUE','globalSBS1' => 'FALSE'));
1424
	} else {
1425
		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1426
	}
1427
*/
1428
	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1429
	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1430
	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1431
	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1432
	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1433
	$va = false;
1434
	if ($globalivao == 'ivao') {
1435
		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1436
		$va = true;
1437
	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1438
	if ($globalvatsim == 'vatsim') {
1439
		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1440
		$va = true;
1441
	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1442
	if ($globalphpvms == 'phpvms') {
1443
		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1444
		$va = true;
1445
	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1446
	if ($globalvam == 'vam') {
1447
		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1448
		$va = true;
1449
	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1450
	if ($va) {
1451
		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1452
	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1453
	if ($globalva == 'va' || $va) {
1454
		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1455
		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1456
	} else {
1457
		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1458
		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1459
		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1460
	}
1461
	
1462
	
1463
	$mapoffline = filter_input(INPUT_POST,'mapoffline',FILTER_SANITIZE_STRING);
1464
	if ($mapoffline == 'mapoffline') {
1465
		$settings = array_merge($settings,array('globalMapOffline' => 'TRUE'));
1466
	} else {
1467
		$settings = array_merge($settings,array('globalMapOffline' => 'FALSE'));
1468
	}
1469
	$globaloffline = filter_input(INPUT_POST,'globaloffline',FILTER_SANITIZE_STRING);
1470
	if ($globaloffline == 'globaloffline') {
1471
		$settings = array_merge($settings,array('globalOffline' => 'TRUE'));
1472
	} else {
1473
		$settings = array_merge($settings,array('globalOffline' => 'FALSE'));
1474
	}
1475
1476
	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1477
	if ($notam == 'notam') {
1478
		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1479
	} else {
1480
		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1481
	}
1482
	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1483
	if ($owner == 'owner') {
1484
		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1485
	} else {
1486
		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1487
	}
1488
	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1489
	if ($map3d == 'map3d') {
1490
		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1491
	} else {
1492
		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1493
	}
1494
	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1495
	if ($crash == 'crash') {
1496
		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1497
	} else {
1498
		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1499
	}
1500
	$fires = filter_input(INPUT_POST,'fires',FILTER_SANITIZE_STRING);
1501
	if ($fires == 'fires') {
1502
		$settings = array_merge($settings,array('globalMapFires' => 'TRUE'));
1503
	} else {
1504
		$settings = array_merge($settings,array('globalMapFires' => 'FALSE'));
1505
	}
1506
	$firessupport = filter_input(INPUT_POST,'firessupport',FILTER_SANITIZE_STRING);
1507
	if ($firessupport == 'firessupport') {
1508
		$settings = array_merge($settings,array('globalFires' => 'TRUE'));
1509
	} else {
1510
		$settings = array_merge($settings,array('globalFires' => 'FALSE'));
1511
	}
1512
	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1513
	if ($mapsatellites == 'mapsatellites') {
1514
		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1515
	} else {
1516
		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1517
	}
1518
	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1519
	if ($map3ddefault == 'map3ddefault') {
1520
		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1521
	} else {
1522
		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1523
	}
1524
	$map3dliveries = filter_input(INPUT_POST,'map3dliveries',FILTER_SANITIZE_STRING);
1525
	if ($map3dliveries == 'map3dliveries') {
1526
		$settings = array_merge($settings,array('globalMap3DLiveries' => 'TRUE'));
1527
	} else {
1528
		$settings = array_merge($settings,array('globalMap3DLiveries' => 'FALSE'));
1529
	}
1530
	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1531
	if ($translate == 'translate') {
1532
		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1533
	} else {
1534
		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1535
	}
1536
	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1537
	if ($realairlines == 'realairlines') {
1538
		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1539
	} else {
1540
		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1541
	}
1542
	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1543
	if ($estimation == 'estimation') {
1544
		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1545
	} else {
1546
		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1547
	}
1548
	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1549
	if ($metar == 'metar') {
1550
		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1551
	} else {
1552
		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1553
	}
1554
	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1555
	if ($metarcycle == 'metarcycle') {
1556
		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1557
	} else {
1558
		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1559
	}
1560
	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1561
	if ($fork == 'fork') {
1562
		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1563
	} else {
1564
		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1565
	}
1566
1567
	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1568
	if ($colormap == 'colormap') {
1569
		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1570
	} else {
1571
		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1572
	}
1573
	
1574
	if (isset($_POST['aircrafticoncolor'])) {
1575
		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1576
		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1577
	}
1578
1579
	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1580
	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1581
1582
	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1583
	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1584
	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1585
	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1586
	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1587
	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1588
1589
	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1590
	if ($mappopup == 'mappopup') {
1591
		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1592
	} else {
1593
		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1594
	}
1595
	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1596
	if ($airportpopup == 'airportpopup') {
1597
		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1598
	} else {
1599
		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1600
	}
1601
	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1602
	if ($maphistory == 'maphistory') {
1603
		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1604
	} else {
1605
		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1606
	}
1607
	$maptooltip = filter_input(INPUT_POST,'maptooltip',FILTER_SANITIZE_STRING);
1608
	if ($maptooltip == 'maptooltip') {
1609
		$settings = array_merge($settings,array('globalMapTooltip' => 'TRUE'));
1610
	} else {
1611
		$settings = array_merge($settings,array('globalMapTooltip' => 'FALSE'));
1612
	}
1613
	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1614
	if ($flightroute == 'flightroute') {
1615
		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1616
	} else {
1617
		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1618
	}
1619
	$flightremainingroute = filter_input(INPUT_POST,'flightremainingroute',FILTER_SANITIZE_STRING);
1620
	if ($flightremainingroute == 'flightremainingroute') {
1621
		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'TRUE'));
1622
	} else {
1623
		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'FALSE'));
1624
	}
1625
	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1626
	if ($allflights == 'allflights') {
1627
		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1628
	} else {
1629
		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1630
	}
1631
	$bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING);
1632
	if ($bbox == 'bbox') {
1633
		$settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE'));
1634
	} else {
1635
		$settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE'));
1636
	}
1637
	$groundaltitude = filter_input(INPUT_POST,'groundaltitude',FILTER_SANITIZE_STRING);
1638
	if ($groundaltitude == 'groundaltitude') {
1639
		$settings = array_merge($settings,array('globalGroundAltitude' => 'TRUE'));
1640
	} else {
1641
		$settings = array_merge($settings,array('globalGroundAltitude' => 'FALSE'));
1642
	}
1643
	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1644
	if ($waypoints == 'waypoints') {
1645
		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1646
	} else {
1647
		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1648
	}
1649
	$geoid = filter_input(INPUT_POST,'geoid',FILTER_SANITIZE_STRING);
1650
	if ($geoid == 'geoid') {
1651
		$settings = array_merge($settings,array('globalGeoid' => 'TRUE'));
1652
	} else {
1653
		$settings = array_merge($settings,array('globalGeoid' => 'FALSE'));
1654
	}
1655
	$geoid_source = filter_input(INPUT_POST,'geoid_source',FILTER_SANITIZE_STRING);
1656
	$settings = array_merge($settings,array('globalGeoidSource' => $geoid_source));
1657
1658
	$noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING);
1659
	if ($noairlines == 'noairlines') {
1660
		$settings = array_merge($settings,array('globalNoAirlines' => 'TRUE'));
1661
	} else {
1662
		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1663
	}
1664
1665
	$tsk = filter_input(INPUT_POST,'tsk',FILTER_SANITIZE_STRING);
1666
	if ($tsk == 'tsk') {
1667
		$settings = array_merge($settings,array('globalTSK' => 'TRUE'));
1668
	} else {
1669
		$settings = array_merge($settings,array('globalTSK' => 'FALSE'));
1670
	}
1671
	$mapmatching = filter_input(INPUT_POST,'mapmatching',FILTER_SANITIZE_STRING);
1672
	if ($mapmatching == 'mapmatching') {
1673
		$settings = array_merge($settings,array('globalMapMatching' => 'TRUE'));
1674
	} else {
1675
		$settings = array_merge($settings,array('globalMapMatching' => 'FALSE'));
1676
	}
1677
	$mapmatchingsource = filter_input(INPUT_POST,'mapmatchingsource',FILTER_SANITIZE_STRING);
1678
	$settings = array_merge($settings,array('globalMapMatchingSource' => $mapmatchingsource));
1679
	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1680
	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1681
1682
	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1683
1684
	// Set some defaults values...
1685
	if (!isset($globalAircraftImageSources)) {
1686
	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1687
	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1688
	}
1689
1690
	if (!isset($globalSchedulesSources)) {
1691
	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1692
    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1693
    	}
1694
1695
	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1696
1697
	if ($error == '') settings::modify_settings($settings);
1698
	if ($error == '') settings::comment_settings($settings_comment);
1699
	if ($error != '') {
1700
		print '<div class="info column">'.$error.'</div>';
1701
		require('../footer.php');
1702
		exit;
1703
	} else {
1704
		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1705
		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1706
		if (isset($_POST['createdb'])) {
1707
			$_SESSION['install'] = 'database_create';
1708
		} else {
1709
			require_once(dirname(__FILE__).'/../require/class.Connection.php');
1710
			$Connection = new Connection();
1711
			if ($Connection->latest() && isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1712
				if ($Connection->tableExists('airspace') === false) {
1713
					$_SESSION['install'] = 'waypoints';
1714
				} else {
1715
					$_SESSION['install'] = 'database_import';
1716
				}
1717
			} else {
1718
				$_SESSION['install'] = 'database_import';
1719
			}
1720
		}
1721
		//require('../footer.php');
1722
		print '<div class="info column"><ul>';
1723
		 /*
1724
		if (isset($_POST['createdb'])) {
1725
			$_SESSION['done'] = array('Create database','Write configuration');
1726
			print '<li>Create database....<strong>SUCCESS</strong></li>';
1727
		} else $_SESSION['done'] = array('Write configuration');
1728
		*/
1729
		$_SESSION['done'] = array('Write configuration');
1730
		$_SESSION['errorlst'] = array();
1731
		print '<li>Write configuration....<img src="../images/loading.gif" /></li></ul></div>';
1732
		print "<script>console.log('Configuration writed...');setTimeout(window.location = 'index.php?".rand()."&next=".$_SESSION['install']."',10000);</script>";
1733
	}
1734
} else if (isset($_SESSION['install']) && $_SESSION['install'] != 'finish') {
1735
	print '<div class="info column">';
1736
	print '<ul><div id="step">';
1737
	$pop = false;
1738
	$popi = false;
1739
	$popw = false;
1740
	foreach ($_SESSION['done'] as $done) {
1741
	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1742
	    if ($done == 'Create database') $pop = true;
1743
	    if ($_SESSION['install'] == 'database_create') $pop = true;
1744
	    if ($_SESSION['install'] == 'database_import') $popi = true;
1745
	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1746
	}
1747
	if ($pop) {
1748
	    sleep(5);
1749
	    print '<li>Create database....<img src="../images/loading.gif" /></li>';
1750
	} else if ($popi) {
1751
	    sleep(5);
1752
	    print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1753
	} else if ($popw) {
1754
	    sleep(5);
1755
	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1756
	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1757
	print '</div></ul>';
1758
	print '<div id="error"></div>';
1759
/*	foreach ($_SESSION['done'] as $done) {
1760
	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1761
	}
1762
	print '<li>'.$SESSION['next'].'....<img src="../images/loading.gif" /></li>';
1763
1764
	if ($error != '') {
1765
		print '<div class="info column"><span class="error"><strong>Error</strong>'.$error.'</span></div>';
1766
		require('../footer.php');
1767
                exit;
1768
	}
1769
*/
1770
?>
1771
    <script language="JavaScript">
1772
		function installaction() {
1773
		    $.ajax({
1774
			url:'install-action.php',
1775
			dataType: 'json',
1776
			async: true,
1777
			success: function(result) {
1778
			    console.log(result);
1779
			    $('#step').html('');
1780
			    result['done'].forEach(function(done) {
1781
				$('#step').append('<li>'+ done +'....<strong>SUCCESS</strong></li>');
1782
			    });
1783
			    result['errorlst'].forEach(function(done) {
1784
				$('#step').append('<li>'+ done +'....<strong>FAILED</strong></li>');
1785
			    });
1786
			    if (result['error'] != '') {
1787
				setTimeout(function(){
1788
				    console.log('error !');
1789
				    $('#error').html('<p><b>Error : </b> ' + result['error'] + '</p>');
1790
				}, 1000);
1791
				loop = false;
1792
			    } else if (result['next'] != 'finish') {
1793
				$('#step').append('<li>'+ result['next'] +'....<img src="../images/loading.gif" /></li>');
1794
				installaction();
1795
			    } else if (result['install'] == 'finish') {
1796
				console.log('finish !!!');
1797
				$('#step').append('<li>Reloading page to check all is now ok....<img src="../images/loading.gif" /></li>');
1798
				$(location).attr('href','index.php?next=finish');
1799
				loop = false;
1800
			    }
1801
			},
1802
			error: function(XMLHttpRequest, textStatus, errorThrown) { 
1803
				console.log('error !');
1804
				console.log(XMLHttpRequest);
1805
				$('#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>');
1806
			}
1807
		    });
1808
		}
1809
1810
1811
	$(document).ready(function() {
1812
		installaction();
1813
	});
1814
    </script>
1815
<?php
1816
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'finish') {
1817
	unset($_SESSION['install']);
1818
	unset($_COOKIE['install']);
1819
	print '<div class="info column"><ul>';
1820
	foreach ($_SESSION['done'] as $done) {
1821
	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1822
	}
1823
	print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>';
1824
	print '</ul></div>';
1825
	print '<br /><p>All is now installed ! Thanks</p>';
1826
	if ($globalSBS1) {
1827
		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>';
1828
	} else {
1829
		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>';
1830
	}
1831
	if ($globalACARS) {
1832
		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>';
1833
	}
1834
	if ($globalFlightAware && ($globalFlightAwareUsername == '' || $globalFlightAwarePassword == '')) {
1835
		print '<p>You <strong>must</strong> have a FlightAware API account to use FlightAware source</p>';
1836
	}
1837
	if (isset($globalVATSIM) && $globalVATSIM) {
1838
		print '<p>Airline table is populated with VATSIM data</p>';
1839
	}
1840
	if (isset($globalIVAO) && $globalIVAO) {
1841
		print '<p>You need to run install/populate_ivao.php if you want to have IVAO airlines</p>';
1842
	}
1843
	if (isset($globalMap3D) && $globalMap3D) {
1844
		print '<p>You need to run <b>scripts/update_db.php</b> first time manually, this will update all and download 3D models.</p>';
1845
	}
1846
	if (isset($globalVAM) && $globalVAM) {
1847
		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>';
1848
	}
1849
	if (isset($globalGeoid) && $globalGeoid) {
1850
		print '<p>You need to run <b>scripts/update_db.php</b> to update Geoid file if needed (or first time).</p>';
1851
	}
1852
	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>';
1853
	print '<p>If <b>scripts/daemon-spotter.php</b> is already running, you have to restart it.</p>';
1854
	print '</div>';
1855
} else {
1856
	unset($_SESSION['install']);
1857
//	header("Location: index.php");
1858
}
1859
require('../footer.php');
1860
?>