Update install.php to prevent creating an empty config.php file

I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md.
This commit is contained in:
Mohammad H. Al-Shami 2015-05-10 16:40:38 +03:00
parent 31baee5e41
commit 6e27d888c3
2 changed files with 6 additions and 7 deletions

View File

@ -23,7 +23,6 @@ Contributors to LibreNMS:
- Stuart Henderson <stu@spacehopper.org> (sthen)
- Filippo Giunchedi <filippo@esaurito.net> (filippog)
- Lasse Leegaard <lasse@brandbil.dk> (lasseleegaard)
- Mohammad Al-Shami <mohammad@al-shami.net> (mohshami)
[1]: http://observium.org/ "Observium web site"

View File

@ -33,7 +33,7 @@ include("../includes/defaults.inc.php");
// Work out the install directory
$cur_dir = explode('/',$_SERVER['DOCUMENT_ROOT']);
$install_dir = array_pop($cur_dir);
$install_dir = array_pop($cur_dir);
#$install_dir = array_pop($cur_dir);
$install_dir = implode('/',$cur_dir);
$config['install_dir'] = $install_dir;
$config['log_dir'] = $install_dir.'/logs';
@ -409,9 +409,9 @@ EOD;
if(!file_exists("../config.php"))
{
$conf = fopen("../config.php", 'w');
if ($conf === false)
if ($conf != false)
{
if(fwrite($handle, '<?php') === FALSE)
if(fwrite($conf, "<?php\n") === FALSE)
{
echo("<div class='alert alert-danger'>We couldn't create the config.php file, please create this manually before continuing by copying the below into a config.php in the root directory of your install (typically /opt/librenms/)</div>");
echo("<pre>&lt;?php\n".stripslashes($config_file)."</pre>");
@ -419,7 +419,7 @@ EOD;
else
{
$config_file = stripslashes($config_file);
fwrite($handle,$config_file);
fwrite($conf,$config_file);
echo("<div class='alert alert-success'>The config file has been created</div>");
}
}