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 
data field.
2) A unix_timestamp field is added to table 'A'. The value of this field initially = 
when the user
subscribed.
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 
subscriber tables,
    SELECTing email addresses where the unix_timestamp < the create date of the files, 
by category (all
in one
    SELECT statement?)
    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 
programming)

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.

Cheers,
Dan

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 
>column name
> 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 
>every morning.
> * The script gets current file numbers per directory and places this data into table 
>'B'.
> * Another script, also executed by cron every evening at time 'Y' (after the script 
>above),
> 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' 
>and 'C'.
> * 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 
>categories.
> * 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 
>recursion
> scripts I got from phpbuilder, but the exact method of performing the above kinda 
>eludes me.
>
> Any (constructive) comments more than welcome.
>
> Kind regards:
> Russ
>
> #-------------------------------------------------------#
>
>   "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
>
>   www.theruss.com
>
> #-------------------------------------------------------#
>
> --
> 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]

--
----------
Dan Barton
Terrestrial Program Biologist
Data Manager
Point Reyes Bird Observatory
http://www.prbo.org
[EMAIL PROTECTED]
[EMAIL PROTECTED]



-- 
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]

Reply via email to