I would suggest perhaps a different way (slightly larger use of disk space, but only
one script and
only one query, although a moderately complex query):
1) Subscriber's emails are stored in table 'A' with their associated category as a
2) A unix_timestamp field is added to table 'A'. The value of this field initially =
when the user
3) Once daily, a script:
a) loads the contents of each directory into a table (B, C, D, etc.).
b) compares the create dates of each file with the unix_timestamp in the
SELECTing email addresses where the unix_timestamp < the create date of the files,
by category (all
c) mail()s those users
d) updates the unix_timestamp in table A, and start the cycle anew.
e) nuke the temporary tables of directory contents (or retain for further
All really depends on what you're optimizing for...this is perhaps the easiest
implementation for me in
terms of programming, but is probably not the easiest method on the server.
Russ Michell wrote:
> Hi there folks, this problem is sincerely 'doing my head in'!
> I want to know if there is a simpler method of achieving my aims set out below:
> Script aim:
> * To alert users subscribed to category's when new files are added to that category.
> * A category has the same name as each directory in my projects' filesystem.
> Proposed method (this is what I need a hand with)
> * Subscribers emails are stored in table 'A' under their associated category. (Each
> reflects a category name)
> * Subscribers are auto-emailed whenever a new file is added to their category
> * A script is executed by cron that iterates through all categories at time 'X, once
> * The script gets current file numbers per directory and places this data into table
> * Another script, also executed by cron every evening at time 'Y' (after the script
> compares the value of files per directory from table 'B' to the *now* current number
>of files in
> each directory.
> * It inserts these values into a another table 'C' and compares the totals in 'B'
> * If the totals in 'C' are greater than those in 'B' then detect which category's
>have had files
> added and select emails from table 'A' where their subscribed categories = updated
> * mail() these addresses with the message "Directory X has been updated"
> Is this too contrived or is there an easier method? I already have various directory
> scripts I got from phpbuilder, but the exact method of performing the above kinda
> Any (constructive) comments more than welcome.
> Kind regards:
> "Believe nothing - consider everything"
> Russ Michell
> Anglia Polytechnic University Webteam
> Room 1C 'The Eastings' East Road, Cambridge
> e: [EMAIL PROTECTED]
> w: www.apu.ac.uk/webteam
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
Terrestrial Program Biologist
Point Reyes Bird Observatory
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]