diff options
author | Paul 'flowerysong' Arthur <flowerysong00@yahoo.com> | 2010-10-12 20:40:25 +0000 |
---|---|---|
committer | Paul 'flowerysong' Arthur <flowerysong00@yahoo.com> | 2010-10-12 20:40:25 +0000 |
commit | 680e9f6206de1e17cdc63ebec498f6ebafa667b6 (patch) | |
tree | ed24d2f4f054dbf749b0df87cf9ade1ca0025f02 /lib/install.php | |
parent | 6e7d0869697cc79c291a84871c1cf73324d984ef (diff) | |
download | ampache-680e9f6206de1e17cdc63ebec498f6ebafa667b6.tar.gz ampache-680e9f6206de1e17cdc63ebec498f6ebafa667b6.tar.bz2 ampache-680e9f6206de1e17cdc63ebec498f6ebafa667b6.zip |
Add fallback to the old method of downloading the config file if the config
file cannot be written to.
Diffstat (limited to 'lib/install.php')
-rw-r--r-- | lib/install.php | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/install.php b/lib/install.php index 5ba4d0d3..77e0d268 100644 --- a/lib/install.php +++ b/lib/install.php @@ -236,13 +236,6 @@ function install_create_config($web_path,$username,$password,$hostname,$database $config_file = Config::get('prefix') . '/config/ampache.cfg.php'; - // Make sure the directory is writeable OR the empty config file is - if (!is_writeable(Config::get('prefix') . '/config/') AND !is_writeable($config_file)) { - /* HINT: Config File */ - Error::add('general',sprintf(_('%s is not writeable'),$config_file)); - return false; - } - $data['database_username'] = $username; $data['database_password'] = $password; $data['database_hostname'] = $hostname; @@ -270,15 +263,24 @@ function install_create_config($web_path,$username,$password,$hostname,$database $final = generate_config($data); - // Open the file and try to write it - $fhandle = fopen($config_file,'w'); - if (!fwrite($fhandle,$final)) { - Error::add('general',"Error Writing config file"); + // Make sure the directory is writable OR the empty config file is + if (!is_writeable(Config::get('prefix') . '/config/') && !is_writeable($config_file)) { + // Fall back to the old method + $browser = new Browser(); + $browser->downloadHeaders('ampache.cfg.php', 'text/plain', false, filesize('config/ampache.cfg.php.dist')); + echo $final; + exit(); + } + else { + // Open the file and try to write it + $fhandle = fopen($config_file,'w'); + if (!fwrite($fhandle,$final)) { + Error::add('general',"Error Writing config file"); + fclose ($fhandle); + return false; + } fclose ($fhandle); - return false; } - fclose ($fhandle); - return true; |