2013-02-28 09:14:20 +01:00
< ? php
/*
* ReDonate is more free software . It is licensed under the WTFPL , which
* allows you to do pretty much anything with it , without having to
* ask permission . Commercial use is allowed , and no attribution is
* required . We do politely request that you share your modifications
* to benefit other developers , but you are under no enforced
* obligation to do so : )
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text .
*/
$_APP = true ;
require ( " includes/base.php " );
if ( php_sapi_name () !== " cli " )
{
2013-03-01 13:42:17 +01:00
http_status_code ( 403 );
die ();
2013-02-28 09:14:20 +01:00
}
/* This cronjob will send out donation reminder e - mails for every user
* that hasn ' t received an e - mail in the past month . It will also
* re - generate statistics for every campaign , and store them in the
* historical statistics logs .
*/
2013-03-01 10:52:31 +01:00
/* First, we will update the exchange rates. */
Currency :: UpdateRates ();
/* Then, we'll start out sending reminder e-mails. */
2013-02-28 09:14:20 +01:00
try
{
2014-06-25 13:05:12 +02:00
$sSubscriptions = Subscription :: CreateFromQuery ( " SELECT * FROM subscriptions WHERE `Confirmed` = 1 AND `Active` = 1 AND (`LastEmail` IS NULL OR `LastEmail` < DATE_SUB(NOW(), INTERVAL 1 MONTH)) " );
2013-02-28 09:14:20 +01:00
}
catch ( NotFoundException $e )
{
$sSubscriptions = array ();
}
foreach ( $sSubscriptions as $sSubscription )
{
2013-03-01 12:52:04 +01:00
$sSubscription -> SendPaymentRequest ();
2013-02-28 09:14:20 +01:00
}
2013-03-01 08:14:00 +01:00
/* Now, we'll log a historical statistics snapshot for every campaign. */
2013-03-02 05:37:52 +01:00
try
{
$sCampaigns = Campaign :: CreateFromQuery ( " SELECT * FROM campaigns " );
$found = true ;
}
catch ( NotFoundException $e )
{
/* No campaigns are in the database yet. */
$found = false ;
}
if ( $found )
2013-03-01 08:14:00 +01:00
{
2013-03-02 05:37:52 +01:00
foreach ( $sCampaigns as $sCampaign )
{
$sCampaign -> UpdateStatistics ();
$sStatisticsEntry = $sCampaign -> CreateStatisticsEntry ();
$sStatisticsEntry -> InsertIntoDatabase ();
}
2013-03-01 08:14:00 +01:00
}