aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-12-15 14:36:43 -0800
committerfriendica <info@friendica.com>2013-12-15 14:36:43 -0800
commit0272ab4cd9a6428396489d88c7a1a89be76e5810 (patch)
tree78ae24629cb4fd9b52442fdad2f307107460b048
parent950bd72e020daf887ac487c95d6f4f2e42b1dee9 (diff)
downloadvolse-hubzilla-0272ab4cd9a6428396489d88c7a1a89be76e5810.tar.gz
volse-hubzilla-0272ab4cd9a6428396489d88c7a1a89be76e5810.tar.bz2
volse-hubzilla-0272ab4cd9a6428396489d88c7a1a89be76e5810.zip
Provide a fallback channel to probe for magic-auth when we have no prior communications with a site.
This will be a system channel if one exists, otherwise any channel will do. We'll try to use the first valid channel on the site because that was probably created when the site was installed and is the closest thing to a system channel we've got.
-rwxr-xr-xboot.php6
-rw-r--r--mod/magic.php37
-rw-r--r--mod/zfinger.php32
-rw-r--r--version.inc2
-rw-r--r--view/css/mod_profiles.css6
-rwxr-xr-xview/tpl/profile_edit.tpl2
6 files changed, 61 insertions, 24 deletions
diff --git a/boot.php b/boot.php
index 4134ce3fa..0cde9419d 100755
--- a/boot.php
+++ b/boot.php
@@ -205,6 +205,7 @@ define ( 'PAGE_DIRECTORY_CHANNEL', 0x0008 ); // system channel used for director
define ( 'PAGE_PREMIUM', 0x0010 );
define ( 'PAGE_ADULT', 0x0020 );
+define ( 'PAGE_SYSTEM', 0x1000 );
define ( 'PAGE_REMOVED', 0x8000 );
@@ -367,6 +368,7 @@ define ( 'XCHAN_FLAGS_HIDDEN', 0x0001);
define ( 'XCHAN_FLAGS_ORPHAN', 0x0002);
define ( 'XCHAN_FLAGS_CENSORED', 0x0004);
define ( 'XCHAN_FLAGS_SELFCENSORED', 0x0008);
+define ( 'XCHAN_FLAGS_SYSTEM', 0x0010);
define ( 'XCHAN_FLAGS_DELETED', 0x1000);
/*
* Traficlights for Administration of HubLoc
@@ -478,8 +480,10 @@ define ( 'ACCOUNT_PENDING', 0x0010 );
* Account roles
*/
-define ( 'ACCOUNT_ROLE_ADMIN', 0x1000 );
define ( 'ACCOUNT_ROLE_ALLOWCODE', 0x0001 );
+define ( 'ACCOUNT_ROLE_SYSTEM', 0x0002 );
+
+define ( 'ACCOUNT_ROLE_ADMIN', 0x1000 );
/**
* Item visibility
diff --git a/mod/magic.php b/mod/magic.php
index 03d09e70d..aead559a7 100644
--- a/mod/magic.php
+++ b/mod/magic.php
@@ -33,21 +33,28 @@ function magic_init(&$a) {
if(! $x) {
- // Somebody new? Finger them if they've never been seen here before
-
- if($addr) {
- $ret = zot_finger($addr,null);
- if($ret['success']) {
- $j = json_decode($ret['body'],true);
- if($j)
- import_xchan($j);
-
- // Now try again
-
- $x = q("select * from hubloc where hubloc_url = '%s' order by hubloc_connected desc limit 1",
- dbesc($basepath)
- );
- }
+ /*
+ * We have no records for, or prior communications with this hub.
+ * If an address was supplied, let's finger them to create a hub record.
+ * Otherwise we'll use the special address '[system]' which will return
+ * either a system channel or the first available normal channel. We don't
+ * really care about what channel is returned - we need the hub information
+ * from that response so that we can create signed auth packets destined
+ * for that hub.
+ *
+ */
+
+ $ret = zot_finger((($addr) ? $addr : '[system]@' . $parsed['host']),null);
+ if($ret['success']) {
+ $j = json_decode($ret['body'],true);
+ if($j)
+ import_xchan($j);
+
+ // Now try again
+
+ $x = q("select * from hubloc where hubloc_url = '%s' order by hubloc_connected desc limit 1",
+ dbesc($basepath)
+ );
}
}
diff --git a/mod/zfinger.php b/mod/zfinger.php
index 0827f3424..aad8e224d 100644
--- a/mod/zfinger.php
+++ b/mod/zfinger.php
@@ -52,11 +52,33 @@ function zfinger_init(&$a) {
);
}
elseif(strlen($zaddr)) {
- $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
- where ( channel_address = '%s' or xchan_addr = '%s' ) limit 1",
- dbesc($zaddr),
- dbesc($zaddr)
- );
+ if(strpos($zaddr,'[system]') === false) { /* normal address lookup */
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
+ where ( channel_address = '%s' or xchan_addr = '%s' ) limit 1",
+ dbesc($zaddr),
+ dbesc($zaddr)
+ );
+ }
+
+ else {
+
+ /**
+ * The special address '[system]' will return a system channel if one has been defined,
+ * Or the first valid channel we find if there are no system channels.
+ *
+ * This is used by magic-auth if we have no prior communications with this site - and
+ * returns an identity on this site which we can use to create a valid hub record so that
+ * we can exchange signed messages. The precise identity is irrelevant. It's the hub
+ * information that we really need at the other end - and this will return it.
+ *
+ */
+
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
+ where (( channel_pageflags & %d ) or not ( channel_pageflags & %d )) order by channel_id limit 1",
+ intval(PAGE_SYSTEM),
+ intval(PAGE_REMOVED)
+ );
+ }
}
else {
$ret['message'] = 'Invalid request';
diff --git a/version.inc b/version.inc
index 2aa2a72b7..d967ddd6a 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2013-12-14.527
+2013-12-15.528
diff --git a/view/css/mod_profiles.css b/view/css/mod_profiles.css
index 8378245d2..6d935ee4d 100644
--- a/view/css/mod_profiles.css
+++ b/view/css/mod_profiles.css
@@ -35,9 +35,11 @@
margin-top: 10px;
}
-#profile-edit-with-label {
+#profile-edit-with-label, #profile-edit-howlong-label {
+
width: 175px;
- margin-left: 20px;
+ margin-left: 50px;
+ margin-bottom: 20px;
}
#profile-edit-profile-name-label,
diff --git a/view/tpl/profile_edit.tpl b/view/tpl/profile_edit.tpl
index 183389b9b..196b3ac6d 100755
--- a/view/tpl/profile_edit.tpl
+++ b/view/tpl/profile_edit.tpl
@@ -108,8 +108,10 @@
<label id="profile-edit-marital-label" for="profile-edit-marital" >{{$lbl_marital}} </label>
{{$marital}}
</div>
+<div class="clear"></div>
<label id="profile-edit-with-label" for="profile-edit-with" > {{$lbl_with}} </label>
<input type="text" size="32" name="with" id="profile-edit-with" title="{{$lbl_ex1}}" value="{{$with}}" />
+<div class="clear"></div>
<label id="profile-edit-howlong-label" for="profile-edit-howlong" > {{$lbl_howlong}} </label>
<input type="text" size="32" name="howlong" id="profile-edit-howlong" title="{{$lbl_howlong}}" value="{{$howlong}}" />