Home Messages Index
[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index

Re: can have a time expired link?

  • Subject: Re: can have a time expired link?
  • From: Roy Schestowitz <newsgroups@schestowitz.com>
  • Date: Wed, 08 Jun 2005 16:57:29 +0100
  • Newsgroups: alt.html
  • References: <R6Dpe.16869$iy2.6561@newsfe1-gui.ntli.net> <1118243532.a8f23e21662617f4818d6eb87cf9375d@teranews> <d8727n$ekh$1@godfrey.mcc.ac.uk> <op.sr14670edob4us@ibis>
  • User-agent: KNode/0.7.2
Mitja wrote:

> On Wed, 08 Jun 2005 17:18:12 +0200, Roy Schestowitz
> <newsgroups@schestowitz.com> wrote:
> 
>> Martin Magnusson wrote:
>>
>>> diablo wrote:
>>>> I want to offer a download to people for a certain amount of time -
>>>> after the link expires.
>>>
>>> I don't believe that's possible using only HTML. You would have to
>>> remove the file manually or have a server-side script to automate it.
>>
>> Set up a cron job for the day of expiry, say:
>> 20 22 24 * * cp ~/index2.html ~/index.html; rm ~/index2.html
> 
> Which is still a server side script, although admittedly not one that
> interacts with the server. And using cron for this kind of job is at best
> not overly elegant, either...
> 
> I'd go for a database (can ba plain-textfile based one) with valid/active
> "passwords". Each time a user pays for the book, your script generates a
> new password (usu called a hash, since it's just a long mess of randomly
> mixed characters and numbers) and adds it to the database along with a
> timestamp. The password is given to the user. If he wants to download the
> book, he must pass this code to a script which checks whether the code
> exists in the database at all and whether it's expired already or not. If
> all's fine, it sends the book, else an error message.
> 
> This way you can also track misuses (e.g. one password used 50 times) or
> warn users if you see they haven't yet donwloaded the book but their code
> is about to expire, etc etc.

That's still quite laborious. How about changing that cron job to a simple
chmod command. You don't need to hold duplicate files, _but_ it assumes
that the link points to something on the same server. You can make it very
flexible, for example:

0 9 * * * chmod 644 ~/index.html
0 17 * * * chmod 600 ~/index.html

will ensure the link (destination) is alive (accessible) only between 9 and
5.

Roy

-- 
Roy S. Schestowitz
http://Schestowitz.com

[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index