Semi-stable version with old variable names

This commit is contained in:
Fabio Herzig
2026-07-16 18:43:30 +02:00
parent 3731183654
commit c8e7ce9174
165 changed files with 25654 additions and 9728 deletions
@@ -4,6 +4,7 @@ use Dotenv\Dotenv;
header('Content-Type: application/json');
date_default_timezone_set('Europe/Zurich');
if (!isset($baseDir)) {
$baseDir = $_SERVER['DOCUMENT_ROOT'];
@@ -32,6 +33,26 @@ if ($dbconnection['success'] !== true){
exit;
}
$link_expires_at = $_POST['linkExpiresAt'] ?? '';
if ($link_expires_at === '' || strtotime($link_expires_at) === false) {
echo json_encode(['success' => false, 'message' => 'Ungültiges Ablaufdatum']);
http_response_code(400);
exit;
}
if (strtotime($link_expires_at) > strtotime('+8 days')) {
echo json_encode(['success' => false, 'message' => 'Datum liegt zu weit in der Zukunft']);
http_response_code(400);
exit;
}
if (strtotime($link_expires_at) < time()) {
echo json_encode(['success' => false, 'message' => 'Datum liegt in der Vergangenheit']);
http_response_code(400);
exit;
}
$editor_id = $_SESSION['user_id_wk_leitung'];
$plain = trim($_POST['password'] ?? null);
@@ -136,15 +157,12 @@ if (!$updated) {
$new_id = $mysqli->insert_id;
// Delete old OTL links for this user (recommended)
db_delete($mysqli, $tableOTL, ['user_id' => $new_id]);
// Insert the row — url + timestamp are auto-generated by MySQL
$typeOp = "create_profile";
$stmt = $mysqli->prepare("INSERT INTO {$tableOTL} (user_id, `type`) VALUES (?, ?)");
$stmt->bind_param("is", $new_id, $typeOp);
$stmt = $mysqli->prepare("INSERT INTO $tableOTL (user_id, `type`, `expires_at`) VALUES (?, ?, ?)");
$stmt->bind_param("iss", $new_id, $typeOp, $link_expires_at);
if (!$stmt->execute()) {
@@ -164,4 +182,4 @@ if (!$url) {
exit;
}
echo json_encode(['success' => true, 'url' => $url]);
echo json_encode(['success' => true, 'url' => $url, 'expiresAt' => $link_expires_at]);