]> git.mxchange.org Git - friendica.git/commitdiff
added webfinger support
authorMike Macgirvin <mike@macgirvin.com>
Fri, 23 Jul 2010 23:33:34 +0000 (16:33 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Fri, 23 Jul 2010 23:33:34 +0000 (16:33 -0700)
boot.php
include/hostxrd.php [new file with mode: 0644]
mod/xrd.php [new file with mode: 0644]
view/xrd_host.tpl [new file with mode: 0644]
view/xrd_person.tpl [new file with mode: 0644]

index b36a255eb4c28b3d8b26604944f2ecdd78e4dfb1..8d2628845ad224b694398731d3e7170dd1f603ac 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -73,6 +73,10 @@ class App {
                else {
                        $this->module = 'home';
                }
+
+               if($this->cmd == '.well-known/host-meta')
+                       require_once('include/hostxrd.php');
+
                $this->pager['page'] = ((x($_GET,'page')) ? $_GET['page'] : 1);
                $this->pager['itemspage'] = 50;
                $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
diff --git a/include/hostxrd.php b/include/hostxrd.php
new file mode 100644 (file)
index 0000000..3279cea
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+
+       $tpl = file_get_contents('view/xrd_host.tpl');
+       echo str_replace('$domain',$this->hostname,$tpl);
+       session_write_close();
+       exit();
diff --git a/mod/xrd.php b/mod/xrd.php
new file mode 100644 (file)
index 0000000..5d43147
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+
+function xrd_content(&$a) {
+
+       $uri = notags(trim($_GET['uri']));
+       $local = str_replace('acct:', '', $uri);
+       $name = substr($local,0,strpos($local,'@'));
+
+       $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
+               dbesc($name)
+       );
+       if(! count($r))
+               killme();
+
+       $tpl = file_get_contents('view/xrd_person.tpl');
+
+       $o = replace_macros($tpl, array(
+               '$accturi' => $uri,
+               '$profile_url' => $a->get_baseurl() . '/profile/' . $r[0]['nickname'],
+               '$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid']
+       ));
+
+       echo $o;
+       killme();
+
+}
\ No newline at end of file
diff --git a/view/xrd_host.tpl b/view/xrd_host.tpl
new file mode 100644 (file)
index 0000000..091c154
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
+     xmlns:hm='http://host-meta.net/xrd/1.0'>
+    <hm:Host>$domain</hm:Host>
+    <Link rel='lrdd'
+          template='http://$domain/xrd/?uri={uri}'>
+        <Title>Resource Descriptor</Title>
+    </Link>
+</XRD>
diff --git a/view/xrd_person.tpl b/view/xrd_person.tpl
new file mode 100644 (file)
index 0000000..acf3c4c
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
+    <Subject>$accturi</Subject>
+    <Alias>$profile_url</Alias>
+    <Link rel='http://portablecontacts.net/spec/1.0'
+          href='http://example.com/api/people/' />
+    <Link rel='http://webfinger.net/rel/profile-page'
+          type='text/html'
+          href='$profile_url' />
+    <Link rel='http://microformats.org/profile/hcard'
+          type='text/html'
+          href='$profile_url' />
+    <Link rel='http://webfinger.net/rel/avatar'
+          href='$photo' />
+</XRD>