2012-07-27 08:58:27 -04:00
|
|
|
<?php
|
2012-12-28 16:51:50 -05:00
|
|
|
require_once("mod/hostxrd.php");
|
2015-08-10 15:33:57 -04:00
|
|
|
require_once("mod/nodeinfo.php");
|
2012-07-27 08:58:27 -04:00
|
|
|
|
|
|
|
function _well_known_init(&$a){
|
2015-08-09 02:31:42 -04: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 15:33:57 -04:00
|
|
|
case "nodeinfo":
|
|
|
|
nodeinfo_wellknown($a);
|
|
|
|
break;
|
2015-08-09 02:31:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
http_status_exit(404);
|
|
|
|
killme();
|
|
|
|
}
|
|
|
|
|
|
|
|
function wk_social_relay(&$a) {
|
|
|
|
|
|
|
|
define('SR_SCOPE_ALL', 'all');
|
|
|
|
define('SR_SCOPE_TAGS', 'tags');
|
|
|
|
|
2015-08-09 14:39:11 -04:00
|
|
|
$subscribe = (bool)get_config('system', 'relay_subscribe');
|
|
|
|
|
|
|
|
if ($subscribe)
|
|
|
|
$scope = get_config('system', 'relay_scope');
|
|
|
|
else
|
|
|
|
$scope = "";
|
2015-08-09 02:31:42 -04:00
|
|
|
|
|
|
|
$tags = array();
|
|
|
|
|
|
|
|
if ($scope == SR_SCOPE_TAGS) {
|
|
|
|
|
2015-08-09 14:39:11 -04: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 02:31:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-09 14:39:11 -04:00
|
|
|
$taglist = array();
|
|
|
|
foreach($tags AS $tag)
|
|
|
|
$taglist[] = $tag;
|
|
|
|
|
2015-08-09 02:31:42 -04:00
|
|
|
$relay = array("subscribe" => $subscribe,
|
|
|
|
"scope" => $scope,
|
2015-08-09 14:39:11 -04:00
|
|
|
"tags" => $taglist);
|
2015-08-09 02:31:42 -04:00
|
|
|
|
|
|
|
header('Content-type: application/json; charset=utf-8');
|
|
|
|
echo json_encode($relay, true);
|
|
|
|
exit;
|
2012-12-28 16:51:50 -05:00
|
|
|
}
|