diff options
-rw-r--r-- | include/dir_fns.php | 43 | ||||
-rw-r--r-- | include/poller.php | 15 |
2 files changed, 54 insertions, 4 deletions
diff --git a/include/dir_fns.php b/include/dir_fns.php index 677420c54..5a1d671cb 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -6,6 +6,49 @@ function find_upstream_directory($dirmode) { return ''; } + +function sync_directories($dirmode) { + + if($dirmode == DIRECTORY_MODE_STANDALONE || $dirmode == DIRECTORY_MODE_NORMAL) + return; + + $r = q("select * from site where (site_flags & %d) and site_url != '%s'", + intval(DIRECTORY_MODE_PRIMARY), + dbesc(z_root()) + ); + + // If there are no directory servers, setup the fallback master + + if((! $r) && (z_root() != DIRECTORY_FALLBACK_MASTER)) { + $r = array( + 'site_url' => DIRECTORY_FALLBACK_MASTER, + 'site_flags' => DIRECTORY_MODE_PRIMARY, + 'site_update' => '0000-00-00 00:00:00', + 'site_directory' => DIRECTORY_FALLBACK_MASTER . '/dirsearch' + ); + $x = q("insert into site ( site_url, site_flags, site_update, site_directory ) + values ( '%s', %d', '%s', '%s' ) ", + dbesc($r[0]['site_url']), + intval($r[0]['site_flags']), + dbesc($r[0]['site_update']), + dbesc($r[0]['site_directory']) + ); + + } + + + + + + +} + + + + + + + function syncdirs($uid) { logger('syncdirs', LOGGER_DEBUG); diff --git a/include/poller.php b/include/poller.php index 1dd065196..33e882735 100644 --- a/include/poller.php +++ b/include/poller.php @@ -50,16 +50,23 @@ function poller_run($argv, $argc){ if($d2 != intval($d1)) { + // 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); + } + // update_suggestions(); set_config('system','last_expire_day',$d2); proc_run('php','include/expire.php'); } - // 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? $manual_id = 0; $generation = 0; |