2011-10-09 19:12:16 +04:00
|
|
|
<?php
|
2012-08-10 12:01:17 +04:00
|
|
|
if (!OCP\App::isEnabled("user_webfinger")) {
|
|
|
|
return;
|
|
|
|
}
|
2012-07-16 21:56:43 +04:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-04-02 19:12:52 +04:00
|
|
|
$hostMetaHeader = array(
|
|
|
|
'Access-Control-Allow-Origin' => '*',
|
2012-05-11 17:27:11 +04:00
|
|
|
'Content-Type' => 'application/xrd+json'
|
2012-04-02 19:12:52 +04:00
|
|
|
);
|
2012-03-30 23:35:09 +04:00
|
|
|
$serverName = $_SERVER['SERVER_NAME'];
|
2012-07-16 21:56:43 +04:00
|
|
|
$hostMetaContents = '{"links":[{"rel":"lrdd","template":"http'.(isset($_SERVER['HTTPS'])?'s':'').'://'.$serverName.$WEBROOT.'/public.php?service=webfinger&q={uri}"}]}';
|
2012-04-02 19:12:52 +04:00
|
|
|
foreach($hostMetaHeader as $header => $value) {
|
2012-05-11 12:47:42 +04:00
|
|
|
header($header . ": " . $value);
|
2012-04-02 19:12:52 +04:00
|
|
|
}
|
2012-05-11 12:47:42 +04:00
|
|
|
echo $hostMetaContents;
|