aboutsummaryrefslogtreecommitdiffstats
path: root/include/dir_fns.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-04-25 18:10:23 -0700
committerfriendica <info@friendica.com>2014-04-25 18:10:23 -0700
commit3e8e67df2c838ee5fe0129bd77a0c987b151a8f3 (patch)
tree711b02a71b00b79210ce633179c0cc5e8398259d /include/dir_fns.php
parentd6620522c274d67f12adebefea0d2ea50d08bf34 (diff)
downloadvolse-hubzilla-3e8e67df2c838ee5fe0129bd77a0c987b151a8f3.tar.gz
volse-hubzilla-3e8e67df2c838ee5fe0129bd77a0c987b151a8f3.tar.bz2
volse-hubzilla-3e8e67df2c838ee5fe0129bd77a0c987b151a8f3.zip
Set a default directory server from a hard-wired list if one was not previously chosen.
Diffstat (limited to 'include/dir_fns.php')
-rw-r--r--include/dir_fns.php27
1 files changed, 24 insertions, 3 deletions
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() {