3 namespace Friendica\Module;
5 use Friendica\BaseModule;
6 use Friendica\Core\Addon;
7 use Friendica\Core\Hook;
8 use Friendica\Core\Renderer;
10 use Friendica\Model\User;
13 * Prints information about the current node
14 * Either in human readable form or in JSON
16 class Friendica extends BaseModule
18 public static function content(array $parameters = [])
20 $config = DI::config();
22 $visibleAddonList = Addon::getVisibleList();
23 if (!empty($visibleAddonList)) {
25 $sorted = $visibleAddonList;
28 $sortedAddonList = '';
30 foreach ($sorted as $addon) {
32 if (strlen($sortedAddonList)) {
33 $sortedAddonList .= ', ';
35 $sortedAddonList .= $addon;
39 'title' => DI::l10n()->t('Installed addons/apps:'),
40 'list' => $sortedAddonList,
44 'title' => DI::l10n()->t('No installed addons/apps'),
48 $tos = ($config->get('system', 'tosdisplay')) ?
49 DI::l10n()->t('Read about the <a href="%1$s/tos">Terms of Service</a> of this node.', DI::baseUrl()->get()) :
52 $blockList = $config->get('system', 'blocklist');
54 if (!empty($blockList)) {
56 'title' => DI::l10n()->t('On this server the following remote servers are blocked.'),
58 DI::l10n()->t('Blocked domain'),
59 DI::l10n()->t('Reason for the block'),
69 Hook::callAll('about_hook', $hooked);
71 $tpl = Renderer::getMarkupTemplate('friendica.tpl');
73 return Renderer::replaceMacros($tpl, [
74 'about' => DI::l10n()->t('This is Friendica, version %s that is running at the web location %s. The database version is %s, the post update version is %s.',
75 '<strong>' . FRIENDICA_VERSION . '</strong>',
77 '<strong>' . DB_UPDATE_VERSION . '</strong>',
78 '<strong>' . $config->get('system', 'post_update_version') . '</strong>'),
79 'friendica' => DI::l10n()->t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.'),
80 'bugs' => DI::l10n()->t('Bug reports and issues: please visit') . ' ' . '<a href="https://github.com/friendica/friendica/issues?state=open">' . DI::l10n()->t('the bugtracker at github') . '</a>',
81 'info' => DI::l10n()->t('Suggestions, praise, etc. - please email "info" at "friendi - dot - ca'),
83 'visible_addons' => $addon,
85 'block_list' => $blocked,
90 public static function rawContent(array $parameters = [])
94 // @TODO: Replace with parameter from router
95 if ($app->argc <= 1 || ($app->argv[1] !== 'json')) {
99 $config = DI::config();
101 $register_policies = [
102 Register::CLOSED => 'REGISTER_CLOSED',
103 Register::APPROVE => 'REGISTER_APPROVE',
104 Register::OPEN => 'REGISTER_OPEN'
107 $register_policy_int = intval($config->get('config', 'register_policy'));
108 if ($register_policy_int !== Register::CLOSED && $config->get('config', 'invitation_only')) {
109 $register_policy = 'REGISTER_INVITATION';
111 $register_policy = $register_policies[$register_policy_int];
116 if (!empty($config->get('config', 'admin_nickname'))) {
117 $condition['nickname'] = $config->get('config', 'admin_nickname');
119 if (!empty($config->get('config', 'admin_email'))) {
120 $adminList = explode(',', str_replace(' ', '', $config->get('config', 'admin_email')));
121 $condition['email'] = $adminList[0];
122 $administrator = User::getByEmail($adminList[0], ['username', 'nickname']);
123 if (!empty($administrator)) {
125 'name' => $administrator['username'],
126 'profile' => DI::baseUrl()->get() . '/profile/' . $administrator['nickname'],
131 $visible_addons = Addon::getVisibleList();
133 $config->load('feature_lock');
134 $locked_features = [];
135 $featureLocks = $config->get('config', 'feature_lock');
136 if (isset($featureLocks)) {
137 foreach ($featureLocks as $feature => $lock) {
138 if ($feature === 'config_loaded') {
142 $locked_features[$feature] = intval($lock);
147 'version' => FRIENDICA_VERSION,
148 'url' => DI::baseUrl()->get(),
149 'addons' => $visible_addons,
150 'locked_features' => $locked_features,
151 'explicit_content' => intval($config->get('system', 'explicit_content', 0)),
152 'language' => $config->get('system', 'language'),
153 'register_policy' => $register_policy,
155 'site_name' => $config->get('config', 'sitename'),
156 'platform' => strtolower(FRIENDICA_PLATFORM),
157 'info' => $config->get('config', 'info'),
158 'no_scrape_url' => DI::baseUrl()->get() . '/noscrape',
161 header('Content-type: application/json; charset=utf-8');
162 echo json_encode($data);