improve webfinger for situations where owncloud is not installed in the server root
This commit is contained in:
parent
f047fdbfaa
commit
19f2ce6997
|
@ -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>
|
|
@ -1,10 +1,27 @@
|
||||||
<?php
|
<?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(
|
$hostMetaHeader = array(
|
||||||
'Access-Control-Allow-Origin' => '*',
|
'Access-Control-Allow-Origin' => '*',
|
||||||
'Content-Type' => 'application/xrd+json'
|
'Content-Type' => 'application/xrd+json'
|
||||||
);
|
);
|
||||||
$serverName = $_SERVER['SERVER_NAME'];
|
$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) {
|
foreach($hostMetaHeader as $header => $value) {
|
||||||
header($header . ": " . $value);
|
header($header . ": " . $value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue