diff --git a/apps/user_webfinger/.htaccess b/apps/user_webfinger/.htaccess new file mode 100644 index 0000000000000000000000000000000000000000..1b13cf788ffb3c5b25c02353819c6be516ee48e0 --- /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 32ffb512057f83237cd00463f6faa62807d01251..4ac37b1ea0922d0a319b7321afd9bb0d0a6b6112 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); }