17 lines
632 B
PHP
17 lines
632 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
require_once __DIR__ . '/../db/config.php';
|
|
|
|
try {
|
|
$db = db();
|
|
$stmt = $db->query("SELECT * FROM announcements_history ORDER BY created_at DESC LIMIT 10");
|
|
$announcements = $stmt->fetchAll();
|
|
|
|
$stmt = $db->query("SELECT COUNT(*) FROM announcements_history WHERE created_at > DATE_SUB(NOW(), INTERVAL 24 HOUR)");
|
|
$count_24h = $stmt->fetchColumn();
|
|
|
|
echo json_encode(['success' => true, 'announcements' => $announcements, 'count_24h' => $count_24h]);
|
|
} catch (PDOException $e) {
|
|
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
|
|
}
|