Improved the output of the automatic config file

This commit is contained in:
Alejandro Gallardo Escobar 2015-05-07 18:36:25 +02:00
parent 0dd42fd1e0
commit f93e861369

View File

@ -62,8 +62,8 @@
<body> <body>
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '6.0dev'; $version = '6.0dev';
$build = '150504'; $build = '150504';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);
@ -722,6 +722,18 @@ function install_step3() {
function install_step4() { function install_step4() {
$pandora_config = "include/config.php"; $pandora_config = "include/config.php";
if (!defined('PHP_EOL')) {
switch (strtoupper(substr(PHP_OS, 0, 3))) {
// Windows
case 'WIN':
define('PHP_EOL', "\r\n");
break;
// Unix
default:
define('PHP_EOL', "\n");
}
}
if ( (! isset($_POST["user"])) || (! isset($_POST["dbname"])) || (! isset($_POST["host"])) || if ( (! isset($_POST["user"])) || (! isset($_POST["dbname"])) || (! isset($_POST["host"])) ||
(! isset($_POST["pass"])) || (!isset($_POST['engine'])) || (! isset($_POST["db_action"])) ) { (! isset($_POST["pass"])) || (!isset($_POST['engine'])) || (! isset($_POST["db_action"])) ) {
$dbpassword = ""; $dbpassword = "";
@ -818,32 +830,32 @@ function install_step4() {
$cfgout = fopen ($pandora_config,"w"); $cfgout = fopen ($pandora_config,"w");
$config_contents = fread ($cfgin, filesize("include/config.inc.php")); $config_contents = fread ($cfgin, filesize("include/config.inc.php"));
$dbtype = 'mysql'; $dbtype = 'mysql';
$config_new = '<?php $config_new = '<?php' . PHP_EOL
// Begin of automatic config file . '// Begin of automatic config file' . PHP_EOL
$config["dbtype"] = "' . $dbtype . '"; //DB type (mysql, postgresql...in future others) . '$config["dbtype"] = "' . $dbtype . '"; //DB type (mysql, oracle, postgresql)' . PHP_EOL
$config["dbname"]="'.$dbname.'"; // MySQL DataBase name . '$config["dbname"]="' . $dbname . '"; // DataBase name' . PHP_EOL
$config["dbuser"]="pandora"; // DB User . '$config["dbuser"]="pandora"; // DB User' . PHP_EOL
$config["dbpass"]="'.$random_password.'"; // DB Password . '$config["dbpass"]="' . $random_password . '"; // DB Password' . PHP_EOL
$config["dbhost"]="'.$dbhost.'"; // DB Host . '$config["dbhost"]="' . $dbhost . '"; // DB Host' . PHP_EOL
$config["homedir"]="'.$path.'"; // Config homedir . '$config["homedir"]="' . $path . '"; // Config homedir' . PHP_EOL
/* . '/*' . PHP_EOL
----------Attention-------------------- . '----------Attention--------------------' . PHP_EOL
Please note that in certain installations: . 'Please note that in certain installations:' . PHP_EOL
- reverse proxy. . ' - reverse proxy.' . PHP_EOL
- web server in other ports. . ' - web server in other ports.' . PHP_EOL
- https . ' - https' . PHP_EOL
. PHP_EOL
This variable might be dynamically altered. . 'This variable might be dynamically altered.' . PHP_EOL
. PHP_EOL
But it is save as backup in the . 'But it is save as backup in the' . PHP_EOL
$config["homeurl_static"] . '$config["homeurl_static"]' . PHP_EOL
for expecial needs. . 'for expecial cases.' . PHP_EOL
----------Attention-------------------- . '----------Attention--------------------' . PHP_EOL
*/ . '*/' . PHP_EOL
$config["homeurl"]="'.$url.'"; // Base URL . '$config["homeurl"]="'.$url.'"; // Base URL' . PHP_EOL
$config["homeurl_static"]="'.$url.'"; // Don\'t delete . '$config["homeurl_static"]="'.$url.'"; // Don\'t delete' . PHP_EOL
// End of automatic config file . '// End of automatic config file' . PHP_EOL
?>'; . '?>' . PHP_EOL . PHP_EOL;
$step7 = fputs ($cfgout, $config_new); $step7 = fputs ($cfgout, $config_new);
$step7 = $step7 + fputs ($cfgout, $config_contents); $step7 = $step7 + fputs ($cfgout, $config_contents);
if ($step7 > 0) if ($step7 > 0)
@ -882,8 +894,7 @@ function install_step4() {
check_generic ($step2, "Populating database"); check_generic ($step2, "Populating database");
if (PHP_OS == "FreeBSD") if (PHP_OS == "FreeBSD") {
{
$step_freebsd = adjust_paths_for_freebsd ($engine, $connection); $step_freebsd = adjust_paths_for_freebsd ($engine, $connection);
check_generic ($step_freebsd, "Adjusting paths in database for FreeBSD"); check_generic ($step_freebsd, "Adjusting paths in database for FreeBSD");
} }
@ -901,32 +912,32 @@ function install_step4() {
$cfgout = fopen ($pandora_config,"w"); $cfgout = fopen ($pandora_config,"w");
$config_contents = fread ($cfgin, filesize("include/config.inc.php")); $config_contents = fread ($cfgin, filesize("include/config.inc.php"));
$dbtype = 'oracle'; $dbtype = 'oracle';
$config_new = '<?php $config_new = '<?php' . PHP_EOL
// Begin of automatic config file . '// Begin of automatic config file' . PHP_EOL
$config["dbtype"] = "' . $dbtype . '"; //DB type (mysql, postgresql, oracle) . '$config["dbtype"] = "' . $dbtype . '"; //DB type (mysql, oracle, postgresql)' . PHP_EOL
$config["dbname"]="' . $dbname . '"; // Oracle DataBase name . '$config["dbname"]="' . $dbname . '"; // DataBase name' . PHP_EOL
$config["dbuser"]="' . $dbuser . '"; // DB User . '$config["dbuser"]="' . $dbuser . '"; // DB User' . PHP_EOL
$config["dbpass"]="' . $dbpassword . '"; // DB Password . '$config["dbpass"]="' . $dbpassword . '"; // DB Password' . PHP_EOL
$config["dbhost"]="' . $dbhost . '"; // DB Host . '$config["dbhost"]="' . $dbhost . '"; // DB Host' . PHP_EOL
$config["homedir"]="' . $path . '"; // Config homedir . '$config["homedir"]="' . $path . '"; // Config homedir' . PHP_EOL
/* . '/*' . PHP_EOL
----------Attention-------------------- . '----------Attention--------------------' . PHP_EOL
Please note that in certain installations: . 'Please note that in certain installations:' . PHP_EOL
- reverse proxy. . ' - reverse proxy.' . PHP_EOL
- web server in other ports. . ' - web server in other ports.' . PHP_EOL
- https . ' - https' . PHP_EOL
. PHP_EOL
This variable might be dynamically altered. . 'This variable might be dynamically altered.' . PHP_EOL
. PHP_EOL
But it is save as backup in the . 'But it is save as backup in the' . PHP_EOL
$config["homeurl_static"] . '$config["homeurl_static"]' . PHP_EOL
for expecial cases. . 'for expecial cases.' . PHP_EOL
----------Attention-------------------- . '----------Attention--------------------' . PHP_EOL
*/ . '*/' . PHP_EOL
$config["homeurl"]="' . $url . '"; // Base URL . '$config["homeurl"]="'.$url.'"; // Base URL' . PHP_EOL
$config["homeurl_static"]="'.$url.'"; // Don\'t delete . '$config["homeurl_static"]="'.$url.'"; // Don\'t delete' . PHP_EOL
// End of automatic config file . '// End of automatic config file' . PHP_EOL
?>'; . '?>' . PHP_EOL . PHP_EOL;
$step4 = fputs ($cfgout, $config_new); $step4 = fputs ($cfgout, $config_new);
$step4 = $step4 + fputs ($cfgout, $config_contents); $step4 = $step4 + fputs ($cfgout, $config_contents);
if ($step4 > 0) if ($step4 > 0)
@ -1000,8 +1011,7 @@ function install_step4() {
check_generic ($step4, "Populating database"); check_generic ($step4, "Populating database");
if (PHP_OS == "FreeBSD") if (PHP_OS == "FreeBSD") {
{
$step_freebsd = adjust_paths_for_freebsd ($engine, $connection); $step_freebsd = adjust_paths_for_freebsd ($engine, $connection);
check_generic ($step_freebsd, "Adjusting paths in database for FreeBSD"); check_generic ($step_freebsd, "Adjusting paths in database for FreeBSD");
} }
@ -1101,32 +1111,32 @@ function install_step4() {
$cfgout = fopen ($pandora_config,"w"); $cfgout = fopen ($pandora_config,"w");
$config_contents = fread ($cfgin, filesize("include/config.inc.php")); $config_contents = fread ($cfgin, filesize("include/config.inc.php"));
$dbtype = 'postgresql'; $dbtype = 'postgresql';
$config_new = '<?php $config_new = '<?php' . PHP_EOL
// Begin of automatic config file . '// Begin of automatic config file' . PHP_EOL
$config["dbtype"] = "' . $dbtype . '"; //DB type (mysql, postgresql...in future others) . '$config["dbtype"] = "'.$dbtype.'"; //DB type (mysql, oracle, postgresql...)' . PHP_EOL
$config["dbname"]="'.$dbname.'"; // MySQL DataBase name . '$config["dbname"]="'.$dbname.'"; // DataBase name' . PHP_EOL
$config["dbuser"]="pandora"; // DB User . '$config["dbuser"]="pandora"; // DB User' . PHP_EOL
$config["dbpass"]="'.$random_password.'"; // DB Password . '$config["dbpass"]="'.$random_password.'"; // DB Password' . PHP_EOL
$config["dbhost"]="'.$dbhost.'"; // DB Host . '$config["dbhost"]="'.$dbhost.'"; // DB Host' . PHP_EOL
$config["homedir"]="'.$path.'"; // Config homedir . '$config["homedir"]="'.$path.'"; // Config homedir' . PHP_EOL
/* . '/*' . PHP_EOL
----------Attention-------------------- . '----------Attention--------------------' . PHP_EOL
Please note that in certain installations: . 'Please note that in certain installations:' . PHP_EOL
- reverse proxy. . ' - reverse proxy.' . PHP_EOL
- web server in other ports. . ' - web server in other ports.' . PHP_EOL
- https . ' - https' . PHP_EOL
. PHP_EOL
This variable might be dynamically altered. . 'This variable might be dynamically altered.' . PHP_EOL
. PHP_EOL
But it is save as backup in the . 'But it is save as backup in the' . PHP_EOL
$config["homeurl_static"] . '$config["homeurl_static"]' . PHP_EOL
for expecial cases. . 'for expecial cases.' . PHP_EOL
----------Attention-------------------- . '----------Attention--------------------' . PHP_EOL
*/ . '*/' . PHP_EOL
$config["homeurl"]="'.$url.'"; // Base URL . '$config["homeurl"]="'.$url.'"; // Base URL' . PHP_EOL
$config["homeurl_static"]="'.$url.'"; // Don\'t delete . '$config["homeurl_static"]="'.$url.'"; // Don\'t delete' . PHP_EOL
// End of automatic config file . '// End of automatic config file' . PHP_EOL
?>'; . '?>' . PHP_EOL . PHP_EOL;
$step7 = fputs ($cfgout, $config_new); $step7 = fputs ($cfgout, $config_new);
$step7 = $step7 + fputs ($cfgout, $config_contents); $step7 = $step7 + fputs ($cfgout, $config_contents);
if ($step7 > 0) if ($step7 > 0)