diff options
author | Florian Hülsmann <fh@cbix.de> | 2012-03-30 21:35:09 +0200 |
---|---|---|
committer | Florian Hülsmann <fh@cbix.de> | 2012-03-30 21:35:09 +0200 |
commit | 5161758921efb5bb50e579d8e6debfa93e595a7d (patch) | |
tree | 7dcec30511f04ffa99f3fa9b00f951b2a74cc5c1 /apps/user_webfinger | |
parent | 34a0128ddf01a44302f89a1dfa14bb9565a8ae47 (diff) | |
download | nextcloud-server-5161758921efb5bb50e579d8e6debfa93e595a7d.tar.gz nextcloud-server-5161758921efb5bb50e579d8e6debfa93e595a7d.zip |
create static host-meta instead of symlink and .htaccess
Diffstat (limited to 'apps/user_webfinger')
-rw-r--r-- | apps/user_webfinger/appinfo/install.php | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/apps/user_webfinger/appinfo/install.php b/apps/user_webfinger/appinfo/install.php index 775141dce41..678d57ae8f2 100644 --- a/apps/user_webfinger/appinfo/install.php +++ b/apps/user_webfinger/appinfo/install.php @@ -4,33 +4,32 @@ $thisAppDir = dirname($appInfoDir); $appsDir = dirname($thisAppDir); $ownCloudDir = dirname($appsDir); $docRoot = $_SERVER['DOCUMENT_ROOT']; -if(file_exists($docRoot . '/.well-known/host-meta')) { - OC_Log::write( - 'user_webfinger', - $docRoot . "/.well-known already exists; installation aborted", - OC_Log::ERROR - ); -} else { - if(@symlink($thisAppDir, $docRoot . '/.well-known')) { - OC_Log::write( - 'user_webfinger', - "Webfinger symlink created at " . $docRoot . "/.well-known", - OC_Log::INFO - ); - } else { - if(@symlink($thisAppDir, $ownCloudDir . '/.well-known')) { - OC_Log::write( - 'user_webfinger', - "Couldn't create webfinger symlink in document root, linked to " . $ownCloudDir . "/.well-known instead", - OC_Log::WARN - ); - } else { - OC_Log::write( - 'user_webfinger', - "Couldn't create webfinger symlink, either check write permissions or create the link manually!", - OC_Log::ERROR - ); - } - } +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 . '/apps/user_webfinger/webfinger.php?q={uri}'; +$hostMetaPath = $docRoot . '/.well-known/host-meta'; +$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>"; +@mkdir(dirname($hostMetaPath)); +$hostMeta = fopen($hostMetaPath, 'w'); +if(!$hostMeta) { + die("Could not open " . $hostMetaPath . " for writing, please check permissions!"); +} +if(!fwrite($hostMeta, $hostMetaContents, strlen($hostMetaContents))) { + die("Could not write to " . $hostMetaPath . ", please check permissions!"); +} +fclose($hostMeta); |