Semi-stable version with old variable names
This commit is contained in:
@@ -16,7 +16,7 @@ verify_csrf();
|
||||
require $baseDir . '/../scripts/db/db-functions.php';
|
||||
require $baseDir . '/../scripts/db/db-tables.php';
|
||||
|
||||
|
||||
date_default_timezone_set('Europe/Zurich');
|
||||
|
||||
$type = 'wkl';
|
||||
|
||||
@@ -45,10 +45,12 @@ if ($id <= 0) {
|
||||
// Delete old OTL links for this user (recommended)
|
||||
db_delete($mysqli, $tableOTL, ['user_id' => $id]);
|
||||
|
||||
// Insert the row — url + timestamp are auto-generated by MySQL
|
||||
$timestamp_one_day = strtotime('+1 days');
|
||||
|
||||
$stmt = $mysqli->prepare("INSERT INTO {$tableOTL} (user_id, `type`) VALUES (?, ?)");
|
||||
$stmt->bind_param("is", $id, $typeOp);
|
||||
$link_expires_at = date("Y-m-d H:i:s", $timestamp_one_day);
|
||||
|
||||
$stmt = $mysqli->prepare("INSERT INTO $tableOTL (user_id, `type`, `expires_at`) VALUES (?, ?, ?)");
|
||||
$stmt->bind_param("iss", $id, $typeOp, $link_expires_at);
|
||||
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
@@ -60,7 +62,6 @@ $row_id = $stmt->insert_id;
|
||||
|
||||
$stmt->close();
|
||||
|
||||
// Now fetch the auto-generated URL
|
||||
$url = db_get_var($mysqli, "SELECT url FROM $tableOTL WHERE id = ? LIMIT 1", [$row_id]);
|
||||
|
||||
if (!$url) {
|
||||
@@ -68,4 +69,4 @@ if (!$url) {
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['success' => true, 'url' => $url]);
|
||||
echo json_encode(['success' => true, 'url' => $url, 'expiresAt' => $link_expires_at]);
|
||||
|
||||
Reference in New Issue
Block a user