Refactor API and database interactions: enhance token management, improve entry handling, and add application name retrieval

This commit is contained in:
marc-go committed 2026-10-06 19:23:15 +02:00
1 parent 9316818753
commit 1a2ee0c176
10 files changed
+79 -19

No files matched your search

+7 -7
View File
@@ -69,25 +69,25 @@ $stmt->execute([":username" => $username, ":password" => $hash, ":owner" => 1]);
$command = "INSERT INTO settings (name, value) VALUES (:name, :value)";
$settings = [
":application_name" => "",
":allow_html" => "false",
":approve_entrys" => "true",
":allow_new_entrys" => "true"
"application_name" => "Guestbook",
"allow_html" => "false",
"approve_entrys" => "true",
"allow_new_entrys" => "true"
];
foreach ($settings as $key => $value) {
$stmt = $db->prepare($command);
$stmt->execute([$key => $value]);
$stmt->execute([":name" => $key, ":value" => $value]);
}
// WRITE .env AND GENERATE SECRETS
$env = "";
$cookie_token = bin2hex(random_bytes(32));
$env .= "COOKIE_TOKEN_SIGNATURE=" . $cookie_token;
$env .= "COOKIE_TOKEN_SIGNATURE=" . $cookie_token . "\n";
$api_token = bin2hex(random_bytes(32));
$env .= "API_TOKEN_SIGNATURE=" . $api_token;
$env .= "API_TOKEN_SIGNATURE=" . $api_token . "\n";
$env .= "DB_FILE=database.db";