mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-22 00:15:23 +00:00
116 lines
2.9 KiB
PHP
116 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace Zotlabs\Daemon;
|
|
|
|
use Zotlabs\Lib\ServiceClass;
|
|
use Zotlabs\Lib\Libzotdir;
|
|
use Zotlabs\Lib\Libzot;
|
|
use Zotlabs\Lib\Statistics;
|
|
|
|
class Cron_daily
|
|
{
|
|
|
|
public static function run($argc, $argv)
|
|
{
|
|
|
|
logger('cron_daily: start');
|
|
|
|
/**
|
|
* Cron Daily
|
|
*
|
|
*/
|
|
|
|
|
|
// make sure our own site record is up to date
|
|
Libzot::import_site(Libzot::site_info(true));
|
|
|
|
|
|
// Fire off the Cron_weekly process if it's the correct day.
|
|
|
|
$d3 = intval(datetime_convert('UTC', 'UTC', 'now', 'N'));
|
|
if ($d3 == 7) {
|
|
Run::Summon([ 'Cron_weekly' ]);
|
|
}
|
|
|
|
// once daily run birthday_updates and then expire in background
|
|
|
|
// FIXME: add birthday updates, both locally and for xprof for use
|
|
// by directory servers
|
|
|
|
update_birthdays();
|
|
|
|
// expire any read notifications over a month old
|
|
|
|
q(
|
|
"delete from notify where seen = 1 and created < %s - INTERVAL %s",
|
|
db_utcnow(),
|
|
db_quoteinterval('60 DAY')
|
|
);
|
|
|
|
// expire any unread notifications over a year old
|
|
|
|
q(
|
|
"delete from notify where seen = 0 and created < %s - INTERVAL %s",
|
|
db_utcnow(),
|
|
db_quoteinterval('1 YEAR')
|
|
);
|
|
|
|
|
|
// update statistics counters (ignore values, they will be stored in config)
|
|
|
|
Statistics::get_channels_all();
|
|
Statistics::get_channels_6mo();
|
|
Statistics::get_channels_1mo();
|
|
Statistics::get_posts();
|
|
Statistics::get_comments();
|
|
|
|
// expire old delivery reports
|
|
|
|
$keep_reports = intval(get_config('system', 'expire_delivery_reports'));
|
|
if ($keep_reports === 0) {
|
|
$keep_reports = 10;
|
|
}
|
|
|
|
q(
|
|
"delete from dreport where dreport_time < %s - INTERVAL %s",
|
|
db_utcnow(),
|
|
db_quoteinterval($keep_reports . ' DAY')
|
|
);
|
|
|
|
// delete accounts that did not submit email verification within 3 days
|
|
|
|
$r = q(
|
|
"select * from register where password = 'verify' and created < %s - INTERVAL %s",
|
|
db_utcnow(),
|
|
db_quoteinterval('3 DAY')
|
|
);
|
|
if ($r) {
|
|
foreach ($r as $rv) {
|
|
q(
|
|
"DELETE FROM account WHERE account_id = %d",
|
|
intval($rv['uid'])
|
|
);
|
|
|
|
q(
|
|
"DELETE FROM register WHERE id = %d",
|
|
intval($rv['id'])
|
|
);
|
|
}
|
|
}
|
|
|
|
// expire any expired accounts
|
|
ServiceClass::downgrade_accounts();
|
|
|
|
Run::Summon([ 'Expire' ]);
|
|
|
|
remove_obsolete_hublocs();
|
|
|
|
call_hooks('cron_daily', datetime_convert());
|
|
|
|
set_config('system', 'last_expire_day', intval(datetime_convert('UTC', 'UTC', 'now', 'd')));
|
|
|
|
/**
|
|
* End Cron Daily
|
|
*/
|
|
}
|
|
}
|