<?php
/**
 * Panel Logout
 * Destroys session and redirects to login
 */

session_start();

// Log logout
if (isset($_SESSION['panel_username'])) {
    $logFile = __DIR__ . '/../logs/panel_access.log';
    $logMessage = sprintf(
        "[%s] Logout - User: %s | IP: %s\n",
        date('Y-m-d H:i:s'),
        $_SESSION['panel_username'],
        $_SERVER['REMOTE_ADDR']
    );
    file_put_contents($logFile, $logMessage, FILE_APPEND);
}

// Destroy session
session_unset();
session_destroy();

// Redirect to login
header('Location: login.php');
exit;
?>
