HEX
Server: Apache/2.4.37 (CentOS Stream) OpenSSL/1.1.1k
System: Linux ysnet.com.tw 4.18.0-553.5.1.el8.x86_64 #1 SMP Tue May 21 05:46:01 UTC 2024 x86_64
User: test (521)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //var/www/net/download.php
<?php

$base = "/ftp";

if (!isset($_GET['id'])) {
    exit("Missing identity");
}

$id = preg_replace('/[^a-zA-Z0-9_-]/', '', $_GET['id']);

$file = "$base/$id.backup";

if (!file_exists($file)) {

    echo "
    <script>
        alert('找不到 {$id} 備份檔,請洽網管部。');
        history.back();
    </script>
    ";

    exit;
}
// 取得檔案最後修改時間(FTP upload time = mtime)
$mtime = filemtime($file);
$date = date("Y-m-d", $mtime);

// 新檔名(只含日期)
$downloadName = $id . "_" . $date . ".backup";

// header下載
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"$downloadName\"");
header("Content-Length: " . filesize($file));

readfile($file);
exit;