<?php

if(core::ifPost("from")){
    sftp::downloadFormRemote(core::getPost("file"));

    historique::recRef("/proweb-export-csv.html");
    historique::add(array(
        "idType" => historique::getIdRef("ACTION"),
        "idUser" => session::getId(),
        "idPage" => historique::getIdRef("/proweb-export-csv.html"),
        "log" => "Téléchargement du fichier ". core::getPost("file") . " sur " . SFTP_HOST
    ));
    
    header('Content-type: application/octet-stream;');
    header('Content-Transfer-Encoding: base64');
    header('Content-Disposition: attachment; filename="'.core::getPost("file").'"');
    readfile(DIR_TEMP.core::getPost("file"));
    unlink(DIR_TEMP.core::getPost("file"));
}
