How do I set up boot authentication?

I am looking for some boot authentication. I'm going to provide the user with a link to the file and I want to make sure that only that person gets it only once. Is there an easy solution without setting up the database?

Better yet, if it's possible to have an encrypted web link that will only allow you to download a file from my FTP server once, then the link becomes invalid.

+2


a source to share


1 answer


You can use a simple PHP script. This script is an input element to be saved to a GET file on a browser. After excluding it, you can rename this file to a random string. this only first download this file. Your link turns out something like this. www.domain.tld / dir / script.php? file =. / usr / 123.tar.gz. You can also encrypt the filename in base64, in this option your link is: www.domain.tld / dir / script.php? File = Li91c3IvMTIzLnRhci5neg ==

Script without base64:

<?php
$file = $_GET['file'];

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    rename($file, "secret_new_filename");
    exit;
}
else
{
    echo 'File don\'t exist';
}
?>

      



And with base64:

<?php
$file = base64_decode($_GET['file']);

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    rename($file, "secret_new_filename");
    exit;
}
else
{
    echo 'File don\'t exist';
}
?>

      

+2


a source







All Articles