aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-01-18 16:43:46 -0800
committerfriendica <info@friendica.com>2015-01-18 16:43:46 -0800
commit673556a8472a1e6343c00a70651a90c79288da6c (patch)
tree7e70334e914a538d867164517db5767809bed4ac /include
parent5d30565c665341e6a6a805684cee4d45c1d2fafe (diff)
downloadvolse-hubzilla-673556a8472a1e6343c00a70651a90c79288da6c.tar.gz
volse-hubzilla-673556a8472a1e6343c00a70651a90c79288da6c.tar.bz2
volse-hubzilla-673556a8472a1e6343c00a70651a90c79288da6c.zip
don't unset a directory server which has no active channels and hence will never have a site table update. Do this by probing the sys channel of that directory weekly and checking the directory status returned by it.
Diffstat (limited to 'include')
-rw-r--r--include/dir_fns.php33
1 files changed, 24 insertions, 9 deletions
diff --git a/include/dir_fns.php b/include/dir_fns.php
index 371ee0fbc..6d06fddd1 100644
--- a/include/dir_fns.php
+++ b/include/dir_fns.php
@@ -31,22 +31,37 @@ function find_upstream_directory($dirmode) {
}
function check_upstream_directory() {
+
/**
* Directories may come and go over time. We will need to check that our
* directory server is still valid occasionally, and reset to something that
* is if our directory has gone offline for any reason
*/
+
$directory = get_config('system','directory_server');
- if ($directory) {
- $r = q("select * from site where site_url = '%s' and (site_flags & %d) > 0 ",
- dbesc($directory),
- intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY|DIRECTORY_MODE_STANDALONE)
- );
- }
- // If we've got something, it's still a directory. If we haven't, we need to reset and let find_upstream_directory() fix it
- if (! $r) {
- set_config('system','directory_server','');
+
+ // it's possible there is no directory server configured and the local hub is being used.
+ // If so, default to preserving the absence of a specific server setting.
+
+ $isadir = true;
+
+ if($directory) {
+ $h = parse_url($directory);
+ if($h) {
+ $x = zot_finger('sys@' . $h['host']);
+ if($x['success']) {
+ $j = json_decode($x['body'],true);
+ if(array_key_exists('site',$j) && array_key_exists('directory_mode',$j['site'])) {
+ if($j['site']['directory_mode'] === 'normal') {
+ $isadir = false;
+ }
+ }
+ }
}
+ }
+
+ if(! $isadir)
+ set_config('system','directory_server','');
return;
}