2011-09-12 02:12:34 +04:00
|
|
|
<?php
|
2012-03-31 04:42:41 +04:00
|
|
|
header("Access-Control-Allow-Origin: *");
|
2012-05-11 17:26:45 +04:00
|
|
|
header("Content-Type: application/xrd+json");
|
2011-11-03 16:09:44 +04:00
|
|
|
|
2012-03-31 04:42:41 +04:00
|
|
|
/**
|
|
|
|
* To include your app in the webfinger XML, add a new script with file name
|
|
|
|
* 'webfinger.php' to /apps/yourapp/appinfo/, which prints out the XML parts
|
|
|
|
* to be included. That script can make use of the constants WF_USER (e. g.
|
2012-04-02 19:12:52 +04:00
|
|
|
* "user"), WF_ID (user@host) and WF_BASEURL (e. g. https://host/owncloud).
|
2012-03-31 04:42:41 +04:00
|
|
|
* An example could look like this:
|
|
|
|
*
|
|
|
|
* <Link
|
|
|
|
* rel="myProfile"
|
|
|
|
* type="text/html"
|
2012-04-02 19:12:52 +04:00
|
|
|
* href="<?php echo WF_BASEURL; ?>/apps/myApp/profile.php?user=<?php echo WF_USER; ?>">
|
2012-03-31 04:42:41 +04:00
|
|
|
* </Link>
|
|
|
|
*
|
|
|
|
'* but can also use complex database queries to generate the webfinger result
|
|
|
|
**/
|
2011-09-12 02:12:34 +04:00
|
|
|
|
2012-05-07 11:46:15 +04:00
|
|
|
$userName = '';
|
|
|
|
$hostName = '';
|
2012-05-07 11:26:54 +04:00
|
|
|
$request = strip_tags(urldecode($_GET['q']));
|
2011-09-12 02:12:34 +04:00
|
|
|
if($_GET['q']) {
|
2012-04-02 19:12:52 +04:00
|
|
|
$reqParts = explode('@', $request);
|
2012-05-07 11:46:15 +04:00
|
|
|
if(count($reqParts)==2) {
|
2012-05-07 11:51:37 +04:00
|
|
|
$userName = $reqParts[0];
|
|
|
|
$hostName = $reqParts[1];
|
|
|
|
}
|
2011-09-12 02:12:34 +04:00
|
|
|
}
|
|
|
|
if(substr($userName, 0, 5) == 'acct:') {
|
|
|
|
$userName = substr($userName, 5);
|
|
|
|
}
|
2012-04-02 19:12:52 +04:00
|
|
|
if($userName == "") {
|
|
|
|
$id = "";
|
|
|
|
} else {
|
|
|
|
$id = $userName . '@' . $hostName;
|
|
|
|
}
|
2012-02-22 22:04:21 +04:00
|
|
|
if(isset($_SERVER['HTTPS'])) {
|
2012-03-31 04:42:41 +04:00
|
|
|
$baseAddress = 'https://';
|
2011-12-07 18:51:47 +04:00
|
|
|
} else {
|
2012-03-31 04:42:41 +04:00
|
|
|
$baseAddress = 'http://';
|
2011-12-07 18:51:47 +04:00
|
|
|
}
|
2012-03-31 04:42:41 +04:00
|
|
|
$baseAddress .= $_SERVER['SERVER_NAME'].OC::$WEBROOT;
|
2012-05-07 13:15:24 +04:00
|
|
|
if(empty($id)) {
|
|
|
|
header("HTTP/1.0 400 Bad Request");
|
|
|
|
}
|
2012-03-31 04:42:41 +04:00
|
|
|
define('WF_USER', $userName);
|
2012-04-02 19:12:52 +04:00
|
|
|
define('WF_ID', $id);
|
|
|
|
define('WF_BASEURL', $baseAddress);
|
2012-05-11 17:26:45 +04:00
|
|
|
echo "{\"links\":[";
|
2012-03-31 04:42:41 +04:00
|
|
|
$apps = OC_Appconfig::getApps();
|
|
|
|
foreach($apps as $app) {
|
2012-05-02 02:50:26 +04:00
|
|
|
if(OCP\App::isEnabled($app)) {
|
2012-06-05 00:37:00 +04:00
|
|
|
if(is_file(OC_App::getAppPath($app). '/appinfo/webfinger.php')) {
|
2012-03-31 04:42:41 +04:00
|
|
|
require($app . '/appinfo/webfinger.php');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-05-11 17:26:45 +04:00
|
|
|
echo "]}";
|