Tamam, bu yüzden bugüne kadar aşağıdaki şartları var
- Let onun / oturumunda kullanıcı indir tek
- hiçbir kopya & başkası için linki yapıştırın
- Kullanıcılar, siteye, örneğin indirmek zorunda Hiçbir hotlinking
- Hız kontrolü
Bakalım. Bu not working code, ama bu satırlar boyunca çalışması gerekir:
<?php // download.php
session_start(); // start or resume a session
// always sanitize user input
$fileId = filter_input(INPUT_GET, 'fileId', FILTER_SANITIZE_NUMBER_INT);
$token = filter_input(INPUT_GET, 'token', FILTER_UNSAFE_RAW);
$referer = filter_input(INPUT_SERVER, 'HTTP_REFERER', FILTER_SANITIZE_URL);
$script = filter_input(INPUT_SERVER, 'SCRIPT_NAME', FILTER_SANITIZE_URL);
// mush session_id and fileId into an access token
$secret = 'i can haz salt?';
$expectedToken = md5($secret . session_id() . $fileId);
// check if request came from download.php and has the valid access token
if(($expectedToken === $token) && ($referer === $script)) {
$file = realpath('path/to/files/' . $fileId . '.zip');
if(is_readable($file)) {
session_destroy(); // optional
header(/* stuff */);
fpassthru($file);
exit;
}
}
// if no file was sent, send the page with the download link.
?>
<html ...
<?php printf('a href="/download.php?fileId=%s&token=%s',
$fileId, $expectedToken); ?>
...
</html>
Ve işte bu. Veritabanı gerekmez. Bu gereksinimleri 1-3 kapsamalıdır. PHP ile hız kontrol edemez, ancak oturumu yok dont bir dosya göndererek sonra oturuma bir sayaç yazmak ve kullanıcı oturumu sırasında gönderilecek dosya sayısını sınırlayabilir.
Ben bütün kalbiyle bu çok daha zarif bu monkeyform ile kesmek daha çözülebilir olduğunu kabul ediyorum, ama kanıt-of-concept gibi, bu yeterli olmalı.