improve webfinger for situations where owncloud is not installed in the server root

This commit is contained in:
Robin Appelman 2012-07-16 19:56:43 +02:00
parent f047fdbfaa
commit 19f2ce6997
2 changed files with 23 additions and 1 deletions

View File

@ -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>

View File

@ -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);
}