aboutsummaryrefslogtreecommitdiffstats
path: root/mod/regdir.php
diff options
context:
space:
mode:
authorHabeas Codice <habeascodice@federated.social>2015-02-05 09:15:39 -0800
committerHabeas Codice <habeascodice@federated.social>2015-02-05 09:15:39 -0800
commit9ed23f9081b56369349d4e06c51e3856f950804e (patch)
treeb3a1121ec41e04cce02cfa07fc958b95a3fd289b /mod/regdir.php
parent88488fdfbb58aa04b450af1691aba7cea1bce8ab (diff)
parent646a874390be8f92736866118d7215e8cb80fb8a (diff)
downloadvolse-hubzilla-9ed23f9081b56369349d4e06c51e3856f950804e.tar.gz
volse-hubzilla-9ed23f9081b56369349d4e06c51e3856f950804e.tar.bz2
volse-hubzilla-9ed23f9081b56369349d4e06c51e3856f950804e.zip
Merge branch 'master' of https://github.com/friendica/red
Diffstat (limited to 'mod/regdir.php')
-rw-r--r--mod/regdir.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/mod/regdir.php b/mod/regdir.php
new file mode 100644
index 000000000..eecc99ca5
--- /dev/null
+++ b/mod/regdir.php
@@ -0,0 +1,69 @@
+<?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 {
+ if($dirmode == DIRECTORY_MODE_STANDALONE) {
+ $r = array(array('site_url' => z_root()));
+ }
+ 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