<?php
session_start();

if (isset($_GET['file'])) {
    $file = basename($_GET['file']);
    $filepath = __DIR__ . '/' . $file;
    
    if (file_exists($filepath) && pathinfo($filepath, PATHINFO_EXTENSION) === 'html') {
        header('Content-Description: File Transfer');
        header('Content-Type: text/html');
        header('Content-Disposition: attachment; filename="' . basename($filepath) . '"');
        header('Expires: 0');
        header('Cache-Control: must-revalidate');
        header('Pragma: public');
        header('Content-Length: ' . filesize($filepath));
        readfile($filepath);
        exit;
    } else {
        header('HTTP/1.0 404 Not Found');
        echo 'File tidak ditemukan';
    }
}
?>