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