diff options
Diffstat (limited to 'include/poller.php')
-rw-r--r-- | include/poller.php | 62 |
1 files changed, 58 insertions, 4 deletions
diff --git a/include/poller.php b/include/poller.php index ef4b93fe7..00914a712 100644 --- a/include/poller.php +++ b/include/poller.php @@ -1,4 +1,4 @@ -<?php +<?php /** @file */ require_once('boot.php'); require_once('include/cli_startup.php'); @@ -30,14 +30,32 @@ function poller_run($argv, $argc){ // expire any expired accounts q("UPDATE account - SET account_flags = account_flags | %d - where not account_flags & %d + SET account_flags = (account_flags | %d) + where not (account_flags & %d) and account_expires != '0000-00-00 00:00:00' and account_expires < UTC_TIMESTAMP() ", intval(ACCOUNT_EXPIRED), intval(ACCOUNT_EXPIRED) ); + // publish any applicable items that were set to be published in the future + // (time travel posts) + + $r = q("select id from item where ( item_restrict & %d ) and created <= UTC_TIMESTAMP() ", + intval(ITEM_DELAYED_PUBLISH) + ); + if($r) { + foreach($r as $rr) { + $x = q("update item set item_restrict = ( item_restrict ^ %d ) where id = %d limit 1", + intval(ITEM_DELAYED_PUBLISH), + intval($rr['id']) + ); + if($x) { + proc_run('php','include/notifer.php','wall-new',$rr['id']); + } + } + } + $abandon_days = intval(get_config('system','account_abandon_days')); if($abandon_days < 1) $abandon_days = 0; @@ -45,15 +63,51 @@ function poller_run($argv, $argc){ // once daily run birthday_updates and then expire in background + // FIXME: add birthday updates, both locally and for xprof for use + // by directory servers + $d1 = get_config('system','last_expire_day'); $d2 = intval(datetime_convert('UTC','UTC','now','d')); if($d2 != intval($d1)) { -// update_suggestions(); + // If this is a directory server, request a sync with an upstream + // directory at least once a day, up to once every poll interval. + // Pull remote changes and push local changes. + // potential issue: how do we keep from creating an endless update loop? + + $dirmode = get_config('system','directory_mode'); + if($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) { + require_once('include/dir_fns.php'); + sync_directories($dirmode); + } + set_config('system','last_expire_day',$d2); proc_run('php','include/expire.php'); + + proc_run('php','include/cli_suggest.php'); + + } + + // update any photos which didn't get imported properly + // This should be rare + + $r = q("select xchan_photo_l, xchan_hash from xchan where xchan_photo_l != '' and xchan_photo_m = '' + and xchan_photo_date < UTC_TIMESTAMP() - INTERVAL 1 DAY"); + if($r) { + require_once('include/photo/photo_driver.php'); + foreach($r as $rr) { + $photos = import_profile_photo($rr['xchan_photo_l'],$rr['xchan_hash']); + $x = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' + where xchan_hash = '%s' limit 1", + dbesc($photos[0]), + dbesc($photos[1]), + dbesc($photos[2]), + dbesc($photos[3]), + dbesc($rr['xchan_hash']) + ); + } } |