I'm looking for help/suggestions as well as just trying to get this out of my head and see how bad my logic is for this problem.

Basics:
I have a set of .html and flash files in a directory. I want to sell access to these files for a nominal amount for 24 hours. The purchaser will receive an email and purchase confirmation page that will have a URL to access the files for the limited amount of time. I already have a perl script in place to deal with the purchasing.

Problem:
I need to figure out how to generate the random URL string and then expire it after a certain amount of time. This is not a random filename problem, this is a random directory name problem. I also need to figure out where to store the random directory name value so I can access it within the purchasing script (which handles more than just these URL's for sale).

Initial Thoughts:
I will have all the files in a directory and with a cron, I'll run a script to mv the directory to a new directory name every so often. This where the logic gets weird. Because if a person buys the item at 11:59pm on 11/14 and the cron runs at 12:01am on 11/15, then they'll immediately lose access, which doesn't work. There is the thought that we tell the user its only available for 24 hours, but its really available for 48 hours, but then I guess I'd need to have 2 set of files and keep track of which one is still valid to be "sold". And here is where my head starts to explode.

Environment
As a note, I'm doing this on an aging system running v.5.004_04 and while I have most basic modules, adding new ones aren't really an option. If someone suggestions one, I'll gladly look to see if it is installed. The last two times I've tried to have new modules installed it took 3 months and the "unix admins" horked up my 5.6 install (which is why I'm back to the older version). The deadline for this is less than 3 months. I also have no real database to access beyond text files. Thankfully, I am getting a new tasty server running linux and a current version of perl soon. But it still isn't here, so I must continue to toil in an environment from 1998 for now.

Please ask me many questions and point out obvious things that I am not thinking about. I just need other views on this problem.


In reply to Random directory creation/deletion scheduling logic problem by hmbscully

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.