Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
117 lines (85 sloc) 2.63 KB
// Simple MySQL database creation tool
// Handy for creating that initial empty Wordpress database without mucking around in PHPMyAdmin
// database server configuration
include ("config.php");
// common functions
include ("common/functions.php");
// strict error reporting while debugging
ini_set('display_errors', 'On');
// connect to db server
$connection = @mysql_connect ($config["host"]["name"], $config["host"]["user"], $config["host"]["password"]) or die ('Couldn\'t connect: ' . mysql_error());
// get the database list
$dbs = listDBs($connection);
$result = "";
// you really don't want to run this without user confirmation first
if (isset($_POST["create"]) && isset($_POST["filename"])) {
// create a new database
if (createDB($connection, $_POST["filename"]) == "") {
$result = "Created database.";
} else {
$result = "Couldn't connect, or database already exists.";
// disconnect from db server
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Wordpress DB Creation</title>
<meta name="robots" content="all">
<link rel="stylesheet" href="common/css/default.css" media="screen">
<script src="common/script/custom-forms.js"></script>
<div class="dialog">
<h1>Wordpress DB Creation</h1>
if (!$result) {
<p>This script will create a new MySQL database on the server. Configure host settings in <code>config.php</code> first.</p>
if (count($dbs)) {
<p>Existing databases that you may not want to overwrite:</p>
foreach ($dbs as $key => $name) {
echo "<li>$name</li>\n";
<form method="post" action="./create.php" enctype="multipart/form-data">
<input type="hidden" name="create" value="true">
<label>New database name:</label>
<input type="text" name="filename" value="<?php echo $config["db"]["name"]; ?>">
<div class="buttons">
<button type="submit" name="restore">Make it so</button>
} else if (strlen($result) > 1) {
<p>Something went wrong:</p>
<p><?php echo $result; ?></p>
} else {
<p class="warning"><strong>Warning:</strong> this script is dangerous to leave unprotected on a server, as it allows access to your database server to anyone who knows where to look. Protecting this script with <a href="">HTTP Authentication</a> should be considered mandatory, but even higher security is recommended if possible.</p>