X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2F_well_known.php;h=407fc756a931fef7cfe0a39adc79816def46b1b6;hb=050ad68b9fc21fc5cf06153d2c6d161d30b241c6;hp=45c1da494cc785da79f753ea3546a6705c1847ff;hpb=86cae070f2a048e553c545caec54be72c1c14da5;p=friendica.git diff --git a/mod/_well_known.php b/mod/_well_known.php index 45c1da494c..407fc756a9 100644 --- a/mod/_well_known.php +++ b/mod/_well_known.php @@ -2,31 +2,37 @@ use Friendica\App; use Friendica\Core\Config; +use Friendica\Core\System; -require_once("mod/hostxrd.php"); -require_once("mod/nodeinfo.php"); +require_once 'mod/hostxrd.php'; +require_once 'mod/nodeinfo.php'; +require_once 'mod/xrd.php'; -function _well_known_init(App $a) { +function _well_known_init(App $a) +{ if ($a->argc > 1) { - switch($a->argv[1]) { + switch ($a->argv[1]) { case "host-meta": hostxrd_init($a); break; case "x-social-relay": - wk_social_relay($a); + wk_social_relay(); break; case "nodeinfo": nodeinfo_wellknown($a); break; + case "webfinger": + xrd_init($a); + break; } } - http_status_exit(404); + System::httpExit(404); killme(); } -function wk_social_relay(App $a) { - - $subscribe = (bool)Config::get('system', 'relay_subscribe', false); +function wk_social_relay() +{ + $subscribe = (bool) Config::get('system', 'relay_subscribe', false); if ($subscribe) { $scope = Config::get('system', 'relay_scope', SR_SCOPE_ALL); @@ -34,36 +40,44 @@ function wk_social_relay(App $a) { $scope = SR_SCOPE_NONE; } - $tags = array(); + $tags = []; if ($scope == SR_SCOPE_TAGS) { $server_tags = Config::get('system', 'relay_server_tags'); $tagitems = explode(",", $server_tags); - foreach($tagitems AS $tag) { - $tags[trim($tag, "# ")] = trim($tag, "# "); + /// @todo Check if it was better to use "strtolower" on the tags + foreach ($tagitems AS $tag) { + $tag = trim($tag, "# "); + $tags[$tag] = $tag; } if (Config::get('system', 'relay_user_tags')) { $terms = q("SELECT DISTINCT(`term`) FROM `search`"); - foreach($terms AS $term) { + foreach ($terms AS $term) { $tag = trim($term["term"], "#"); $tags[$tag] = $tag; } } } - $taglist = array(); - foreach($tags AS $tag) { - $taglist[] = $tag; + $taglist = []; + foreach ($tags AS $tag) { + if (!empty($tag)) { + $taglist[] = $tag; + } } - $relay = array("subscribe" => $subscribe, - "scope" => $scope, - "tags" => $taglist); + $relay = [ + 'subscribe' => $subscribe, + 'scope' => $scope, + 'tags' => $taglist, + 'protocols' => ['diaspora' => ['receive' => System::baseUrl() . '/receive/public'], + 'dfrn' => ['receive' => System::baseUrl() . '/dfrn_notify']] + ]; header('Content-type: application/json; charset=utf-8'); - echo json_encode($relay, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES); + echo json_encode($relay, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); exit; }