aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/regdir.php64
-rw-r--r--mod/zfinger.php9
2 files changed, 72 insertions, 1 deletions
diff --git a/mod/regdir.php b/mod/regdir.php
new file mode 100644
index 000000000..c00187978
--- /dev/null
+++ b/mod/regdir.php
@@ -0,0 +1,64 @@
+<?php
+
+
+function regdir_init(&$a) {
+
+ $result = array('success' => false);
+
+ $url = $_REQUEST['url'];
+
+
+ // we probably don't need the realm as we will find out in the probe.
+ // What we may want to die is throw an error if you're trying to register in a different realm
+ // so this configuration issue can be discovered.
+
+ $realm = $_REQUEST['realm'];
+ if(! $realm)
+ $realm = DIRECTORY_REALM;
+
+ $dirmode = intval(get_config('system','directory_mode'));
+
+ if($dirmode == DIRECTORY_MODE_NORMAL) {
+ $ret['message'] = t('This site is not a directory server');
+ json_return_and_die($ret);
+ }
+
+ $m = null;
+ if($url) {
+ $m = parse_url($url);
+
+ if((! $m) || (! @dns_get_record($m['host'], DNS_A + DNS_CNAME + DNS_PTR)) || (! filter_var($m['host'], FILTER_VALIDATE_IP) )) {
+ $result['message'] = 'unparseable url';
+ json_return_and_die($result);
+ }
+
+ $f = zot_finger('sys@' . $m['host']);
+ if($f['success']) {
+ $j = json_decode($f['body'],true);
+ if($j['success'] && $j['guid']) {
+ $x = import_xchan($j);
+ if($x['success']) {
+ $result['success'] = true;
+ json_return_and_die($result);
+ }
+ }
+ }
+
+ json_return_and_die($result);
+ }
+ else {
+ $r = q("select site_url from site where site_flags in ( 1, 2 ) and site_realm = '%s'",
+ dbesc(get_directory_realm())
+ );
+ if($r) {
+ $result['success'] = true;
+ $result['directories'] = array();
+ foreach($r as $rr)
+ $result['directories'][] = $rr['site_url'];
+ json_return_and_die($result);
+ }
+ }
+ json_return_and_die($result);
+
+
+} \ No newline at end of file
diff --git a/mod/zfinger.php b/mod/zfinger.php
index 6f4febc6f..f4b7efd96 100644
--- a/mod/zfinger.php
+++ b/mod/zfinger.php
@@ -99,13 +99,14 @@ function zfinger_init(&$a) {
$id = $e['channel_id'];
+ $sys_channel = (($e['channel_pageflags'] & PAGE_SYSTEM) ? true : false);
$special_channel = (($e['channel_pageflags'] & PAGE_PREMIUM) ? true : false);
$adult_channel = (($e['channel_pageflags'] & PAGE_ADULT) ? true : false);
$censored = (($e['channel_pageflags'] & PAGE_CENSORED) ? true : false);
$searchable = (($e['channel_pageflags'] & PAGE_HIDDEN) ? false : true);
$deleted = (($e['xchan_flags'] & XCHAN_FLAGS_DELETED) ? true : false);
- if($deleted || $censored)
+ if($deleted || $censored || $sys_channel)
$searchable = false;
$public_forum = false;
@@ -237,6 +238,12 @@ function zfinger_init(&$a) {
$dirmode = get_config('system','directory_mode');
if(($dirmode === false) || ($dirmode == DIRECTORY_MODE_NORMAL))
$ret['site']['directory_mode'] = 'normal';
+
+ // downgrade mis-configured primaries
+
+ if($dirmode == DIRECTORY_MODE_PRIMARY && z_root() != get_directory_primary())
+ $dirmode = DIRECTORY_MODE_SECONDARY;
+
if($dirmode == DIRECTORY_MODE_PRIMARY)
$ret['site']['directory_mode'] = 'primary';
elseif($dirmode == DIRECTORY_MODE_SECONDARY)