Forum Moderators: phranque

Message Too Old, No Replies

allowing only ONE file download

         

esllou

10:19 am on Apr 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



how can I set things up so that a certain .zip file can only be downloaded once?

Or, easier possibly, password protect a directory containing the self same .zip file, so that access is only given once.

Is there a script out there that would allow this sort of thing? Something simple, perl maybe or php, but nothing I have to set up database for.

Thanks in advance...

trillianjedi

10:24 am on Apr 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How about setting a cookie?

TJ

esllou

11:29 am on Apr 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



tj, yeah that seems the easiest solution but I have never used cookies in anything other than self contained scripts such as forums and so forth. In other words, I didn't have to do anything!

how would I start to set cookies and use them in a single directory with a single zip file in?

tomda

11:59 am on Apr 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If not a cookie, than a variable in user session (knowing that it will only be able to download ONCE PER SESSION)...

Then if you user is a member, you can just increment the data in the user database. If it is a guest, it is a bit more complicated indeed (although you can create a database which store user agent and IP of your guest)...

esllou

1:14 pm on Apr 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



doesn't there exist a password script that "expires" after one use?

I'm not so worried about a user downloading the file more than once, but of e-mailing his/her friends and them downloading it multiple times between them.

so a one life password would be the simplest way to go.

or am I being simplistic?

killroy

2:06 pm on Apr 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you could create a random name, like 12342323424343.zip and mod_rewrite this to a php script which then pulls and returns the zip. after use, plonk the id into a database so it can never be used again.

SN

trillianjedi

3:21 pm on Apr 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That was my first thought also Killroy, but the OP is trying to do it without a DB.

I'm no php expert by any stretch, but I think the cookie thing is as simple as:-


if ($_COOKIE['downloadedzip'] == '')
{
setcookie('downloadedzip', 1);
//Allow the download
}
else
{
//Don't allow the download
}

But you might be better off in the php forum to get a better response on the actual code, and perhaps some ideas of securing it further.

TJ