summaryrefslogtreecommitdiffstats
path: root/apps/user_webfinger
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-07-16 19:56:43 +0200
committerRobin Appelman <icewind@owncloud.com>2012-07-16 19:58:05 +0200
commit19f2ce69975ed63589eca461f88a46da2bf57625 (patch)
treea00acc02e145677d032a94b9e243e0e759bee3c5 /apps/user_webfinger
parentf047fdbfaa653a3f745d3911df125b02ecb2556c (diff)
downloadnextcloud-server-19f2ce69975ed63589eca461f88a46da2bf57625.tar.gz
nextcloud-server-19f2ce69975ed63589eca461f88a46da2bf57625.zip
improve webfinger for situations where owncloud is not installed in the server root
Diffstat (limited to 'apps/user_webfinger')
-rw-r--r--apps/user_webfinger/.htaccess5
-rw-r--r--apps/user_webfinger/host-meta.php19
2 files changed, 23 insertions, 1 deletions
diff --git a/apps/user_webfinger/.htaccess b/apps/user_webfinger/.htaccess
new file mode 100644
index 00000000000..1b13cf788ff
--- /dev/null
+++ b/apps/user_webfinger/.htaccess
@@ -0,0 +1,5 @@
+<IfModule mod_rewrite.c>
+RewriteEngine on
+RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
+RewriteRule ^host-meta host-meta.php [QSA,L]
+</IfModule>
diff --git a/apps/user_webfinger/host-meta.php b/apps/user_webfinger/host-meta.php
index 32ffb512057..4ac37b1ea09 100644
--- a/apps/user_webfinger/host-meta.php
+++ b/apps/user_webfinger/host-meta.php
@@ -1,10 +1,27 @@
<?php
+
+if(class_exists('OC')){
+ $WEBROOT=OC::$WEBROOT;
+}else{//not called trough remote.php try to guess the webroot the best we can from here
+ // calculate the root directories
+ $SERVERROOT=str_replace("\\",'/',substr(__FILE__,0,-strlen('apps/user_webfinger/host-meta.php')));
+ $WEBROOT=substr($SERVERROOT,strlen(realpath($_SERVER['DOCUMENT_ROOT'])));
+
+ if($WEBROOT!='' and $WEBROOT[0]!=='/'){
+ $WEBROOT='/'.$WEBROOT;
+ }
+}
+
+if(substr($WEBROOT,-1)==='/'){
+ $WEBROOT=substr($WEBROOT,0,-1);
+}
+
$hostMetaHeader = array(
'Access-Control-Allow-Origin' => '*',
'Content-Type' => 'application/xrd+json'
);
$serverName = $_SERVER['SERVER_NAME'];
-$hostMetaContents = '{"links":[{"rel":"lrdd","template":"http'.(isset($_SERVER['HTTPS'])?'s':'').'://'.$serverName.'/public.php?service=webfinger&q={uri}"}]}';
+$hostMetaContents = '{"links":[{"rel":"lrdd","template":"http'.(isset($_SERVER['HTTPS'])?'s':'').'://'.$serverName.$WEBROOT.'/public.php?service=webfinger&q={uri}"}]}';
foreach($hostMetaHeader as $header => $value) {
header($header . ": " . $value);
}