Set a default directory server from a hard-wired list if one was not previously chosen.
This commit is contained in:
parent
d6620522c2
commit
3e8e67df2c
8
boot.php
8
boot.php
@ -67,6 +67,14 @@ define ( 'DIRECTORY_MODE_STANDALONE', 0x0100);
|
|||||||
define ( 'DIRECTORY_REALM', 'RED_GLOBAL');
|
define ( 'DIRECTORY_REALM', 'RED_GLOBAL');
|
||||||
define ( 'DIRECTORY_FALLBACK_MASTER', 'https://zothub.com');
|
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'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -3,10 +3,31 @@
|
|||||||
require_once('include/permissions.php');
|
require_once('include/permissions.php');
|
||||||
|
|
||||||
function find_upstream_directory($dirmode) {
|
function find_upstream_directory($dirmode) {
|
||||||
|
global $DIRECTORY_FALLBACK_SERVERS;
|
||||||
|
|
||||||
$preferred = get_config('system','directory_server');
|
$preferred = get_config('system','directory_server');
|
||||||
if($preferred)
|
if(! $preferred) {
|
||||||
return array('url' => $preferred);
|
|
||||||
return '';
|
/**
|
||||||
|
* 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() {
|
function dir_sort_links() {
|
||||||
|
@ -48,13 +48,7 @@ function directory_run($argv, $argc){
|
|||||||
}
|
}
|
||||||
|
|
||||||
$directory = find_upstream_directory($dirmode);
|
$directory = find_upstream_directory($dirmode);
|
||||||
|
$url = $directory['url'] . '/post';
|
||||||
if($directory) {
|
|
||||||
$url = $directory['url'] . '/post';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$url = DIRECTORY_FALLBACK_MASTER . '/post';
|
|
||||||
}
|
|
||||||
|
|
||||||
// ensure the upstream directory is updated
|
// ensure the upstream directory is updated
|
||||||
|
|
||||||
|
@ -370,13 +370,7 @@ function update_suggestions() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$directory = find_upstream_directory($dirmode);
|
$directory = find_upstream_directory($dirmode);
|
||||||
|
$url = $directory['url'] . '/sitelist';
|
||||||
if($directory) {
|
|
||||||
$url = $directory['url'] . '/sitelist';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$url = DIRECTORY_FALLBACK_MASTER . '/sitelist';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(! $url)
|
if(! $url)
|
||||||
return;
|
return;
|
||||||
|
@ -304,13 +304,7 @@ function navbar_complete(&$a) {
|
|||||||
if(! $url) {
|
if(! $url) {
|
||||||
require_once("include/dir_fns.php");
|
require_once("include/dir_fns.php");
|
||||||
$directory = find_upstream_directory($dirmode);
|
$directory = find_upstream_directory($dirmode);
|
||||||
|
$url = $directory['url'] . '/dirsearch';
|
||||||
if($directory) {
|
|
||||||
$url = $directory['url'] . '/dirsearch';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$url = DIRECTORY_FALLBACK_MASTER . '/dirsearch';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($url) {
|
if($url) {
|
||||||
|
@ -56,14 +56,9 @@ function directory_content(&$a) {
|
|||||||
}
|
}
|
||||||
if(! $url) {
|
if(! $url) {
|
||||||
$directory = find_upstream_directory($dirmode);
|
$directory = find_upstream_directory($dirmode);
|
||||||
|
$url = $directory['url'] . '/dirsearch';
|
||||||
if($directory) {
|
|
||||||
$url = $directory['url'] . '/dirsearch';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$url = DIRECTORY_FALLBACK_MASTER . '/dirsearch';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
|
logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
|
||||||
|
|
||||||
$contacts = array();
|
$contacts = array();
|
||||||
|
@ -23,13 +23,7 @@ function dirprofile_init(&$a) {
|
|||||||
}
|
}
|
||||||
if(! $url) {
|
if(! $url) {
|
||||||
$directory = find_upstream_directory($dirmode);
|
$directory = find_upstream_directory($dirmode);
|
||||||
|
$url = $directory['url'] . '/dirsearch';
|
||||||
if($directory) {
|
|
||||||
$url = $directory['url'] . '/dirsearch';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$url = DIRECTORY_FALLBACK_MASTER . '/dirsearch';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
|
logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
|
||||||
|
|
||||||
|
@ -9,13 +9,7 @@ function pubsites_content(&$a) {
|
|||||||
}
|
}
|
||||||
if(! $url) {
|
if(! $url) {
|
||||||
$directory = find_upstream_directory($dirmode);
|
$directory = find_upstream_directory($dirmode);
|
||||||
|
$url = $directory['url'] . '/dirsearch';
|
||||||
if($directory) {
|
|
||||||
$url = $directory['url'] . '/dirsearch';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$url = DIRECTORY_FALLBACK_MASTER . '/dirsearch';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$url .= '/sites';
|
$url .= '/sites';
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user