如何阻止访客下载文件

时间:2019-03-22 00:18:59

标签: php

我有一个很小的代码,只能让成员每天下载20个文件,

如果超出限制,则会显示页面警告并阻止它们。

现在一切都很好,,但是我想做的是让来宾用户尝试下载任何内容时显示不同的味精,例如“只有成员才能下载”。我该如何实现!

注意:所有未登录名为“ guest”的系统的成员

if (!(isset($_GET['username']) && !empty($_GET['username']))){
   echo 'Only a member of this website can download this file. However, no username was specified in this download. Sorry for inconvenience.';  
   die;
}

$dl_username = $this->decrypt($_GET['username']);

if (gator::getUser($dl_username) == false){
    echo 'Only a member of this website can download this file. However, the username provided does not exist in the database. Sorry for inconvenience.';   
    die;
}

$dl_user = gator::getUser($dl_username);
if ($dl_user['downloads'] > 20){
   echo 'Cannot download more files for today! You have crossed the limit of downloading 20 files.';
   die;
}

0 个答案:

没有答案