Rob Marscher wrote:
I believe Adrian was showing how ADODB uses a Unix command to clean up
it's files and saying that you could also use a Unix command. I'm not
sure I would call it "3rd party" if you're always using a unix-based
server. Of course, it wouldn't be portable to Windows.
Not only that, anyone using my script would need to make sure that the
cleanup task is present. Not everyone runs their own web server at home,
although with Apachefriend's XAMPP and DynDNS I can't think of any
reason why not...OK, I can, but the point is that many may want to run
this on their web space that the ISP gives them.
At any rate, you can use PHP's filesystem functions to go through your
directories and figure out the last time they were changed via
filemtime(): http://us.php.net/manual/en/function.filemtime.php
All I need to know is the age of the folder with all the files in it.
The manual doesn't explicitly state if filemtime works on directories as
well. I then could get all directories and check for their timestamp
rather than hitting the database a few times for this. And it will save
me from making yet another table. I will try this out.
On a side note, if you use custom session save_handlers like I mentioned
before, then you can know which sessions are active. I use custom
save_handlers to store all of my sessions in a database rather than in
temp files. Then I can just query the database to find active
sessions.
I first planned on writing the session id and a timestamp to a db table
and use that, but what I need to do hasn't anything to do with the
session per sé. So, if filemtime works for dirs as well (and works on
Windope) then I am much closer to something smarter. I then have a
screwdriver and a hammer. ;)
Great, this discussion really helps me a lot. I went from no clue over
complicated and bloated to something that is potentially done in half a
dozen of lines without the need of tables and queries and such.
It's funny, half of my scripts come from NYPHP and the other half is
just commentary. Nah, have to give myself some credit, I figured the zip
stuff out on my own. That is quite an accomplishment for someone who
still thinks that arrays are just wicked awesome. And it is still like
magic that this stuff really works.
Thanks to everyone who pushed my nose in a better direction.
David
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php