$db_password = $db['pwd']; $db_host = $db['dbhost']; $db_port = $db['dbport']; $configFileContents = ''; $show_db_config = false; if (!is_writable(OP_DB_CONF_FILE) || !is_writable(RP_DB_CONF_FILE)) { if (!is_writable(OP_DB_CONF_FILE)) { $unwriteable_file = OP_DB_CONF_FILE; } else { $unwriteable_file = RP_DB_CONF_FILE; } $status_text = sprintf('Unable to write database configuration to file %s. Make sure the web server process has write permission for that directory.', $unwriteable_file); $link = sprintf("<a href='config.php'>Retry</a>"); } else { $configFileContents = ''; $status1 = configureDB(DB_CONF_TEMPLATE, OP_DB_CONF_FILE, $db_host, $db_port, $db_name, $db_user, $db_password, $configFileContents); if ($status === false) { $status_text = sprintf('Unable to write database configuration to file %s. Make sure the web server process has write permission for that directory.', OP_DB_CONF_FILE); } else { if ($configFileContents) { file_put_contents(RP_DB_CONF_FILE, $configFileContents); $configFileContents = null; } require_once 'libdb.php'; require_once 'migration.php'; $dsn = sprintf('%s://%s:%s@%s:%s/%s', 'mysql', $db_user, $db_password, $db_host, $db_port, $db_name); try { $db_connection = Doctrine_Manager::connection(); if (!$db_connection->connect()) { $show_db_config = true; } else {
if ($argc >= 2) { list($executable, $command) = $argv; $executable = array_shift($argv); $command = array_shift($argv); switch ($command) { case 'checkdbconnection': checkDbConnection(); break; case 'configAb': list($op_sig_kid, $op_enc_kid, $rp_sig_kid, $rp_enc_kid) = $argv; configureAb(AB_CONF_TEMPLATE, OP_AB_CONF_FILE, $op_sig_kid, $op_enc_kid, $rp_sig_kid, $rp_enc_kid); copy(OP_AB_CONF_FILE, RP_AB_CONF_FILE); break; case 'configDb': list($db_host, $db_port, $db_name, $db_user, $db_password) = $argv; configureDB(DB_CONF_TEMPLATE, OP_DB_CONF_FILE, $db_host, $db_port, $db_name, $db_user, $db_password); copy(OP_DB_CONF_FILE, RP_DB_CONF_FILE); if (file_exists(OP_DB_CONF_FILE)) { require_once 'migration.php'; migrate_db(); } break; case 'migrateDb': if (file_exists(OP_DB_CONF_FILE)) { require_once 'migration.php'; migrate_db(); } break; default: } }