<?php
/*
	DevSaver Web Framework
	Copyright (c) 2002-2018 DevSaver. 
	All rights reserved.
		web:  www.devsaver.com
		mail: support@devsaver.com
*/

if (!defined("STPBase")) {
	die("This file can't be accessed directly!");
}



$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";

*/
?>