aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-08-17 19:06:56 -0700
committerfriendica <info@friendica.com>2014-08-17 19:06:56 -0700
commit4a76925787672ede57e0d36c890ffb08b6d32ed4 (patch)
treee61d21fbde2020027fd0c9dd132c0cb8f998d262 /include
parentde1198ccfe113c848482ba0ba21bc9f24caca8a8 (diff)
downloadvolse-hubzilla-4a76925787672ede57e0d36c890ffb08b6d32ed4.tar.gz
volse-hubzilla-4a76925787672ede57e0d36c890ffb08b6d32ed4.tar.bz2
volse-hubzilla-4a76925787672ede57e0d36c890ffb08b6d32ed4.zip
some more work on realms
Diffstat (limited to 'include')
-rw-r--r--include/dir_fns.php30
-rw-r--r--include/zot.php7
2 files changed, 26 insertions, 11 deletions
diff --git a/include/dir_fns.php b/include/dir_fns.php
index 14e4c0a1d..815b6a197 100644
--- a/include/dir_fns.php
+++ b/include/dir_fns.php
@@ -64,26 +64,40 @@ function sync_directories($dirmode) {
if($dirmode == DIRECTORY_MODE_STANDALONE || $dirmode == DIRECTORY_MODE_NORMAL)
return;
- $r = q("select * from site where (site_flags & %d) and site_url != '%s'",
- intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY),
- dbesc(z_root())
- );
+ $realm = get_directory_realm();
+ if($realm == DIRECTORY_REALM) {
+ $r = q("select * from site where (site_flags & %d) and site_url != '%s' and ( site_realm = '%s' or site_realm = '') ",
+ intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY),
+ dbesc(z_root()),
+ dbesc($realm)
+ );
+ }
+ else {
+ $r = q("select * from site where (site_flags & %d) and site_url != '%s' and site_realm like '%s' ",
+ intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY),
+ dbesc(z_root()),
+ dbesc(protect_sprintf('%' . $realm . '%'))
+ );
+ }
// If there are no directory servers, setup the fallback master
+ // FIXME - what to do if we're in a different realm?
if((! $r) && (z_root() != DIRECTORY_FALLBACK_MASTER)) {
$r = array(
'site_url' => DIRECTORY_FALLBACK_MASTER,
'site_flags' => DIRECTORY_MODE_PRIMARY,
'site_update' => '0000-00-00 00:00:00',
- 'site_directory' => DIRECTORY_FALLBACK_MASTER . '/dirsearch'
+ 'site_directory' => DIRECTORY_FALLBACK_MASTER . '/dirsearch',
+ 'site_realm' => DIRECTORY_REALM
);
- $x = q("insert into site ( site_url, site_flags, site_update, site_directory )
- values ( '%s', %d', '%s', '%s' ) ",
+ $x = q("insert into site ( site_url, site_flags, site_update, site_directory, site_realm )
+ values ( '%s', %d', '%s', '%s', '%s' ) ",
dbesc($r[0]['site_url']),
intval($r[0]['site_flags']),
dbesc($r[0]['site_update']),
- dbesc($r[0]['site_directory'])
+ dbesc($r[0]['site_directory']),
+ dbesc($r[0]['site_realm'])
);
$r = q("select * from site where (site_flags & %d) and site_url != '%s'",
diff --git a/include/zot.php b/include/zot.php
index 8dcc19522..8b0efe09d 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -2064,8 +2064,8 @@ function import_site($arr,$pubkey) {
}
else {
$update = true;
- $r = q("insert into site ( site_location, site_url, site_access, site_flags, site_update, site_directory, site_register, site_sellpage )
- values ( '%s', '%s', %d, %d, '%s', '%s', %d, '%s' )",
+ $r = q("insert into site ( site_location, site_url, site_access, site_flags, site_update, site_directory, site_register, site_sellpage, site_realm )
+ values ( '%s', '%s', %d, %d, '%s', '%s', %d, '%s', '%s' )",
dbesc($site_location),
dbesc($url),
intval($access_policy),
@@ -2073,7 +2073,8 @@ function import_site($arr,$pubkey) {
dbesc(datetime_convert()),
dbesc($directory_url),
intval($register_policy),
- dbesc($sellpage)
+ dbesc($sellpage),
+ dbesc($site_realm)
);
if(! $r) {
logger('import_site: record create failed. ' . print_r($arr,true));