<?php
	$username=$_POST['username'];
	$pwd=$_POST['passwd'];
	$db=$_POST['db'];
	$host=$_POST['host'];
	$serverip=$_SERVER['SERVER_ADDR'];
	$path=dirname(dirname($_SERVER['PHP_SELF']));
	$hint=($_POST['hints'] == true?'true':'false');
	$con = mysql_connect($host,$username,$pwd);
	@mysql_select_db($db,$con) or die( "Unable to connect to the database: $db");
	if ($con)
	{  
		if(isset($_POST['submit'])) {
			header('Content-Disposition: attachment; filename="LocalSettings.php"');
			$var = 
"<?php
# This file was automatically generated by the Bricks installer. 
# If you make manual changes, please keep track in case you need to recreate them later.

\$dbuser = '$username'; //MySQL database username
\$dbpass = '$pwd'; //MySQL database password
\$dbname = '$db';  //MySQL database name
\$host = '$host';  //MySQL database host
\$showhint = $hint;  //Shows the last executed SQL query
\$server = 'http://$serverip';  //The protocol and server name to use in fully-qualified URLs
\$scriptpath = '$path';
?>";
			print $var;
		}
	} else {
	die('Could not connect: ' . mysql_error());
			}
?>