diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/dir_fns.php | 27 | ||||
-rw-r--r-- | include/directory.php | 8 | ||||
-rw-r--r-- | include/socgraph.php | 8 |
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; |