feat: Add user edit modal and user management pages

- Implemented user edit modal in user_edit.html for editing user details.
- Updated sidebar.html to correctly reflect active states for Users and Settings.
- Created table-07.html for displaying user data in a structured format.
- Added settings.html for managing email content and configurations.
- Developed users.html for listing all users with functionality to add and edit users.
This commit is contained in:
marc-go
2026-04-27 19:00:06 +02:00
parent 8d0245c769
commit 58b5af9e7e
38 changed files with 4024 additions and 2075 deletions

54
api/users/add.php Normal file
View File

@@ -0,0 +1,54 @@
<?php
require "../api.php";
ini_set("display_errors", 1);
ini_set("display_startup_errors", 1);
error_reporting(E_ALL);
$api = new spamhasiApi();
$conf = $api->getConf();
if (!$api->checkAuth()) {
header("Location: /users.html?status=500&error=Unauthorized");
exit;
}
if (!isset($_POST["name"]) || !isset($_POST["passwd1"]) || !isset($_POST["passwd2"])) {
header("Location: /users.html?status=500&error=Missing fields");
exit;
}
$name = htmlspecialchars($_POST["name"]);
$passwd1 = hash("sha256", $_POST["passwd1"]);
$passwd2 = hash("sha256", $_POST["passwd2"]);
if (!preg_match('/^[a-z]+$/', $name)) {
header("Location: /users.html?status=500&error=Der Benutzername enthält ungültige Zeichen.");
exit;
}
if ($passwd1 !== $passwd2) {
header("Location: /users.html?status=500&error=Die Passwörter stimmen nicht überein.");
exit;
}
$db = $api->getDB();
$sql = "INSERT INTO users (username, passwd) VALUES (:name, :passwd)";
$stmt = $db->prepare($sql);
$sql_exec = $stmt->execute([':name' => $name, ':passwd' => $passwd2]);
if (!$sql_exec) {
header("Location: /users.html?status=500&error=SQL Error");
}
if (!file_put_contents($conf["PATH"] . "/tmp/user_sessions/" . $name . ".json", '{}')) {
header("Location: /users.html?status=500&error=Error to write session file.");
exit;
}
header("Location: /users.html?status=200");
exit;
?>