nextcloud/apps/user_webfinger/host-meta.php

27 lines
959 B
PHP
Raw Normal View History

2011-10-09 19:12:16 +04:00
<?php
$hostMetaHeader = array(
'Access-Control-Allow-Origin' => '*',
2012-05-11 17:27:11 +04:00
'Content-Type' => 'application/xrd+json'
);
2012-05-11 18:00:10 +04:00
$ownCloudDir = dirname(dirname(dirname(__FILE__)));
$docRoot = $_SERVER['DOCUMENT_ROOT'];
try {
$webRoot = substr(realpath($ownCloudDir), strlen(realpath($docRoot)));
} catch(Exception $e) {
// some servers fail on realpath(), let's try it the unsecure way:
$webRoot = substr($ownCloudDir, strlen($docRoot));
}
$serverName = $_SERVER['SERVER_NAME'];
$lrddTmpl = 'http';
if(isset($_SERVER['HTTPS'])) {
$lrddTmpl .= 's';
}
$lrddTmpl .= '://' . $serverName . $webRoot . '/public.php?service=webfinger&q={uri}';
$hostMetaPath = $docRoot . '/.well-known/host-meta';
$hostMetaDir = $docRoot . '/.well-known';
$hostMetaContents = "{\"links\":[{\"rel\":\"lrdd\",\"template\":\"http://mich.oc/public.php?service=webfinger&q={uri}\"}]}";
foreach($hostMetaHeader as $header => $value) {
2012-05-11 12:47:42 +04:00
header($header . ": " . $value);
}
2012-05-11 12:47:42 +04:00
echo $hostMetaContents;