aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xboot.php8
-rw-r--r--include/dir_fns.php27
-rw-r--r--include/directory.php8
-rw-r--r--include/socgraph.php8
-rw-r--r--mod/acl.php8
-rw-r--r--mod/directory.php9
-rw-r--r--mod/dirprofile.php8
-rw-r--r--mod/pubsites.php8
8 files changed, 39 insertions, 45 deletions
diff --git a/boot.php b/boot.php
index 01d11bee7..602012c85 100755
--- a/boot.php
+++ b/boot.php
@@ -67,6 +67,14 @@ define ( 'DIRECTORY_MODE_STANDALONE', 0x0100);
define ( 'DIRECTORY_REALM', 'RED_GLOBAL');
define ( 'DIRECTORY_FALLBACK_MASTER', 'https://zothub.com');
+$DIRECTORY_FALLBACK_SERVERS = array(
+ 'https://zothub.com',
+ 'https://zotid.net',
+ 'https://redmatrix.nl',
+ 'https://whogotzot.com',
+ 'https://red.mariovavti.com'
+);
+
/**
*
diff --git a/include/dir_fns.php b/include/dir_fns.php
index aeee8492f..a96e7821f 100644
--- a/include/dir_fns.php
+++ b/include/dir_fns.php
@@ -3,10 +3,31 @@
require_once('include/permissions.php');
function find_upstream_directory($dirmode) {
+ global $DIRECTORY_FALLBACK_SERVERS;
+
$preferred = get_config('system','directory_server');
- if($preferred)
- return array('url' => $preferred);
- return '';
+ if(! $preferred) {
+
+ /**
+ * No directory has yet been set. For most sites, pick one at random
+ * from our list of directory servers. However, if we're a directory
+ * server ourself, point at the local instance
+ * We will then set this value so this should only ever happen once.
+ * Ideally there will be an admin setting to change to a different
+ * directory server if you don't like our choice or if circumstances change.
+ */
+
+ $dirmode = intval(get_config('system','directory_mode'));
+ if($dirmode == DIRECTORY_MODE_NORMAL) {
+ $toss = mt_rand(0,count($DIRECTORY_FALLBACK_SERVERS));
+ $preferred = $DIRECTORY_FALLBACK_SERVERS[$toss];
+ set_config('system','directory_server',$preferred);
+ }
+ else{
+ set_config('system','directory_server',z_root());
+ }
+ }
+ return array('url' => $preferred);
}
function dir_sort_links() {
diff --git a/include/directory.php b/include/directory.php
index c69fb1f4b..c51fe765f 100644
--- a/include/directory.php
+++ b/include/directory.php
@@ -48,13 +48,7 @@ function directory_run($argv, $argc){
}
$directory = find_upstream_directory($dirmode);
-
- if($directory) {
- $url = $directory['url'] . '/post';
- }
- else {
- $url = DIRECTORY_FALLBACK_MASTER . '/post';
- }
+ $url = $directory['url'] . '/post';
// ensure the upstream directory is updated
diff --git a/include/socgraph.php b/include/socgraph.php
index 65e23f9df..e12da5862 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -370,13 +370,7 @@ function update_suggestions() {
}
else {
$directory = find_upstream_directory($dirmode);
-
- if($directory) {
- $url = $directory['url'] . '/sitelist';
- }
- else {
- $url = DIRECTORY_FALLBACK_MASTER . '/sitelist';
- }
+ $url = $directory['url'] . '/sitelist';
}
if(! $url)
return;
diff --git a/mod/acl.php b/mod/acl.php
index 9bd1a9eb4..fa399a9b5 100644
--- a/mod/acl.php
+++ b/mod/acl.php
@@ -304,13 +304,7 @@ function navbar_complete(&$a) {
if(! $url) {
require_once("include/dir_fns.php");
$directory = find_upstream_directory($dirmode);
-
- if($directory) {
- $url = $directory['url'] . '/dirsearch';
- }
- else {
- $url = DIRECTORY_FALLBACK_MASTER . '/dirsearch';
- }
+ $url = $directory['url'] . '/dirsearch';
}
if($url) {
diff --git a/mod/directory.php b/mod/directory.php
index 6e0e2e7dc..b11b0d410 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -56,14 +56,9 @@ function directory_content(&$a) {
}
if(! $url) {
$directory = find_upstream_directory($dirmode);
-
- if($directory) {
- $url = $directory['url'] . '/dirsearch';
- }
- else {
- $url = DIRECTORY_FALLBACK_MASTER . '/dirsearch';
- }
+ $url = $directory['url'] . '/dirsearch';
}
+
logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
$contacts = array();
diff --git a/mod/dirprofile.php b/mod/dirprofile.php
index d88144f52..e9b12ada7 100644
--- a/mod/dirprofile.php
+++ b/mod/dirprofile.php
@@ -23,13 +23,7 @@ function dirprofile_init(&$a) {
}
if(! $url) {
$directory = find_upstream_directory($dirmode);
-
- if($directory) {
- $url = $directory['url'] . '/dirsearch';
- }
- else {
- $url = DIRECTORY_FALLBACK_MASTER . '/dirsearch';
- }
+ $url = $directory['url'] . '/dirsearch';
}
logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
diff --git a/mod/pubsites.php b/mod/pubsites.php
index c08ca2ae5..c31bbcf97 100644
--- a/mod/pubsites.php
+++ b/mod/pubsites.php
@@ -9,13 +9,7 @@ function pubsites_content(&$a) {
}
if(! $url) {
$directory = find_upstream_directory($dirmode);
-
- if($directory) {
- $url = $directory['url'] . '/dirsearch';
- }
- else {
- $url = DIRECTORY_FALLBACK_MASTER . '/dirsearch';
- }
+ $url = $directory['url'] . '/dirsearch';
}
$url .= '/sites';