<td><?php echo debug_result(is_readable($prefix . '/sql/ampache.sql')); ?> </td> <td><?php echo T_('This tests whether the file needed to initialise the database structure is available.'); ?> </td> </tr> <tr> <td><?php echo T_('ampache.cfg.php is writable'); ?> </td> <td><?php echo debug_result(check_config_writable()); ?> </td> <td><?php echo T_('This tests whether PHP can write to config/. This is not strictly necessary, but will help streamline the installation process.'); ?> </td> </tr> </table> <form role="form" method="post" action="<?php echo $web_path . "/install.php?action=init"; ?> " enctype="multipart/form-data" > <input type="hidden" name="htmllang" value="<?php echo $htmllang; ?>
} ?> <div class="col-sm-4"> </div><div class="col-sm-8"> </div> <div class="col-sm-4"> <?php echo T_('config/ampache.cfg.php action'); ?> </div> <div class="col-sm-8"> <button type="submit" class="btn btn-warning" name="download"><?php echo T_('Download'); ?> </button> <button type="submit" class="btn btn-warning" name="write" <?php if (!check_config_writable()) { echo "disabled "; } ?> > <?php echo T_('Write'); ?> </button> </div> <div class="col-sm-4 control-label"><?php echo T_('config/ampache.cfg.php exists?'); ?> </div> <div class="col-sm-8"><?php echo debug_result(is_readable($configfile));
/** * install_create_config * * Attempts to write out the config file or offer it as a download. */ function install_create_config($download = false) { $config_file = AmpConfig::get('prefix') . '/config/ampache.cfg.php'; /* Attempt to make DB connection */ Dba::dbh(); $params = AmpConfig::get_all(); if (empty($params['database_username']) || empty($params['database_password']) && strpos($params['database_hostname'], '/') !== 0) { Error::add('general', T_("Invalid configuration settings")); return false; } // Connect to the DB if (!Dba::check_database()) { Error::add('general', T_("Database Connection Failed Check Hostname, Username and Password")); return false; } $final = generate_config($params); // Make sure the directory is writable OR the empty config file is if (!$download) { if (!check_config_writable()) { Error::add('general', T_('Config file is not writable')); return false; } else { // Given that $final is > 0, we can ignore lazy comparison problems if (!file_put_contents($config_file, $final)) { Error::add('general', T_('Error writing config file')); return false; } } } else { $browser = new Horde_Browser(); $browser->downloadHeaders('ampache.cfg.php', 'text/plain', false, strlen($final)); echo $final; exit; } return true; }