<?php
require_once '../includes/auth.php';
requireRole('super_admin');

header('Content-Type: application/json');

$logDir = '../logs';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (is_dir($logDir)) {
        $files = scandir($logDir);
        foreach ($files as $file) {
            if ($file !== '.' && $file !== '..') {
                unlink($logDir . '/' . $file);
            }
        }
    }
    echo json_encode(['success' => true, 'message' => 'Logs cleared']);
} else {
    echo json_encode(['success' => false, 'message' => 'Method not allowed']);
}
?>