Blame view

sources/apps/user_webfinger/host-meta.php 977 Bytes
42e4f8d60   Kload   add all apps
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  <?php
  if (!OCP\App::isEnabled("user_webfinger")) {
  	return;
  }
  
  if(class_exists('OC')) {
  	$WEBROOT=OC::$WEBROOT;
  }else{//not called trough remote.php try to guess the webroot the best we can from here
  	// calculate the root directories
  	$SERVERROOT=str_replace("\\",'/',substr(__FILE__,0,-strlen('apps/user_webfinger/host-meta.php')));
  	$WEBROOT=substr($SERVERROOT,strlen(realpath($_SERVER['DOCUMENT_ROOT'])));
  
  	if($WEBROOT!='' and $WEBROOT[0]!=='/') {
  		$WEBROOT='/'.$WEBROOT;
  	}
  }
  
  if(substr($WEBROOT,-1)==='/') {
  	$WEBROOT=substr($WEBROOT,0,-1);
  }
  
  $hostMetaHeader = array(
  	'Access-Control-Allow-Origin' => '*',
  	'Content-Type' => 'application/xrd+json'
  );
  $serverName = $_SERVER['SERVER_NAME'];
  $hostMetaContents = '{"links":[{"rel":"lrdd","template":"http'.(isset($_SERVER['HTTPS'])?'s':'').'://'.$serverName.$WEBROOT.'/public.php?service=webfinger&q={uri}"}]}';
  foreach($hostMetaHeader as $header => $value) {
  	header($header . ": " . $value);
  }
  echo $hostMetaContents;