28 lines
747 B
PHP
28 lines
747 B
PHP
<?php
|
|
require __DIR__ . '/../session.php';
|
|
require __DIR__ . '/../db.php';
|
|
start_app_session();
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
$userId = $_SESSION['user_id'] ?? null;
|
|
$result = false;
|
|
|
|
if ($userId !== null) {
|
|
$pdo = getDbConnection();
|
|
$tableExists = $pdo->query("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'transactions'")->fetch();
|
|
|
|
if ($tableExists) {
|
|
$stmt = $pdo->prepare("
|
|
SELECT 1 FROM transactions
|
|
WHERE user_id = :user_id
|
|
AND created_at >= datetime('now', '-40 seconds')
|
|
LIMIT 1
|
|
");
|
|
$stmt->execute(['user_id' => (int) $userId]);
|
|
$result = (bool) $stmt->fetch();
|
|
}
|
|
}
|
|
|
|
echo json_encode(['result' => $result]);
|