Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/attendance/admin/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/attendance/admin/get_location_details.php

<?php
require_once '../config/config.php';

// Check if user is logged in and is superuser
if (!isLoggedIn() || !hasRole('superuser')) {
    http_response_code(403);
    echo json_encode(['success' => false, 'message' => 'Access denied']);
    exit;
}

$db = new Database();
$conn = $db->getConnection();

$location_id = isset($_GET['id']) ? (int)$_GET['id'] : 0;

if (!$location_id) {
    echo json_encode(['success' => false, 'message' => 'Invalid location ID']);
    exit;
}

try {
    // Get location details
    $query = "SELECT * FROM locations WHERE id = ?";
    $stmt = $conn->prepare($query);
    $stmt->execute([$location_id]);
    $location = $stmt->fetch();

    if (!$location) {
        echo json_encode(['success' => false, 'message' => 'Location not found']);
        exit;
    }

    echo json_encode([
        'success' => true,
        'location' => $location
    ]);

} catch (Exception $e) {
    echo json_encode(['success' => false, 'message' => 'Database error']);
}
?>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists