Added new languages, updated translations, changed sql installation

Separated language in db dump, makes it easier for me to update
Added commit alongside the version in the generated config file
2.0
Wruczek 6 years ago
parent 65ae062a96
commit 895e36c8ec

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -44,24 +44,39 @@ if (!empty($_POST)) {
if (isset($dbconfig)) { if (isset($dbconfig)) {
try { try {
$db = new Medoo($dbconfig); $db = new Medoo($dbconfig);
$sqlfile = $usingMysql ? "dbinstall_mysql" : "dbinstall_sqlite";
$sqlquery = file_get_contents(__DIR__ . "/../$sqlfile.sql");
if($sqlquery === false) { $sqlfiles = [];
$errormessage = "Cannot read $sqlfile.sql file!";
if ($usingMysql) {
$sqlfiles = [
"dbinstall_mysql",
"dbinstall_mysql_lang"
];
} else { } else {
// no other option yet
}
foreach ($sqlfiles as $file) {
$sqlquery = file_get_contents(__DIR__ . "/../$file.sql");
if($sqlquery === false) {
throw new Exception("Cannot read SQL file: $file.sql");
}
$sqlquery = str_replace("DBPREFIX", $dbprefix, $sqlquery); $sqlquery = str_replace("DBPREFIX", $dbprefix, $sqlquery);
$sqlresult = $db->pdo->exec($sqlquery); $sqlresult = $db->pdo->exec($sqlquery);
if($sqlresult === false) { if ($sqlresult === false) {
throw new Exception("EXEC returned false"); throw new Exception("EXEC returned false");
} }
}
$phpcode = <<<EOT // if all queries succeeded, create a config file and save connection info there
$phpcode = <<<EOT
<?php <?php
/* /*
* TS-website database config file * TS-website database config file
* Generated at %s with TS-website %s * Generated at %s with TS-website %s (%s)
*/ */
return [ return [
@ -69,24 +84,24 @@ return [
]; ];
EOT; EOT;
$confarray = ""; $confarray = "";
// Add all variables to the config // Add all variables to the config
foreach ($dbconfig as $key => $value) { foreach ($dbconfig as $key => $value) {
$confarray .= sprintf(' "%s" => "%s",' . PHP_EOL, addcslashes($key, '"'), addcslashes($value, '"')); $confarray .= sprintf(' "%s" => "%s",' . PHP_EOL, addcslashes($key, '"'), addcslashes($value, '"'));
} }
// Remove semicolon and new line from the end // Remove semicolon and new line from the end
$confarray = rtrim($confarray, "," . PHP_EOL); $confarray = rtrim($confarray, "," . PHP_EOL);
// Replace all variables with sprintf // Replace all variables with sprintf
$phpcode = sprintf($phpcode, date("d-m-Y H:i:s"), __TSWEBSITE_VERSION, $confarray); $phpcode = sprintf($phpcode, date("d-m-Y H:i:s"), __TSWEBSITE_VERSION, __TSWEBSITE_COMMIT, $confarray);
if(file_put_contents(__CONFIG_FILE, $phpcode) === false) { if(file_put_contents(__CONFIG_FILE, $phpcode) === false) {
$errormessage = "Cannot write to <code>" . __CONFIG_FILE . "</code>! Please check the file/directory permissions"; $errormessage = "Cannot write to <code>" . __CONFIG_FILE . "</code>! Please check the file/directory permissions";
} else { } else {
header("Location: ?step=" . ($stepNumber + 1)); // redirect to next step on success
} header("Location: ?step=" . ($stepNumber + 1));
} }
} catch (Exception $e) { } catch (Exception $e) {
$errormessage = htmlspecialchars("Error " . $e->getCode() . ": " . $e->getMessage()); $errormessage = htmlspecialchars("Error " . $e->getCode() . ": " . $e->getMessage());

Loading…
Cancel
Save