2011-10-09 19:12:16 +04:00
|
|
|
<?php
|
2012-04-02 19:12:52 +04:00
|
|
|
$hostMetaHeader = array(
|
|
|
|
'Access-Control-Allow-Origin' => '*',
|
|
|
|
'Content-Type' => 'application/xml+xrd'
|
|
|
|
);
|
2011-10-09 19:12:16 +04:00
|
|
|
$ownCloudDir = dirname($appsDir);
|
2012-03-28 18:07:50 +04:00
|
|
|
$docRoot = $_SERVER['DOCUMENT_ROOT'];
|
2012-03-30 23:35:09 +04:00
|
|
|
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));
|
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'])) {
|
|
|
|
$lrddTmpl .= 's';
|
|
|
|
}
|
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-03-30 23:35:09 +04:00
|
|
|
$hostMetaContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
|
|
|
<XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\" xmlns:hm=\"http://host-meta.net/xrd/1.0\">
|
|
|
|
<hm:Host xmlns=\"http://host-meta.net/xrd/1.0\">" . $serverName . "</hm:Host>
|
|
|
|
<Link rel=\"lrdd\" template=\"" . $lrddTmpl . "\">
|
|
|
|
<Title>Resource Descriptor</Title>
|
|
|
|
</Link>
|
|
|
|
</XRD>";
|
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;
|