summaryrefslogtreecommitdiffstats
path: root/apps/user_webfinger/appinfo/install.php
diff options
context:
space:
mode:
authorFlorian Hülsmann <fh@cbix.de>2012-04-02 17:12:52 +0200
committerFlorian Hülsmann <fh@cbix.de>2012-04-02 17:12:52 +0200
commit33c1fa6e28bb592de8d81089b6d09ede928c9071 (patch)
tree51386b4b0b91da83ace6369541fb209a833452c2 /apps/user_webfinger/appinfo/install.php
parentf9f91a08b47c0a086c43966b1ecdf87185ceef83 (diff)
downloadnextcloud-server-33c1fa6e28bb592de8d81089b6d09ede928c9071.tar.gz
nextcloud-server-33c1fa6e28bb592de8d81089b6d09ede928c9071.zip
webfinger protocol compatible + minor changes
Diffstat (limited to 'apps/user_webfinger/appinfo/install.php')
-rw-r--r--apps/user_webfinger/appinfo/install.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/apps/user_webfinger/appinfo/install.php b/apps/user_webfinger/appinfo/install.php
index 678d57ae8f2..c8d9a427425 100644
--- a/apps/user_webfinger/appinfo/install.php
+++ b/apps/user_webfinger/appinfo/install.php
@@ -1,4 +1,8 @@
<?php
+$hostMetaHeader = array(
+ 'Access-Control-Allow-Origin' => '*',
+ 'Content-Type' => 'application/xml+xrd'
+);
$appInfoDir = __DIR__;
$thisAppDir = dirname($appInfoDir);
$appsDir = dirname($thisAppDir);
@@ -17,6 +21,7 @@ if(isset($_SERVER['HTTPS'])) {
}
$lrddTmpl .= '://' . $serverName . $webRoot . '/apps/user_webfinger/webfinger.php?q={uri}';
$hostMetaPath = $docRoot . '/.well-known/host-meta';
+$hostMetaDir = $docRoot . '/.well-known';
$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>
@@ -24,7 +29,7 @@ $hostMetaContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<Title>Resource Descriptor</Title>
</Link>
</XRD>";
-@mkdir(dirname($hostMetaPath));
+@mkdir($hostMetaDir);
$hostMeta = fopen($hostMetaPath, 'w');
if(!$hostMeta) {
die("Could not open " . $hostMetaPath . " for writing, please check permissions!");
@@ -33,3 +38,14 @@ if(!fwrite($hostMeta, $hostMetaContents, strlen($hostMetaContents))) {
die("Could not write to " . $hostMetaPath . ", please check permissions!");
}
fclose($hostMeta);
+
+// write custom headers into .htaccess:
+$htaccess = fopen($hostMetaDir . '/.htaccess', 'w');
+//TODO: check compatibility!
+fwrite($htaccess, "<filesMatch \"^host-meta$\">
+<ifModule mod_headers.c>\n");
+foreach($hostMetaHeader as $header => $value) {
+ fwrite($htaccess, "Header set " . $header . " \"" . $value . "\"\n");
+}
+fwrite($htaccess, "</ifModule>\n</filesMatch>");
+fclose($htaccess);