|
|
@ -151,35 +151,19 @@
|
|
|
|
function make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS,
|
|
|
|
function make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS,
|
|
|
|
$DB_PORT, $SELF_URL_PATH) {
|
|
|
|
$DB_PORT, $SELF_URL_PATH) {
|
|
|
|
|
|
|
|
|
|
|
|
$data = explode("\n", file_get_contents("../config.php-dist"));
|
|
|
|
$rv = file_get_contents("../config.php-dist");
|
|
|
|
|
|
|
|
|
|
|
|
$rv = "";
|
|
|
|
$settings = [
|
|
|
|
|
|
|
|
"%DB_TYPE" => $DB_TYPE == 'pgsql' ? 'pgsql' : 'mysql',
|
|
|
|
$finished = false;
|
|
|
|
"%DB_HOST" => addslashes($DB_HOST),
|
|
|
|
|
|
|
|
"%DB_USER" => addslashes($DB_USER),
|
|
|
|
foreach ($data as $line) {
|
|
|
|
"%DB_NAME" => addslashes($DB_NAME),
|
|
|
|
if (preg_match("/define\('DB_TYPE'/", $line)) {
|
|
|
|
"%DB_PASS" => addslashes($DB_PASS),
|
|
|
|
$rv .= "\tdefine('DB_TYPE', '$DB_TYPE');\n";
|
|
|
|
"%DB_PORT" => intval($DB_PORT),
|
|
|
|
} else if (preg_match("/define\('DB_HOST'/", $line)) {
|
|
|
|
"%SELF_URL_PATH" => addslashes($SELF_URL_PATH)
|
|
|
|
$rv .= "\tdefine('DB_HOST', '$DB_HOST');\n";
|
|
|
|
];
|
|
|
|
} else if (preg_match("/define\('DB_USER'/", $line)) {
|
|
|
|
|
|
|
|
$rv .= "\tdefine('DB_USER', '$DB_USER');\n";
|
|
|
|
$rv = str_replace(array_keys($settings), array_values($settings), $rv);
|
|
|
|
} else if (preg_match("/define\('DB_NAME'/", $line)) {
|
|
|
|
|
|
|
|
$rv .= "\tdefine('DB_NAME', '$DB_NAME');\n";
|
|
|
|
|
|
|
|
} else if (preg_match("/define\('DB_PASS'/", $line)) {
|
|
|
|
|
|
|
|
$rv .= "\tdefine('DB_PASS', '$DB_PASS');\n";
|
|
|
|
|
|
|
|
} else if (preg_match("/define\('DB_PORT'/", $line)) {
|
|
|
|
|
|
|
|
$rv .= "\tdefine('DB_PORT', '$DB_PORT');\n";
|
|
|
|
|
|
|
|
} else if (preg_match("/define\('SELF_URL_PATH'/", $line)) {
|
|
|
|
|
|
|
|
$rv .= "\tdefine('SELF_URL_PATH', '$SELF_URL_PATH');\n";
|
|
|
|
|
|
|
|
} else if (!$finished) {
|
|
|
|
|
|
|
|
$rv .= "$line\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (preg_match("/\?\>/", $line)) {
|
|
|
|
|
|
|
|
$finished = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $rv;
|
|
|
|
return $rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|