Issues (843)

Security Analysis    not enabled

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

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

install/install-action.php (1 issue)

Upgrade to new PHP Analysis Engine

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

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

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

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

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
3
//header('Content-Encoding: none;');
4
require_once(dirname(__FILE__).'/class.create_db.php');
5
require_once(dirname(__FILE__).'/class.update_schema.php');
6
require_once(dirname(__FILE__).'/class.settings.php');
7
require(dirname(__FILE__).'/../require/settings.php');
8
set_time_limit(0);
9
ini_set('max_execution_time', 6000);
10
/*
11
if ($globalInstalled && !isset($_SESSION['install'])) {
12
	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>';
13
	require('../footer.php');
14
	exit;
15
}
16
 */
17
/*
18
$writable = false;
19
if (!is_writable('../require/settings.php')) {
20
	print '<div class="info column"><p><strong>The file <i>require/settings</i> must be writable.</strong></p></div>';
21
	require('../footer.php');
22
	exit;
23
}
24
if (!set_time_limit(0)) {
25
	print '<div class="info column"><p><strong>You may need to update the maximum execution time.</strong></p></div>';
26
}
27
28
$error = array();
29
if (!extension_loaded('SimpleXML')) {
30
	$error[] = "SimpleXML is not loaded.";
31
}
32
if (!extension_loaded('dom')) {
33
	$error[] = "Dom is not loaded. Needed for aircraft schedule";
34
}
35
if (!extension_loaded('PDO')) {
36
	$error[] = "PDO is not loaded.";
37
}
38
if (!extension_loaded('pdo_sqlite')) {
39
	$error[] = "PDO SQLite is not loaded. Needed to populate database for SBS.";
40
}
41
if (!extension_loaded('zip')) {
42
	$error[] = "ZIP is not loaded. Needed to populate database for SBS.";
43
}
44
if (!extension_loaded('json')) {
45
	$error[] = "Json is not loaded. Needed for aircraft schedule and bitly.";
46
}
47
if (!extension_loaded('curl')) {
48
	$error[] = "Curl is not loaded.";
49
}
50
51
if (count($error) > 0) {
52
	print '<div class="info column"><ul>';
53
	foreach ($error as $err) {
54
		print '<li>'.$err.'</li>';
55
	}
56
	print '</ul>You <strong>must</strong> add these modules.</div>';
57
	require('../footer.php');
58
        exit;
59
}
60
*/
61
$settings = array();
62
$error = '';
63
64
if (isset($_GET['reset'])) {
65
	echo 'Last session : '.$_SESSION['install']."\n";
66
	print_r($_SESSION['done']);
67
	unset($_SESSION['install']);
68
	echo 'Reset session !!';
69
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'database_create') {
70
	$globalDebug = FALSE;
71
	$dbroot = $_SESSION['database_root'];
72
	$dbrootpass = $_SESSION['database_rootpass'];
73
	$error .= create_db::create_database($dbroot,$dbrootpass,$globalDBuser,$globalDBpass,$globalDBname,$globalDBdriver,$globalDBhost);
74
	sleep(5);
75
	if ($error != '') {
76
		$_SESSION['error'] = $error;
77
		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create database'));
78
	} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database'));
79
	$_SESSION['install'] = 'database_import';
80
	$_SESSION['next'] = 'Create and import tables';
81
	$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
82
	print json_encode($result);
83
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'database_import') {
84
	$globalDebug = FALSE;
85
	$check_version = update_schema::check_version(false);
86
	if ($check_version == '0') {
87
		
88
		if ($globalDBdriver == 'mysql') {
89
		    $error .= create_db::import_all_db('../db/');
90
		} elseif ($globalDBdriver == 'pgsql') {
91
		    $error .= create_db::import_all_db('../db/pgsql/');
92
		}
93
		if ($error != '') {
94
			$_SESSION['error'] = $error;
95
			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables'));
96
		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables'));
97
		if ((!isset($globalAircraft) || $globalAircraft === TRUE) && (!isset($globalVA) || $globalVA === FALSE)) {
98
			$_SESSION['install'] = 'populate';
99
			$_SESSION['next'] = 'Populate aircraft_modes table with externals data for ADS-B';
100
		} else {
101
		    $_SESSION['install'] = 'sources';
102
		    $_SESSION['next'] = 'Insert data in source table';
103
		}
104
		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
105
		print json_encode($result);
106
	} elseif (!is_numeric($check_version)) {
107
		$error .= $check_version;
108
		$_SESSION['error'] = $error;
109
		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables'));
110
		if (!isset($_SESSION['next'])) $_SESSION['next'] = '';
111
		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
112
		print json_encode($result);
113
	} else {
114
		$error .= update_schema::check_version(true);
115
		if ($error != '') {
116
			$_SESSION['error'] = $error;
117
			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Update schema if needed'));
118
		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed'));
119
		$_SESSION['install'] = 'sources';
120
		$_SESSION['next'] = 'Insert data in source table';
121
		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
122
		print json_encode($result);
123
	}
124
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'waypoints') {
125
	include_once('class.update_db.php');
126
	$globalDebug = FALSE;
127
	$error .= update_db::update_waypoints();
128
	if ($error != '') {
129
		$_SESSION['error'] = $error;
130
		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate waypoints database'));
131
	} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database'));
132
/*
133
	$_SESSION['install'] = 'airspace';
134
	$_SESSION['next'] = 'Populate airspace table';
135
	$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
136
	print json_encode($result);
137
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'airspace') {
138
	include_once('class.update_db.php');
139
	$globalDebug = FALSE;
140
	$error .= update_db::update_airspace_fam();
141
	if ($error != '') {
142
		$_SESSION['error'] = $error;
143
		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate airspace database'));
144
	} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate airspace database'));
145
*/
146
	$_SESSION['install'] = 'countries';
147
	$_SESSION['next'] = 'Populate countries table';
148
	$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
149
	print json_encode($result);
150
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'countries') {
151
	include_once('class.update_db.php');
152
	$globalDebug = FALSE;
153
	$error .= update_db::update_countries();
154
	if ($error != '') {
155
		$_SESSION['error'] = $error;
156
		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate countries database'));
157
	} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database'));
158
	if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') {
159
	    $_SESSION['install'] = 'notam';
160
	    $_SESSION['next'] = 'Populate NOTAM table with externals data';
161
	    $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
162
	    print json_encode($result);
163
	/*
164
	} elseif (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) {
165
	    $_SESSION['install'] = 'owner';
166
	    $_SESSION['next'] = 'Populate owner table with externals data';
167
	    unset($_SESSION['owner']);
168
	    $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
169
	    print json_encode($result);
170
	*/
171
	} else {
172
	    $_SESSION['install'] = 'sources';
173
	    $_SESSION['next'] = 'Insert data in source table';
174
	    $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
175
	    print json_encode($result);
176
	}
177
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'populate') {
178
	if (!is_writable('tmp')) {
179
		$error = 'The directory <i>install/tmp</i> must be writable.';
180
		$_SESSION['error'] = $error;
181
		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B'));
182
		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
183
		print json_encode($result);
184
	} else {
185
		include_once('class.update_db.php');
186
		$globalDebug = FALSE;
187
		$error .= update_db::update_ModeS_fam();
188
		if ($error != '') {
189
			$_SESSION['error'] = $error;
190
			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B'));
191
		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B'));
192
		$_SESSION['install'] = 'populate_flarm';
193
		$_SESSION['next'] = 'Populate aircraft_modes table with externals data for FLARM';
194
		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
195
		print json_encode($result);
196
	}
197
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'populate_flarm') {
198
	if (!is_writable('tmp')) {
199
		$error = 'The directory <i>install/tmp</i> must be writable.';
200
		$_SESSION['error'] = $error;
201
		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM'));
202
		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
203
		print json_encode($result);
204
	} else {
205
		include_once('class.update_db.php');
206
		$globalDebug = FALSE;
207
		//$error .= update_db::update_ModeS_flarm();
208
		$error .= update_db::update_ModeS_ogn();
209
		if ($error != '') {
210
			$_SESSION['error'] = $error;
211
			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM'));
212
		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM'));
213
		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
214
			$_SESSION['install'] = 'vatsim';
215
			if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data';
216
			else $_SESSION['next'] = 'Insert VATSIM data';
217
		} elseif (isset($globalVATSIM) && $globalVATSIM) {
218
			$_SESSION['install'] = 'vatsim';
219
			$_SESSION['next'] = 'Insert VATSIM data';
220
		} elseif (isset($globalIVAO) && $globalIVAO) {
221
			$_SESSION['install'] = 'vatsim';
222
			if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data';
223
			else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)';
224
		} elseif (isset($globalphpVMS) && $globalphpVMS) {
225
			$_SESSION['install'] = 'vatsim';
226
			$_SESSION['next'] = 'Insert phpVMS data';
227
		} else {
228
			$_SESSION['install'] = 'routes';
229
			$_SESSION['next'] = 'Populate routes table with externals data';
230
		}
231
		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
232
		print json_encode($result);
233
	}
234
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'routes') {
235
	if (!is_writable('tmp')) {
236
		$error = 'The directory <i>install/tmp</i> must be writable.';
237
		$_SESSION['error'] = $error;
238
		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B'));
239
		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
240
		print json_encode($result);
241
	} else {
242
		include_once('class.update_db.php');
243
		$globalDebug = FALSE;
244
		$error .= update_db::update_routes_fam();
245
		if ($error != '') {
246
			$_SESSION['error'] = $error;
247
			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate routes table with externals data'));
248
		} else 	$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data'));
249
		$_SESSION['install'] = 'translation';
250
		$_SESSION['next'] = 'Populate translation table with externals data';
251
		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
252
		print json_encode($result);
253
	}
254
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'translation') {
255
	if (!is_writable('tmp')) {
256
		$error = 'The directory <i>install/tmp</i> must be writable.';
257
		$_SESSION['error'] = $error;
258
		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data'));
259
		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
260
		print json_encode($result);
261
	} else {
262
		include_once('class.update_db.php');
263
		$globalDebug = FALSE;
264
		$error .= update_db::update_translation_fam();
265
		if ($error != '') {
266
			$_SESSION['error'] = $error;
267
			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data'));
268
		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data'));
269
		if ($_SESSION['waypoints'] == 1) {
270
			$_SESSION['install'] = 'waypoints';
271
			$_SESSION['next'] = 'Populate waypoints table';
272
			unset($_SESSION['waypoints']);
273
		} elseif (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') {
274
			$_SESSION['install'] = 'notam';
275
			$_SESSION['next'] = 'Populate NOTAM table with externals data';
276
		/*
277
		} elseif ($_SESSION['owner'] == 1) {
278
			$_SESSION['install'] = 'owner';
279
			$_SESSION['next'] = 'Populate owner table with externals data';
280
			unset($_SESSION['owner']);
281
		*/
282
		} else {
283
			$_SESSION['install'] = 'sources';
284
			$_SESSION['next'] = 'Insert data in source table';
285
		}
286
		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
287
		print json_encode($result);
288
	}
289
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'owner') {
290
	if (!is_writable('tmp')) {
291
		$error = 'The directory <i>install/tmp</i> must be writable.';
292
		$_SESSION['error'] = $error;
293
		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data'));
294
		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
295
		print json_encode($result);
296
	} else {
297
		include_once('class.update_db.php');
298
		$globalDebug = FALSE;
299
		$error = update_db::update_owner_fam();
300
		if ($error != '') {
301
			$_SESSION['error'] = $error;
302
			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data'));
303
		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data'));
304
		$_SESSION['install'] = 'sources';
305
		$_SESSION['next'] = 'Insert data in source table';
306
		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
307
		print json_encode($result);
308
	}
309
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'notam') {
310
	if (!is_writable('tmp')) {
311
		$error = 'The directory <i>install/tmp</i> must be writable.';
312
		$_SESSION['error'] = $error;
313
		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data'));
314
		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
315
		print json_encode($result);
316
	} else {
317
		include_once('class.update_db.php');
318
		$globalDebug = FALSE;
319
		if (isset($globalNOTAMSource) && $globalNOTAMSource != '') {
320
			$error .= update_db::update_notam();
321
			if ($error != '') {
322
				$_SESSION['error'] = $error;
323
				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data'));
324
			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data'));
325
		} else {
326
			if ($error != '') {
327
				$_SESSION['error'] = $error;
328
				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data (no source defined)'));
329
			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)'));
330
		}
331
		/*
332
		if (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) {
333
			$_SESSION['install'] = 'owner';
334
			$_SESSION['next'] = 'Populate owner table';
335
			unset($_SESSION['owner']);
336
			$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
337
			print json_encode($result);
338
		} else {
339
		*/
340
			$_SESSION['install'] = 'sources';
341
			$_SESSION['next'] = 'Insert data in source table';
342
			$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
343
			print json_encode($result);
344
		//}
345
	}
346
/*
347
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'ivao') {
348
	unset($_SESSION['install']);
349
	if (!is_writable('tmp')) {
350
		print '<p><strong>The directory <i>install/tmp</i> must be writable.</strong></p>';
351
		require('../footer.php');
352
		exit;
353
	}
354
355
	print '<div class="info column"><ul>';
356
	foreach ($_SESSION['done'] as $done) {
357
	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
358
	}
359
	print '<li>Populate airlines table and airlines logos with data from ivao.aero....<img src="../images/loading.gif" /></li></ul></div>';
360
	flush();
361
	@ob_flush();
362
363
	include_once('class.update_db.php');
364
	$globalDebug = FALSE;
365
	update_db::update_ivao();
366
	$_SESSION['done'] = array_merge($_SESSION['done'],array('Populate ivao table with externals data'));
367
368
	$_SESSION['install'] = 'finish';
369
	print "<script>window.location = 'index.php?".rand()."&next=".$_SESSION['install']."';</script>";
370
*/
371
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'sources') {
372
	if (isset($_SESSION['sources']) && count($_SESSION['sources']) > 0) {
373
		$sources = $_SESSION['sources'];
374
		include_once('../require/class.Source.php');
375
		$globalDebug = FALSE;
376
		$Source = new Source();
377
		$Source->deleteAllLocation();
378
		foreach ($sources as $src) {
379
			if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png');
380
		}
381
		$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert data in source table'));
382
		unset($_SESSION['sources']);
383
	}
384
	/*
385
	if (isset($globalIVAO) && $globalIVAO) $_SESSION['install'] = 'ivao';
386
	else $_SESSION['install'] = 'finish';
387
	*/
388
	if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
389
		$_SESSION['install'] = 'vatsim';
390
		if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data';
391
		else $_SESSION['next'] = 'Insert VATSIM data';
392
	} elseif (isset($globalVATSIM) && $globalVATSIM) {
393
		$_SESSION['install'] = 'vatsim';
394
		$_SESSION['next'] = 'Insert VATSIM data';
395
	} elseif (isset($globalIVAO) && $globalIVAO) {
396
		$_SESSION['install'] = 'vatsim';
397
		if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data';
398
		else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)';
399
	} elseif (isset($globalphpVMS) && $globalphpVMS) {
400
		$_SESSION['install'] = 'vatsim';
401
		$_SESSION['next'] = 'Insert phpVMS data';
402
	} else {
403
		$_SESSION['install'] = 'finish';
404
		$_SESSION['next'] = 'finish';
405
	}
406
	$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
407
	print json_encode($result);
408
} else if (isset($_SESSION['install']) && $_SESSION['install'] == 'vatsim') {
409
	include_once('../install/class.create_db.php');
410
	$globalDebug = FALSE;
411
	include_once('class.update_db.php');
412
413
	if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
414
		if (file_exists('tmp/ivae_feb2013.zip')) {
415
			$error .= update_db::update_IVAO();
416
			if ($error != '') {
417
				$_SESSION['error'] = $error;
418
				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data'));
419
			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data'));
420
		} else {
421
			$error .= update_db::update_vatsim();
422
			if ($error != '') {
423
				$_SESSION['error'] = $error;
424
				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data'));
425
			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data'));
426
		}
427
	} elseif (isset($globalVATSIM) && $globalVATSIM) {
428
		$error .= update_db::update_vatsim();
429
		if ($error != '') {
430
			$_SESSION['error'] = $error;
431
			$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data'));
432
		} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data'));
433
	} elseif (isset($globalIVAO) && $globalIVAO) {
434
		if (file_exists('tmp/ivae_feb2013.zip')) {
435
			$error .= update_db::update_IVAO();
436
			if ($error != '') {
437
				$_SESSION['error'] = $error;
438
				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data'));
439
			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data'));
440
		} else {
441
			$error .= update_db::update_vatsim();
442
			if ($error != '') {
443
				$_SESSION['error'] = $error;
444
				$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data (IVAO not found)'));
445
			} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)'));
446
		}
447
	} elseif (isset($globalphpVMS) && $globalphpVMS) {
448
		$_SESSION['done'] = array_merge($_SESSION['done'],array('Insert phpVMS data'));
449
	}
450
	//$_SESSION['install'] = 'routes';
451
	//$_SESSION['next'] = 'Populate routes table with externals data';
452
	$_SESSION['install'] = 'finish';
453
	$_SESSION['next'] = 'finish';
454
	$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
455
	print json_encode($result);
456
} else {
457
	//unset($_SESSION['install']);
458
	$_SESSION['error'] = 'Unknwon task : '.$_SESSION['install'];
459
	$result = array('error' => 'Unknwon task : '.$_SESSION['install'],'done' => $_SESSION['done'],'next' => 'finish','install' => 'finish');
460
	print json_encode($result);
461
}
462
?>