2012-07-27 14:58:27 +02:00
|
|
|
<?php
|
2012-12-28 22:51:50 +01:00
|
|
|
require_once("mod/hostxrd.php");
|
2015-08-10 21:33:57 +02:00
|
|
|
require_once("mod/nodeinfo.php");
|
2012-07-27 14:58:27 +02:00
|
|
|
|
2016-02-05 21:52:39 +01:00
|
|
|
if(! function_exists('_well_known_init')) {
|
2012-07-27 14:58:27 +02:00
|
|
|
function _well_known_init(&$a){
|
2015-08-09 08:31:42 +02:00
|
|
|
if ($a->argc > 1) {
|
|
|
|
switch($a->argv[1]) {
|
|
|
|
case "host-meta":
|
|
|
|
hostxrd_init($a);
|
|
|
|
break;
|
|
|
|
case "x-social-relay":
|
|
|
|
wk_social_relay($a);
|
|
|
|
break;
|
2015-08-10 21:33:57 +02:00
|
|
|
case "nodeinfo":
|
|
|
|
nodeinfo_wellknown($a);
|
|
|
|
break;
|
2015-08-09 08:31:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
http_status_exit(404);
|
|
|
|
killme();
|
|
|
|
}
|
2016-02-05 21:52:39 +01:00
|
|
|
}
|
2015-08-09 08:31:42 +02:00
|
|
|
|
2016-02-05 21:52:39 +01:00
|
|
|
if(! function_exists('wk_social_relay')) {
|
2015-08-09 08:31:42 +02:00
|
|
|
function wk_social_relay(&$a) {
|
|
|
|
|
|
|
|
define('SR_SCOPE_ALL', 'all');
|
|
|
|
define('SR_SCOPE_TAGS', 'tags');
|
|
|
|
|
2015-08-09 20:39:11 +02:00
|
|
|
$subscribe = (bool)get_config('system', 'relay_subscribe');
|
|
|
|
|
|
|
|
if ($subscribe)
|
|
|
|
$scope = get_config('system', 'relay_scope');
|
|
|
|
else
|
|
|
|
$scope = "";
|
2015-08-09 08:31:42 +02:00
|
|
|
|
|
|
|
$tags = array();
|
|
|
|
|
|
|
|
if ($scope == SR_SCOPE_TAGS) {
|
|
|
|
|
2015-08-09 20:39:11 +02:00
|
|
|
$server_tags = get_config('system', 'relay_server_tags');
|
|
|
|
$tagitems = explode(",", $server_tags);
|
|
|
|
|
|
|
|
foreach($tagitems AS $tag)
|
|
|
|
$tags[trim($tag, "# ")] = trim($tag, "# ");
|
|
|
|
|
|
|
|
if (get_config('system', 'relay_user_tags')) {
|
|
|
|
$terms = q("SELECT DISTINCT(`term`) FROM `search`");
|
|
|
|
|
|
|
|
foreach($terms AS $term) {
|
|
|
|
$tag = trim($term["term"], "#");
|
|
|
|
$tags[$tag] = $tag;
|
|
|
|
}
|
2015-08-09 08:31:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-09 20:39:11 +02:00
|
|
|
$taglist = array();
|
|
|
|
foreach($tags AS $tag)
|
|
|
|
$taglist[] = $tag;
|
|
|
|
|
2015-08-09 08:31:42 +02:00
|
|
|
$relay = array("subscribe" => $subscribe,
|
|
|
|
"scope" => $scope,
|
2015-08-09 20:39:11 +02:00
|
|
|
"tags" => $taglist);
|
2015-08-09 08:31:42 +02:00
|
|
|
|
|
|
|
header('Content-type: application/json; charset=utf-8');
|
2015-08-10 21:54:57 +02:00
|
|
|
echo json_encode($relay, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
2015-08-09 08:31:42 +02:00
|
|
|
exit;
|
2012-12-28 22:51:50 +01:00
|
|
|
}
|
2016-02-05 21:52:39 +01:00
|
|
|
}
|