Sindbad~EG File Manager
<?php
require_once '../config/config.php';
header('Content-Type: application/json');
if (!isLoggedIn()) {
echo json_encode(['success' => false, 'message' => 'Unauthorized']);
exit();
}
$notification = new Notification();
$userId = $_SESSION['user_id'];
$action = $_GET['action'] ?? '';
switch ($action) {
case 'count':
$count = $notification->getUnreadCount($userId);
echo json_encode(['success' => true, 'count' => $count]);
break;
case 'list':
$unreadOnly = isset($_GET['unread']) && $_GET['unread'] === 'true';
$notifications = $notification->getUserNotifications($userId, $unreadOnly);
// Add time ago to each notification
foreach ($notifications as &$notif) {
$notif['time_ago'] = timeAgo($notif['created_at']);
}
echo json_encode(['success' => true, 'notifications' => $notifications]);
break;
case 'mark_read':
$notificationId = $_POST['notification_id'] ?? 0;
$result = $notification->markAsRead($notificationId, $userId);
echo json_encode(['success' => $result]);
break;
case 'mark_all_read':
$result = $notification->markAllAsRead($userId);
echo json_encode(['success' => $result]);
break;
case 'delete':
$notificationId = $_POST['notification_id'] ?? 0;
$result = $notification->delete($notificationId, $userId);
echo json_encode(['success' => $result]);
break;
default:
echo json_encode(['success' => false, 'message' => 'Invalid action']);
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists