What is a simple "download ticket" manager program for a webserver?
September 11, 2007 1:32 PM   Subscribe

Is there a download manager (php preferably) that can generate "download tickets" for a file?

Ideally, I'd like this to happen: the php create a list of "tickets" - a generated set of characters - to distribute, and then be set a number of times a file can be downloaded with each "ticket."

Does such a piece of code exist? I have scoured the ends of the php script wastelands and found none.
posted by beelerspace to Computers & Internet (4 answers total)
 
It's a simple two column database table. Column 1 is the ticket, and Column 2 is the number of downloads so far.

SELECT ticket, downloads FROM tickets WHERE ticket = "requested ticket"

deny if you want (ie, too many downloads)
and then after you send the data file down to the client:

UPDATE tickets SET downloads = downloads + 1 WHERE ticket = "requested ticket"

I don't know enough PHP to tell you how to do that, but using mysql it would be trivial to implement that database.
posted by cschneid at 2:38 PM on September 11, 2007


As cschneid says, that should be fairly simple.

For the download part of it, you basically need to keep the files out of the webroot (so they can't be accessed directly, bypassing your script) and when a ticket is accepted, stream the file content to the browser with your PHP script.

There's some fairly good examples of PHP download managment in the comments on the PHP fread() manual page.

The issues you will encounter there are memory and execution time limits - Depending on how you read the file, you can exhaust PHP's allowed memory allocation. And streaming large files through PHP will result in long execution times which can time out.

This method wouldn't support resumable downloads.

I guess it will depend on what you're distributing.
posted by sycophant at 3:41 PM on September 11, 2007


As in cschneid's, you could add another column with "file_path" to map the ticket string with the actual file it applies to.
posted by rhizome at 3:48 PM on September 11, 2007


Response by poster: It'd be a 100mb zip file.

These are good starts...I'll...get started. =)
posted by beelerspace at 5:40 PM on September 11, 2007


« Older In the blink of an eye.   |   When do you know you're doomed? Newer »
This thread is closed to new comments.