Reply to Re: A follow-up to my download-all-files-as-a-zip-file post

Your name:

Reply:


Posted by Toby A Inkster on 08/05/07 08:23

Matt Madrid wrote:

> I'd probably just create a cron job that deletes any zip files older than
> a day. That's the simplest way I can think of. Of course, depending on the
> amount of disk space you have available, and how trustworthy your users are,
> this could open you up to a DOS attack of sorts. A person could keep clicking
> on the download link (or automate it) and possibly fill up your whole disk in
> a day.

A solution which would solve both the "when to delete" question, and the
possibility of DOS attacks would be to simply *keep* all the ZIP files as a
*cache*. This should actually *reduce* the load on the server.

Sketch of how it would work, assuming $X is the place where you keep these
ZIP files you've made...

1. User requests a ZIPped directory. Call this directory $D.

2. You scan through each file in $D to find the "last modified"
date of the *newest* file in $D.

3. Call the timestamp of that last modification $T.

4. Does there exist a file "$X/$D.zip"? If not, go to step 9.

5. Is the last-modified date of "$X/$D.zip" older than $T?
If so, go to step 8.

6. Serve up "$X/$D.zip".

7. Exit.

8. Delete "$X/$D.zip".

9. Zip up directory $D and call it "$X/$D.zip".

10. Use the UNIX "touch" command to change the last-modified
and created dates of "$X/$D.zip" to $T.

11. Go to step 6.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 45 days, 11:47.]

Command Line Interfaces, Again
http://tobyinkster.co.uk/blog/2007/08/02/command-line-again/

[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

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