2011-10-09 19:12:16 +04:00
|
|
|
<?php
|
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-05-11 18:00:10 +04:00
|
|
|
$ownCloudDir = dirname(dirname(dirname(__FILE__)));
|
2012-03-28 18:07:50 +04:00
|
|
|
$docRoot = $_SERVER['DOCUMENT_ROOT'];
|
2012-03-30 23:35:09 +04:00
|
|
|
try {
|
2012-05-11 14:00:31 +04:00
|
|
|
$webRoot = substr(realpath($ownCloudDir), strlen(realpath($docRoot)));
|
2012-03-30 23:35:09 +04:00
|
|
|
} catch(Exception $e) {
|
2012-05-11 14:00:31 +04:00
|
|
|
// some servers fail on realpath(), let's try it the unsecure way:
|
|
|
|
$webRoot = substr($ownCloudDir, strlen($docRoot));
|
2012-03-28 18:07:50 +04:00
|
|
|
}
|
2012-03-30 23:35:09 +04:00
|
|
|
$serverName = $_SERVER['SERVER_NAME'];
|
|
|
|
$lrddTmpl = 'http';
|
|
|
|
if(isset($_SERVER['HTTPS'])) {
|
2012-05-11 14:00:31 +04:00
|
|
|
$lrddTmpl .= 's';
|
2012-03-30 23:35:09 +04:00
|
|
|
}
|
2012-05-11 12:26:30 +04:00
|
|
|
$lrddTmpl .= '://' . $serverName . $webRoot . '/public.php?service=webfinger&q={uri}';
|
2012-03-30 23:35:09 +04:00
|
|
|
$hostMetaPath = $docRoot . '/.well-known/host-meta';
|
2012-04-02 19:12:52 +04:00
|
|
|
$hostMetaDir = $docRoot . '/.well-known';
|
2012-05-11 14:00:31 +04:00
|
|
|
$hostMetaContents = "{\"links\":[{\"rel\":\"lrdd\",\"template\":\"http://mich.oc/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;
|