大家好,我讨厌在这里问愚蠢的问题,所以我希望这不是,我将如何限制某人访问我的下载页面?因此,如果他们尝试再次访问该页面(不止一次)以下载某些内容,它只会重定向或最好将下载链接更改为link 2
然后Link 3
,是否可以在没有数据库的情况下进行?
例如:
- 首次访问 - 主链接
- 第二次访问 - 链接 2
- 第三次访问-链接 3
- 4 及以上 访问无链接并重定向
也许用饼干?我真的不知道该怎么做,我已经用谷歌搜索了,但我的措辞不能在那里......
有这个名字或脚本吗?
谢谢你们的时间。
A.
The best method to achieve the desired goal is database
. Create a database table that contains two columns :
(1)Page Visitors IP
(2)The Last Download link used by the visitor to download
file(contents) from your website.
B. You can too achieve your goal with the help of COOKIE.
setcookie("Visitor IP", "Download Link used by the Visitor", $expire);
Everytime, visitors visit your website, fetch the visitor IP and check whether $_COOKIE["Visitor IP"]
is set or not, if its set, then update the existing Cookie else create the new one.
However, using Cookie is not a convenient way, as there might be a case where
Browser does NOT Support Cookies.
Client alter the Cookies value and use the previous link for download.
So, most simplest and elegant way to do it is, using Database
.
UPD: *How easy is it to code/setup a database?*
Setting up/Connecting to a database in php is pretty easy. Refer the following LINK
Coding is pretty easy as well.
-Whenever the visitor click on the download link, fetch Visitors IP ($fetched_IP) by either POST or GET method. Also fetch the Link ($URL) visitor has clicked.
-Query the database
[eg: Select DB_IP,LASTLINK from database WHERE DB_IP=$fetched_IP.....]
-If RowCount>0, then IP($fetched_IP
) exists in database. Check the Last Link visited by the $fetched_IP
.
-If LASTLINK!=$URL
, then allow him download the content from $URL
.Update the LAST_LINK column in database table by $URL
.
-If rowcount==0,(New User
) Insert a row that contains DB_IP=$fetched_IP(Visitor IP) and LAST_LINK=$URL.
一个简单的方法是使用哈希表(关联数组)。当他们满足访问文件的条件时,使用唯一的 url 作为键,文档路径作为值,向哈希表添加一个条目。将其保存到会话中。当他们访问 url 时,页面会检查 url 是否在哈希表中。如果是,请从哈希表中删除 url 并流式传输文件。如果您想允许多次使用,您可以将倒计时变量与 url 一起存储,该变量将随着每次访问而递减,并且仅在计数为零时从哈希表中删除 url。