From b1a92d620ebf760a3cfd83f6fb62990494d3ad60 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 1 Feb 2015 15:10:52 -0800 Subject: two tracks proceeding in parallel - first adding the ability to store a digital signature with ratings so that directories can pass them around, second provide some directory registration functions so we can obtain a list of directories from somewhere (to pass ratings around between them). This gives the primary directory role some value as that is where you register your directory. --- mod/regdir.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 mod/regdir.php (limited to 'mod/regdir.php') 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 @@ + 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 -- cgit v1.2.3