wellKnown = $wellKnown; $this->main = $main; } /** * handle nodeinfo request * * @param string[] $paths path of us * @return bool true on success */ public function exec($paths) { $config = $this->main->getConfig(); $domain = $config['generic']['externaldomain']; $data = [ 'fqdn' => $domain ]; $template = null; if (sizeof($paths) == 2 && $paths[0] === '.well-known' && $paths[1] === 'nodeinfo') { $template = 'nodeinfo.json'; } else { if ($paths[0] !== 'nodeinfo') { throw new \Federator\Exceptions\FileNotFound(); } } if ($template === null) { switch ($paths[1]) { case '2.1': $template = 'nodeinfo2.1.json'; break; default: $template = 'nodeinfo2.0.json'; } $stats = \Federator\DIO\Stats::getStats($this->main); echo "fetch usercount via connector\n"; $data['usercount'] = $stats->userCount; $data['postcount'] = $stats->postCount; $data['commentcount'] = $stats->commentCount; } $tpl = $this->main->renderTemplate($template, $data); $this->wellKnown->setResponse($tpl); return true; } }