Welcome, Guest. Please Login or Register.
May 14, 2025, 01:48:06 PM
Home Help Search Log in Register
News: If you are still using YaBB SE, please consider upgrading to SMF as soon as possible.

YaBB SE Community  |  Development  |  Mod Ideas and Creation  |  How to send something at regular intervals... « previous next »
Pages: [1] Reply Ignore Print
Author Topic: How to send something at regular intervals...  (Read 1666 times)
Grudge
Global Moderator
Full Member
*****
Posts: 178


Damn llama's don't like me :(

How to send something at regular intervals...
« on: July 23, 2003, 07:18:53 PM »
Reply with quote

Hi,

I'm working on a fairly large mod which essentially is for organising gaming events. I want people to be able to create events on a calendar type system (games such as half-life, unreal etc). Now other users can sign up for notification for games that they like - for example, I could say that I want to be notified whenever someone organises a gaming event for Unreal.

I have coed all of the above - what I want to ask is about timing. This notification will be by email and I want to only send out a maximum of one notification email every 24 hours. So, for example, if 5 gaming events were created within 24 hours the user doesn't receive 5 seperate emails but 1 email with all 5 events listed in it.

I want to know how to write something like this in php as obviously scripts are only executed when someone gets onto the forum - so - I can't for example tell it to execute at midnight every day.

I was thinking of putting a little check into index.php. Basically - it would check the time each time it is executed and check a little flag. When it has got past midnight if the notification script hasn't been run yet (as indicated by the flag) it will get run and the emails sent. The flag will then be set so it isn't ran again. A similar system will be set up for midday so that the first person to browse after 12 midday will reset the flag ready for the midnight time.

Is there a easier or more efficient way of doing this than this? Is this the only way I can use it? Would I be better putting this in a different php file such as messageindex so it doesn't get executed all the time but regular enough to get caught?

I hope this makes some sense - the basics of what I want is a way to execute a script at 12am every day!
Logged
Metho
Sr. Member
****
Posts: 342


I'm a llama!

Re:How to send something at regular intervals...
« Reply #1 on: July 23, 2003, 08:38:09 PM »
Reply with quote

Well, I think the first thing that you have to decide is what's really worth sending an email to a user. Or, perhaps giving the user the ability to receive emails only when certain events have taken place. Otherwise, the way I would go about it is take the emails and put them into a queue. Then at midnight (or whenever) you'd have a script run (cron-job like, not something intiated by a user) that would take all the emails from the previous day and compile the text into one email and then distribute it. Then the queue is deleted or stored in backup. Then everything from 12 am to whenever would be placed in queue until the next process runs.

Methonis
Logged

Grudge
Global Moderator
Full Member
*****
Posts: 178


Damn llama's don't like me :(

Re:How to send something at regular intervals...
« Reply #2 on: July 23, 2003, 08:50:04 PM »
Reply with quote

That is basically what I was trying to explain badly! That is what I want to do.

I think I have worked it out by looking at one of Unknowns mods. Basically - Whenever I send off the emails I stamp the time into the SQL database. Then after loadboard() (in index.php) I check if 24 hours have elapsed since the timestamp was last made. If 24 hours have elapsed I call the function (eg SendEmails) and then reset the timestamp.

Thanks for the help anyway!

Grudge
Logged
Pages: [1] Reply Ignore Print 
YaBB SE Community  |  Development  |  Mod Ideas and Creation  |  How to send something at regular intervals... « previous - next »
 


Powered by MySQL Powered by PHP YaBB SE Community | Powered by YaBB SE
© 2001-2003, YaBB SE Dev Team. All Rights Reserved.
SMF 2.1.4 © 2023, Simple Machines
Valid XHTML 1.0! Valid CSS

Page created in 0.033 seconds with 20 queries.