aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xboot.php2
-rw-r--r--include/dir_fns.php30
-rw-r--r--include/zot.php7
-rw-r--r--install/update.php10
-rw-r--r--mod/dirsearch.php14
-rw-r--r--mod/sitelist.php6
6 files changed, 54 insertions, 15 deletions
diff --git a/boot.php b/boot.php
index 502783409..267999d07 100755
--- a/boot.php
+++ b/boot.php
@@ -47,7 +47,7 @@ define ( 'RED_PLATFORM', 'Red Matrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 );
-define ( 'DB_UPDATE_VERSION', 1122 );
+define ( 'DB_UPDATE_VERSION', 1123 );
define ( 'EOL', '<br />' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
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));
diff --git a/install/update.php b/install/update.php
index bd4e043a0..f7d6441dc 100644
--- a/install/update.php
+++ b/install/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1122 );
+define( 'UPDATE_VERSION' , 1123 );
/**
*
@@ -1369,3 +1369,11 @@ ADD INDEX ( `site_realm` )");
}
+function update_r1122() {
+ $r = q("update site set site_realm = '%s' where true",
+ dbesc(DIRECTORY_REALM)
+ );
+ if($r)
+ return UPDATE_SUCCESS;
+ return UPDATE_FAILED;
+}
diff --git a/mod/dirsearch.php b/mod/dirsearch.php
index 0ace4ecae..b72d303b7 100644
--- a/mod/dirsearch.php
+++ b/mod/dirsearch.php
@@ -325,8 +325,18 @@ function dir_parse_query($s) {
function list_public_sites() {
-
- $r = q("select * from site where site_access != 0 and site_register !=0 order by rand()");
+ $realm = get_directory_realm();
+ if($realm == DIRECTORY_REALM) {
+ $r = q("select * from site where site_access != 0 and site_register !=0 and ( site_realm = '%s' or site_realm = '') order by rand()",
+ dbesc($realm)
+ );
+ }
+ else {
+ $r = q("select * from site where site_access != 0 and site_register !=0 and site_realm = '%s' order by rand()",
+ dbesc($realm)
+ );
+ }
+
$ret = array('success' => false);
if($r) {
diff --git a/mod/sitelist.php b/mod/sitelist.php
index 1e6d0fcfb..95cf862df 100644
--- a/mod/sitelist.php
+++ b/mod/sitelist.php
@@ -18,6 +18,12 @@ function sitelist_init(&$a) {
if($open)
$sql_extra = " and site_register = " . intval(REGISTER_OPEN) . " ";
+ $realm = get_directory_realm();
+ if($realm == DIRECTORY_REALM) {
+ $sql_extra .= " and ( site_realm = '" . dbesc($realm) . "' or site_realm = '') ";
+ }
+ else
+ $sql_extra .= " and site_realm = '" . dbesc($realm) . "' ";
$result = array('success' => false);