"; echo "$sqlServer
"; echo "$sqlUsername
"; echo "$sqlPassword
"; $conn = mysqli_connect($sqlServer, $sqlUsername, $sqlPassword); echo "Sql connection attempt
"; if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } echo "Sql connection successful!
"; // Create the database, if it doesn't exist $dbSetup = "CREATE DATABASE IF NOT EXISTS $dbname"; echo "Preparing database with command - " . $dbSetup . "
"; if (mysqli_query($conn, $dbSetup)) { echo "Database successfully prepared!
"; } else { echo "Database Error " . $sql . "
" . mysqli_error($conn); } echo "Reconnecting to new database...
"; $conn = mysqli_connect($sqlServer, $sqlUsername, $sqlPassword, $dbname); if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } echo "Sql connection successful!
"; // Create the table for storing image data, if doesn't exit $tableSetup = "CREATE TABLE IF NOT EXISTS $tablename ( imgID CHAR(12), fileType VARCHAR(4), mimeType VARCHAR(20), isPrivate BOOLEAN, uploadDate DATETIME DEFAULT CURRENT_TIMESTAMP, editDate DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP )"; echo "Preparing images database table with command - " . $tableSetup . "
"; if (mysqli_query($conn, $tableSetup)) { echo "Images table successfully prepared!
"; } else { echo "Database Error " . $sql . "
" . mysqli_error($conn); } // Create the table to store server settings $settingsSetup = "CREATE TABLE IF NOT EXISTS $settingstable ( serverName VARCHAR(100), serverHostName VARCHAR(100), stylesheet VARCHAR(100), uploadDir VARCHAR(100), privateEnable BOOLEAN, loggingEnable BOOLEAN, genesisDate DATETIME DEFAULT CURRENT_TIMESTAMP, editDate DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP )"; echo "Preparing settings database table with command - " . $settingstable . "
"; if (mysqli_query($conn, $settingsSetup)) { echo "Settings table successfully prepared!
"; } else { echo "Database Error " . $sql . "
" . mysqli_error($conn); } echo "Writing settings to database...
"; // Grab details entered by user if (isset($_POST["serverName"])) { //Server name $serverName = $_POST["serverName"]; } if (isset($_POST["serverHostName"])) { //Hostname $serverHostName = $_POST["serverHostName"]; } if (isset($_POST["stylesheet"])) { //Custom CSS $stylesheet = $_POST["stylesheet"]; } if (isset($_POST["uploadDir"])) { //Directory $targetDir = $_POST["uploadDir"]; } // Set defaults for any fields left blank if ($serverName == ''){ $serverName = "ImgHost"; } if ($serverHostName == ''){ $serverHostName = "imghost.local"; } if ($stylesheet == ''){ $stylesheet = "style.css"; } if ($targetDir == ''){ $targetDir = "uploads"; } // Check if private flag is active if (isset($_POST["enablePrivate"])) { $enablePrivate = 1; } // TODO setup logging IP addresses $enableLogging = 0; $settingsApply = "INSERT INTO $settingstable ( serverName, serverHostName, stylesheet, uploadDir, privateEnable, loggingEnable ) VALUES ( '$serverName', '$serverHostName', '$stylesheet', '$targetDir', '$enablePrivate', '$enableLogging' )"; echo "Preparing to write settings with command - " . $settingsApply . "
"; if (mysqli_query($conn, $settingsApply)) { echo "Settings table successfully written!
"; } else { echo "Database Error " . $sql . "
" . mysqli_error($conn); } // Prepare uploads directory echo "Preparing directories...
"; $directory = "../" . $targetDir; echo $directory. "
"; mkdir ($directory); echo "Initial setup complete! Enjoy!
" ?> Homepage