aboutsummaryrefslogtreecommitdiffstats
path: root/include/zot.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-10-31 20:53:02 -0700
committerfriendica <info@friendica.com>2012-10-31 20:53:02 -0700
commit78f64c90a353606b0a46185d07e65359eebe99ad (patch)
tree76c60d477394a170a80ac09d3abdb84550ea45b0 /include/zot.php
parent0dd06b736a227196154332168d29f6c807819a83 (diff)
downloadvolse-hubzilla-78f64c90a353606b0a46185d07e65359eebe99ad.tar.gz
volse-hubzilla-78f64c90a353606b0a46185d07e65359eebe99ad.tar.bz2
volse-hubzilla-78f64c90a353606b0a46185d07e65359eebe99ad.zip
get permission discovery working - guid sigs were getting truncated in db
Diffstat (limited to 'include/zot.php')
-rw-r--r--include/zot.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/include/zot.php b/include/zot.php
index c9fd25de4..6d48f1e7c 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -72,6 +72,57 @@ function zot_notify($channel,$url) {
return($x);
}
+function zot_finger($webbie,$channel) {
+
+ if(strpos($webbie,'@') === false) {
+ $address = $webbie;
+ $host = get_app()->get_hostname();
+ }
+ else {
+ $address = substr($webbie,0,strpos($webbie,'@'));
+ $host = substr($webbie,strpos($webbie,'@')+1);
+ }
+
+ $xchan_addr = $address . '@' . $host;
+
+ $r = q("select xchan.*, hubloc.* from xchan
+ left join hubloc on xchan_hash = hubloc_hash
+ where xchan_addr = '%s' and (hubloc_flags & %d) limit 1",
+ dbesc($xchan_address),
+ intval(HUBLOC_FLAGS_PRIMARY)
+ );
+
+ if($r) {
+ $url = $r[0]['hubloc_url'];
+ }
+ else {
+ $url = 'https://' . $host;
+ }
+
+ $rhs = '/.well-known/zot-guid';
+
+ if($channel) {
+ $postvars = array(
+ 'address' => $address,
+ 'target' => $channel['channel_guid'],
+ 'target_sig' => $channel['channel_guid_sig']
+ );
+ $result = z_post_url($url . $rhs,$postvars);
+ if(! $result['success'])
+ $result = z_post_url('http://' . $host . $rhs,$postvars);
+ }
+ else {
+ $rhs .= 'address=' . urlencode($address);
+
+ $result = z_fetch_url($url . $rhs);
+ if(! $result['success'])
+ $result = z_fetch_url('http://' . $host . $rhs);
+ }
+
+ return $result;
+
+}
+
function zot_gethub($arr) {