<?php

/*
	Stempora web framework
	copyright (c) 2002-2016 Stempora
		web:  www.stempora.com
		mail: support@stempora.com
		
*/


$file_name = "../upload/conf/database.php";
$conf_file = "<?php

\$_CONF['database'] = array(
	'type'		=> 'mysql',		
	'server'	=> '{$_SESSION[CMSinstall][mysql][server]}',		
	'login'		=> '{$_SESSION[CMSinstall][mysql][user]}',		
	'password'	=> '{$_SESSION[CMSinstall][mysql][pass]}',		
	'default'	=> '{$_SESSION[CMSinstall][mysql][database]}',	
);

";


if (function_exists("openssl_pkey_new")) {

	$config = array(
		"digest_alg" => "sha512",
		"private_key_bits" => 4096,
		"private_key_type" => OPENSSL_KEYTYPE_RSA,
	);

	$res = openssl_pkey_new($config);

	openssl_pkey_export($res, $privKey);

	 $pubKey = openssl_pkey_get_details($res);
	 $pubKey = $pubKey["key"];

	$conf_file .= "\$_CONF['crypt'] = array(
	'priv'		=> '{$privKey}',
	'pub'		=> '{$pubKey}'
);

";
}

$conf_file .= " ?>";

//save the file
CFile::SaveContents($file_name , $conf_file);
//@chmod($file_name , 0777);

$output[] = "Saved upload/conf/database.php";

/*
CFile::SaveContents("../upload/conf/.htaccess"  ,"Deny from  all");

$output[] = "Generated upload/conf/.htaccess";

*/
?>