On Wed, 08 Jun 2005 17:57:29 +0200, Roy Schestowitz
On Wed, 08 Jun 2005 17:18:12 +0200, Roy Schestowitz
Martin Magnusson 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
not overly elegant, either...
I'd go for a database (can ba plain-textfile based one) with
That's still quite laborious. How about changing that cron job to a
simple chmod command.
Hmm.... can't help, still think my way is cleaner, easier to automate and
therefore less prone to errors - not to mention /less/ laborious in the
long run. No manual messing with cron.tab. Just to show you such a script
is not too complicated, here's an example in python (not tested, very
probably has some errors):
"returns the hash from which to create the link of form
hash = ''.join([random.choice(string.ascii_uppercase) for i in
f = open('hash.db','a')
"when the script is called with an actual hash, call this func to check
if it's a valid one"
db = dict([line.split() for line in open('hash.db')])
assert time.time()-db[hash] < 3600*24*7
except KeyError, AssertionError:
sys.out.write('content-type: text/plain\n\nInvalid or expired hash.')
Now for a real, running script of course you'd want to fancy it up a bit,
but the above few lines generally cover all of idea.