2021-12-03 03:01:39 +00:00
|
|
|
<?php
|
|
|
|
|
2018-07-16 02:22:15 +00:00
|
|
|
namespace Zotlabs\Daemon;
|
2018-06-05 06:19:16 +00:00
|
|
|
|
|
|
|
use Zotlabs\Lib\Libzotdir;
|
2020-09-03 06:02:32 +00:00
|
|
|
use Zotlabs\Lib\Libzot;
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
class Cron_daily
|
|
|
|
{
|
|
|
|
|
|
|
|
public static function run($argc, $argv)
|
|
|
|
{
|
|
|
|
|
|
|
|
logger('cron_daily: start');
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
/**
|
|
|
|
* Cron Daily
|
|
|
|
*
|
|
|
|
*/
|
2016-05-20 04:22:04 +00:00
|
|
|
|
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
// make sure our own site record is up to date
|
|
|
|
Libzot::import_site(Libzot::site_info(true));
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2020-09-03 06:02:32 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
// Fire off the Cron_weekly process if it's the correct day.
|
2020-09-03 06:02:32 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
$d3 = intval(datetime_convert('UTC', 'UTC', 'now', 'N'));
|
|
|
|
if ($d3 == 7) {
|
|
|
|
Run::Summon([ 'Cron_weekly' ]);
|
|
|
|
}
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
// once daily run birthday_updates and then expire in background
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
// FIXME: add birthday updates, both locally and for xprof for use
|
|
|
|
// by directory servers
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
update_birthdays();
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
// expire any read notifications over a month old
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
q(
|
|
|
|
"delete from notify where seen = 1 and created < %s - INTERVAL %s",
|
|
|
|
db_utcnow(),
|
|
|
|
db_quoteinterval('60 DAY')
|
|
|
|
);
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
// expire any unread notifications over a year old
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
q(
|
|
|
|
"delete from notify where seen = 0 and created < %s - INTERVAL %s",
|
|
|
|
db_utcnow(),
|
|
|
|
db_quoteinterval('1 YEAR')
|
|
|
|
);
|
2017-02-28 22:56:26 +00:00
|
|
|
|
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
//update statistics in config
|
|
|
|
require_once('include/statistics_fns.php');
|
|
|
|
update_channels_total_stat();
|
|
|
|
update_channels_active_halfyear_stat();
|
|
|
|
update_channels_active_monthly_stat();
|
|
|
|
update_local_posts_stat();
|
|
|
|
update_local_comments_stat();
|
2017-02-28 22:56:26 +00:00
|
|
|
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
// expire old delivery reports
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
$keep_reports = intval(get_config('system', 'expire_delivery_reports'));
|
|
|
|
if ($keep_reports === 0) {
|
|
|
|
$keep_reports = 10;
|
|
|
|
}
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
q(
|
|
|
|
"delete from dreport where dreport_time < %s - INTERVAL %s",
|
|
|
|
db_utcnow(),
|
|
|
|
db_quoteinterval($keep_reports . ' DAY')
|
|
|
|
);
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
// delete accounts that did not submit email verification within 3 days
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
$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'])
|
|
|
|
);
|
2021-03-18 01:30:37 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
q(
|
|
|
|
"DELETE FROM register WHERE id = %d",
|
|
|
|
intval($rv['id'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2021-03-18 01:30:37 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
// expire any expired accounts
|
|
|
|
downgrade_accounts();
|
2021-03-18 01:30:37 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
Run::Summon([ 'Expire' ]);
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2020-09-01 02:24:21 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
// remove xchan photos that were stored in the DB ine earlier versions
|
|
|
|
// and were migrated to filesystem storage.
|
|
|
|
// eventually this will do nothing but waste cpu cycles checking to see if anything remains.
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
cleanup_xchan_photos();
|
2020-08-26 01:29:23 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
remove_obsolete_hublocs();
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
call_hooks('cron_daily', datetime_convert());
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
set_config('system', 'last_expire_day', intval(datetime_convert('UTC', 'UTC', 'now', 'd')));
|
2016-05-20 04:22:04 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
/**
|
|
|
|
* End Cron Daily
|
|
|
|
*/
|
|
|
|
}
|
2016-05-20 04:22:04 +00:00
|
|
|
}
|