Reply to Re: can have a time expired link?

Your name:

Reply:


Posted by Roy Schestowitz on 06/08/05 18:57

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация