From 1383915f865a26fe06c959d155f118b5934b3de7 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Feb 2015 22:58:09 -0800 Subject: notes about private realm registrations and multiple primary directories. --- mod/regdir.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'mod/regdir.php') diff --git a/mod/regdir.php b/mod/regdir.php index eecc99ca5..f24ee3951 100644 --- a/mod/regdir.php +++ b/mod/regdir.php @@ -1,6 +1,18 @@ false); @@ -32,7 +44,7 @@ function regdir_init(&$a) { json_return_and_die($result); } - $f = zot_finger('sys@' . $m['host']); + $f = zot_finger('[system]@' . $m['host']); if($f['success']) { $j = json_decode($f['body'],true); if($j['success'] && $j['guid']) { -- cgit v1.2.3 From 08f054130f5a57e2928e129131e7609271ec7f40 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 24 Feb 2015 16:36:27 -0800 Subject: require access token to view, query, or join directories in private realms, if the realm is so configured. --- mod/regdir.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'mod/regdir.php') diff --git a/mod/regdir.php b/mod/regdir.php index f24ee3951..f12659dad 100644 --- a/mod/regdir.php +++ b/mod/regdir.php @@ -18,7 +18,8 @@ function regdir_init(&$a) { $result = array('success' => false); $url = $_REQUEST['url']; - + $access_token = $_REQUEST['t']; + $valid = 0; // 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 @@ -28,6 +29,18 @@ function regdir_init(&$a) { if(! $realm) $realm = DIRECTORY_REALM; + if($realm === DIRECTORY_REALM) { + $valid = 1; + } + else { + $token = get_config('system','realm_token'); + if($token && $access_token != $token) { + $result['message'] = 'This realm requires an access token'; + return; + } + $valid = 1; + } + $dirmode = intval(get_config('system','directory_mode')); if($dirmode == DIRECTORY_MODE_NORMAL) { @@ -56,14 +69,25 @@ function regdir_init(&$a) { } } + q("update site set site_valid = %d where site_url = '%s' limit 1", + intval($valid), + strtolower($url) + ); + json_return_and_die($result); } else { + + // We can put this in the sql without the condition after 31 march 2015 assuming + // most directory servers will have updated by then + // This just makes sure it happens if I forget + + $sql_extra = ((datetime_convert() > datetime_convert('UTC','UTC','2015-03-31')) ? ' and site_valid = 1 ' : '' ); 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'", + $r = q("select site_url from site where site_flags in ( 1, 2 ) and site_realm = '%s' $sql_extra ", dbesc(get_directory_realm()) ); } -- cgit v1.2.3 From b1fd6c53a5f86fd752db9c5394cae8f67492f07e Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 19 Mar 2015 15:56:30 -0700 Subject: tweaks to directory registrations which don't seem to be happening, also downgrade any directory that claims to be a primary directory for RED_GLOBAL. --- mod/regdir.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod/regdir.php') diff --git a/mod/regdir.php b/mod/regdir.php index f12659dad..5331c1dd4 100644 --- a/mod/regdir.php +++ b/mod/regdir.php @@ -78,11 +78,11 @@ function regdir_init(&$a) { } else { - // We can put this in the sql without the condition after 31 march 2015 assuming + // We can put this in the sql without the condition after 31 april 2015 assuming // most directory servers will have updated by then // This just makes sure it happens if I forget - $sql_extra = ((datetime_convert() > datetime_convert('UTC','UTC','2015-03-31')) ? ' and site_valid = 1 ' : '' ); + $sql_extra = ((datetime_convert() > datetime_convert('UTC','UTC','2015-04-31')) ? ' and site_valid = 1 ' : '' ); if($dirmode == DIRECTORY_MODE_STANDALONE) { $r = array(array('site_url' => z_root())); } -- cgit v1.2.3 From d0361582b0b620064aff90bf88f01d1072b308fe Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Sun, 22 Mar 2015 00:06:08 +0100 Subject: Correcting reported Doxygen syntax warnings. Fixed wrong Doxygen syntax and add some of the available FIXME to Doxygen documentation. Updated Doxygen configuration to add also all capital letter tags. Adding some more Doxygen documentation. --- mod/regdir.php | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'mod/regdir.php') diff --git a/mod/regdir.php b/mod/regdir.php index 5331c1dd4..025be220b 100644 --- a/mod/regdir.php +++ b/mod/regdir.php @@ -1,18 +1,17 @@ false); @@ -31,8 +30,7 @@ function regdir_init(&$a) { if($realm === DIRECTORY_REALM) { $valid = 1; - } - else { + } else { $token = get_config('system','realm_token'); if($token && $access_token != $token) { $result['message'] = 'This realm requires an access token'; @@ -40,19 +38,19 @@ function regdir_init(&$a) { } $valid = 1; } - + $dirmode = intval(get_config('system','directory_mode')); - if($dirmode == DIRECTORY_MODE_NORMAL) { + if ($dirmode == DIRECTORY_MODE_NORMAL) { $ret['message'] = t('This site is not a directory server'); json_return_and_die($ret); } $m = null; - if($url) { + 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) )) { + 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); } @@ -75,31 +73,28 @@ function regdir_init(&$a) { ); json_return_and_die($result); - } - else { + } else { // We can put this in the sql without the condition after 31 april 2015 assuming // most directory servers will have updated by then // This just makes sure it happens if I forget $sql_extra = ((datetime_convert() > datetime_convert('UTC','UTC','2015-04-31')) ? ' and site_valid = 1 ' : '' ); - if($dirmode == DIRECTORY_MODE_STANDALONE) { + if ($dirmode == DIRECTORY_MODE_STANDALONE) { $r = array(array('site_url' => z_root())); - } - else { + } else { $r = q("select site_url from site where site_flags in ( 1, 2 ) and site_realm = '%s' $sql_extra ", dbesc(get_directory_realm()) ); } - if($r) { + if ($r) { $result['success'] = true; $result['directories'] = array(); - foreach($r as $rr) + 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 +} \ No newline at end of file -- cgit v1.2.3 From 6f78d7a85d0371dc7fb72acb3a85217005400f91 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 31 Mar 2015 21:06:48 -0700 Subject: fix regdir --- mod/regdir.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'mod/regdir.php') diff --git a/mod/regdir.php b/mod/regdir.php index 025be220b..dce50e76a 100644 --- a/mod/regdir.php +++ b/mod/regdir.php @@ -50,7 +50,8 @@ function regdir_init(&$a) { 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) )) { + 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); } @@ -62,11 +63,13 @@ function regdir_init(&$a) { $x = import_xchan($j); if($x['success']) { $result['success'] = true; - json_return_and_die($result); } } } + if(! $result['success']) + $valid = 0; + q("update site set site_valid = %d where site_url = '%s' limit 1", intval($valid), strtolower($url) @@ -75,11 +78,11 @@ function regdir_init(&$a) { json_return_and_die($result); } else { - // We can put this in the sql without the condition after 31 april 2015 assuming + // We can put this in the sql without the condition after 31 august 2015 assuming // most directory servers will have updated by then // This just makes sure it happens if I forget - $sql_extra = ((datetime_convert() > datetime_convert('UTC','UTC','2015-04-31')) ? ' and site_valid = 1 ' : '' ); + $sql_extra = ((datetime_convert() > datetime_convert('UTC','UTC','2015-08-31')) ? ' and site_valid = 1 ' : '' ); if ($dirmode == DIRECTORY_MODE_STANDALONE) { $r = array(array('site_url' => z_root())); } else { -- cgit v1.2.3