aboutsummaryrefslogtreecommitdiffstats
path: root/include
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
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')
-rw-r--r--include/dir_fns.php27
-rw-r--r--include/directory.php8
-rw-r--r--include/socgraph.php8
3 files changed, 26 insertions, 17 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() {
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;