2017-02-10 20:45:22 +00:00
|
|
|
<?php
|
|
|
|
|
2017-04-30 04:07:00 +00:00
|
|
|
use Friendica\App;
|
2017-04-30 04:01:26 +00:00
|
|
|
use Friendica\Core\Config;
|
2017-02-10 20:45:22 +00:00
|
|
|
|
|
|
|
require_once("mod/hostxrd.php");
|
|
|
|
require_once("mod/nodeinfo.php");
|
2017-08-22 10:18:07 +00:00
|
|
|
require_once("mod/xrd.php");
|
2017-02-10 20:45:22 +00:00
|
|
|
|
2018-01-05 00:42:48 +00:00
|
|
|
function _well_known_init(App $a)
|
|
|
|
{
|
2017-02-10 20:45:22 +00:00
|
|
|
if ($a->argc > 1) {
|
2018-01-05 00:42:48 +00:00
|
|
|
switch ($a->argv[1]) {
|
2017-02-10 20:45:22 +00:00
|
|
|
case "host-meta":
|
|
|
|
hostxrd_init($a);
|
|
|
|
break;
|
|
|
|
case "x-social-relay":
|
2018-01-05 00:42:48 +00:00
|
|
|
wk_social_relay();
|
2017-02-10 20:45:22 +00:00
|
|
|
break;
|
|
|
|
case "nodeinfo":
|
|
|
|
nodeinfo_wellknown($a);
|
|
|
|
break;
|
2017-08-22 10:18:07 +00:00
|
|
|
case "webfinger":
|
|
|
|
xrd_init($a);
|
|
|
|
break;
|
2017-02-10 20:45:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
http_status_exit(404);
|
|
|
|
killme();
|
|
|
|
}
|
|
|
|
|
2018-01-05 00:42:48 +00:00
|
|
|
function wk_social_relay()
|
|
|
|
{
|
|
|
|
$subscribe = (bool) Config::get('system', 'relay_subscribe', false);
|
2017-02-10 20:45:22 +00:00
|
|
|
|
|
|
|
if ($subscribe) {
|
|
|
|
$scope = Config::get('system', 'relay_scope', SR_SCOPE_ALL);
|
|
|
|
} else {
|
|
|
|
$scope = SR_SCOPE_NONE;
|
|
|
|
}
|
|
|
|
|
2018-01-15 13:05:12 +00:00
|
|
|
$tags = [];
|
2017-02-10 20:45:22 +00:00
|
|
|
|
|
|
|
if ($scope == SR_SCOPE_TAGS) {
|
|
|
|
$server_tags = Config::get('system', 'relay_server_tags');
|
|
|
|
$tagitems = explode(",", $server_tags);
|
|
|
|
|
2018-01-05 00:42:48 +00:00
|
|
|
foreach ($tagitems AS $tag) {
|
2017-02-10 20:45:22 +00:00
|
|
|
$tags[trim($tag, "# ")] = trim($tag, "# ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Config::get('system', 'relay_user_tags')) {
|
|
|
|
$terms = q("SELECT DISTINCT(`term`) FROM `search`");
|
|
|
|
|
2018-01-05 00:42:48 +00:00
|
|
|
foreach ($terms AS $term) {
|
2017-02-10 20:45:22 +00:00
|
|
|
$tag = trim($term["term"], "#");
|
|
|
|
$tags[$tag] = $tag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-15 13:05:12 +00:00
|
|
|
$taglist = [];
|
2018-01-05 00:42:48 +00:00
|
|
|
foreach ($tags AS $tag) {
|
2017-02-10 20:45:22 +00:00
|
|
|
$taglist[] = $tag;
|
|
|
|
}
|
|
|
|
|
2018-01-15 13:05:12 +00:00
|
|
|
$relay = [
|
2018-01-05 00:42:48 +00:00
|
|
|
"subscribe" => $subscribe,
|
|
|
|
"scope" => $scope,
|
|
|
|
"tags" => $taglist
|
2018-01-15 13:05:12 +00:00
|
|
|
];
|
2017-02-10 20:45:22 +00:00
|
|
|
|
|
|
|
header('Content-type: application/json; charset=utf-8');
|
2018-01-05 00:42:48 +00:00
|
|
|
echo json_encode($relay, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
2017-02-10 20:45:22 +00:00
|
|
|
exit;
|
|
|
|
}
|