Closed altazar closed 7 years ago
$file = '../config.php';
$contents = "<?php \n";
$contents .= "//Database details \n";
$contents .= "define ('DB_HOST', '".$_POST['dbHost']."'); \n";
$contents .= "//Username \n";
$contents .= "define ('DB_USERNAME', '".$_POST['dbUserName']."'); \n";
$contents .= "//Pass \n";
$contents .= "define ('DB_PASS', '".$_POST['dbPass']."'); \n";
$contents .= "//Database Name \n";
$contents .= "define ('DB_NAME', '".$_POST['dbName']."'); \n";
$contents .= "//Base URL \n";
$contents .= "define ('BASE_URL', 'http://".$_POST['siteURL']."'); \n";
$contents .= "//Email/Cookie URL \n";
$contents .= "define ('EMAIL_URL', '".$_POST['siteURL']."'); \n";
$contents .= "?>";
$mysql_host = $_POST['dbHost'];
$mysql_username = $_POST['dbUserName'];
$mysql_password = $_POST['dbPass'];
$mysql_database = $_POST['dbName'];
// Name of the file
$filename = 'hoosk.sql';
// Connect to MySQL server $mysql_thing = mysqli_connect($mysql_host, $mysql_username, $mysql_password) or die('Error connecting to MySQL server: ' . mysql_error()); // Select database mysqli_select_db($mysql_thing,$_POST['dbName']) or die('Error selecting MySQL database: ' . mysql_error());
// Temporary variable, used to store current query $templine = ''; // Read in entire file $lines = file($filename); // Loop through each line
foreach ($lines as $line) { // Skip it if it's a comment if (substr($line, 0, 2) == '--' || $line == '') continue;
// Add this line to the current segment
$templine .= $line;
// If it has a semicolon at the end, it's the end of the query
if (substr(trim($line), -1, 1) == '~')
{
$templine = str_replace(";~", ";", $templine);
// Perform the query
mysqli_query($mysql_thing,$templine) or die(print('Error performing query \'' . htmlspecialchars($templine) . '\': ' . mysqli_error() . '
'));
// Reset temp variable to empty
$templine = '';
}
}
file_put_contents($file, $contents);
// Create connection
$conn = new mysqli($mysql_host, $mysql_username, $mysql_password, $mysql_database);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE hoosk_settings SET siteTitle='".$_POST['siteName']."' WHERE siteID=0";
if ($conn->query($sql) === TRUE) {
} else {
echo "Error: " . $sql . "
" . $conn->error;
}
$conn->close();
I modified his first part to work with mysqli.... most likely that will work on your server setup.
I'm trying to instal Hoosk, I get this: Fatal error: Uncaught Error: Call to undefined function mysql_connect()...