上传文件至 /

This commit is contained in:
2025-11-30 13:06:06 +00:00
parent f2106c2fbf
commit c56dca6129
5 changed files with 692 additions and 0 deletions

20
generate-api-key.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
require_once 'config.php';
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
$api_key = bin2hex(random_bytes(API_KEY_LENGTH / 2));
$stmt = $pdo->prepare("UPDATE users SET api_key = ? WHERE id = ?");
if ($stmt->execute([$api_key, $_SESSION['user_id']])) {
$_SESSION['success'] = t('api_key_generated');
} else {
$_SESSION['error'] = t('api_key_generation_failed');
}
header('Location: ' . ($_SERVER['HTTP_REFERER'] ?? 'dashboard.php'));
exit;
?>