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