diff options
author | friendica <info@friendica.com> | 2013-03-04 20:58:39 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2013-03-04 20:58:39 -0800 |
commit | 8d442e6fc1364ea351a9b781e8173c1b679b7a91 (patch) | |
tree | 39703e3d5750e13d666cabbbe3f21125284b9c40 /mod | |
parent | 4cfbdfa6dbed878565bab5172efaf67c8fda0886 (diff) | |
download | volse-hubzilla-8d442e6fc1364ea351a9b781e8173c1b679b7a91.tar.gz volse-hubzilla-8d442e6fc1364ea351a9b781e8173c1b679b7a91.tar.bz2 volse-hubzilla-8d442e6fc1364ea351a9b781e8173c1b679b7a91.zip |
fix timeago (again), webfinger new spec implemented, some theme work
Diffstat (limited to 'mod')
-rw-r--r-- | mod/_well_known.php | 8 | ||||
-rw-r--r-- | mod/follow.php | 8 | ||||
-rw-r--r-- | mod/wfinger.php | 101 |
3 files changed, 116 insertions, 1 deletions
diff --git a/mod/_well_known.php b/mod/_well_known.php index 5c5f6585f..184f75593 100644 --- a/mod/_well_known.php +++ b/mod/_well_known.php @@ -17,6 +17,14 @@ function _well_known_init(&$a){ zfinger_init($a);
break;
+ case 'webfinger':
+ $a->argc -= 1;
+ array_shift($a->argv);
+ $a->argv[0] = 'wfinger';
+ require_once('mod/wfinger.php');
+ wfinger_init($a);
+ break;
+
}
}
diff --git a/mod/follow.php b/mod/follow.php index c07c210f6..05a12d0f0 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -6,7 +6,6 @@ require_once('include/follow.php'); function follow_init(&$a) { if(! local_user()) { - notice( t('Permission denied.') . EOL); return; } @@ -27,3 +26,10 @@ function follow_init(&$a) { goaway(z_root() . '/connections/' . $result['abook']['abook_id']); } + +functon follow_content(&$a) { + + if(! local_user()) { + return login(); + } +}
\ No newline at end of file diff --git a/mod/wfinger.php b/mod/wfinger.php new file mode 100644 index 000000000..3fda96181 --- /dev/null +++ b/mod/wfinger.php @@ -0,0 +1,101 @@ +<?php + +function wfinger_init(&$a) { + + $result = array(); + + $scheme = ''; + + if(x($_SERVER,'HTTPS') && $_SERVER['HTTPS']) + $scheme = 'https'; + elseif(x($_SERVER,'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) + $scheme = 'https'; + + // Don't complain to me - I'm just implementing the spec. + + if($scheme !== 'https') { + header($_SERVER["SERVER_PROTOCOL"] . ' ' . 500 . ' ' . 'Webfinger requires HTTPS'); + killme(); + } + + $resource = $_REQUEST['resource']; + + header('Access-Control-Allow-Origin: *'); + + header('Content-type: application/jrd+json'); + + $pubkey = get_config('system','site_pubkey'); + + $r = null; + + if($resource) { + + if(strpos($resource,'acct:') === 0) { + $channel = str_replace('acct:','',$resource); + $channel = substr($channel,0,strpos($channel,'@')); + } + if(strpos($resource,'http') === 0) { + $channel = str_replace('~','',basename($resource)); + } + + $r = q("select * from channel left join xchan on channel_hash = xchan_hash + where channel_address = '%s' limit 1", + dbesc($channel) + ); + + } + + if($resource && $r) { + + $result['subject'] = $resource; + + $aliases = array( + 'acct:' . $r[0]['channel_address'] . '@' . $a->get_hostname(), + z_root() . '/channel/' . $r[0]['channel_address'], + z_root() . '/~' . $r[0]['channel_address'] + ); + + $result['aliases'] = array(); + + foreach($aliases as $alias) + if($alias != $resource) + $result['aliases'][] = $alias; + + + $result['links'] = array( + + array( + 'rel' => 'http://webfinger.example/rel/avatar', + 'type' => $r[0]['xchan_photo_mimetype'], + 'href' => $r[0]['xchan_photo_l'] + ), + + array( + 'rel' => 'http://webfinger.example/rel/profile-page', + 'href' => z_root() . '/profile/' . $r[0]['channel_address'], + ), + + array( + 'rel' => 'http://webfinger.example/rel/blog', + 'href' => z_root() . '/channel/' . $r[0]['channel_address'], + ), + + array( + 'rel' => 'http://purl.org/zot/protocol', + 'href' => z_root() . '/well-known/zot-info' . '?zaddr=' . $r[0]['xchan_addr'], + ) + ); + + } + else { + header($_SERVER["SERVER_PROTOCOL"] . ' ' . 400 . ' ' . 'Bad Request'); + killme(); + } + + $arr = array('channel' => $r[0], 'request' => $_REQUEST, 'result' => $result); + call_hooks('webfinger',$arr); + + echo json_encode($arr['result']); + killme(); + +}
\ No newline at end of file |