3 namespace Friendica\Module;
5 use Friendica\BaseModule;
6 use Friendica\Core\Addon;
7 use Friendica\Core\Hook;
8 use Friendica\Core\L10n;
9 use Friendica\Core\Renderer;
11 use Friendica\Model\User;
14 * Prints information about the current node
15 * Either in human readable form or in JSON
17 class Friendica extends BaseModule
19 public static function content(array $parameters = [])
21 $config = DI::config();
23 $visibleAddonList = Addon::getVisibleList();
24 if (!empty($visibleAddonList)) {
26 $sorted = $visibleAddonList;
29 $sortedAddonList = '';
31 foreach ($sorted as $addon) {
33 if (strlen($sortedAddonList)) {
34 $sortedAddonList .= ', ';
36 $sortedAddonList .= $addon;
40 'title' => L10n::t('Installed addons/apps:'),
41 'list' => $sortedAddonList,
45 'title' => L10n::t('No installed addons/apps'),
49 $tos = ($config->get('system', 'tosdisplay')) ?
50 L10n::t('Read about the <a href="%1$s/tos">Terms of Service</a> of this node.', DI::baseUrl()->get()) :
53 $blockList = $config->get('system', 'blocklist');
55 if (!empty($blockList)) {
57 'title' => L10n::t('On this server the following remote servers are blocked.'),
59 L10n::t('Blocked domain'),
60 L10n::t('Reason for the block'),
70 Hook::callAll('about_hook', $hooked);
72 $tpl = Renderer::getMarkupTemplate('friendica.tpl');
74 return Renderer::replaceMacros($tpl, [
75 'about' => 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.',
76 '<strong>' . FRIENDICA_VERSION . '</strong>',
78 '<strong>' . DB_UPDATE_VERSION . '</strong>',
79 '<strong>' . $config->get('system', 'post_update_version') . '</strong>'),
80 'friendica' => L10n::t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.'),
81 'bugs' => L10n::t('Bug reports and issues: please visit') . ' ' . '<a href="https://github.com/friendica/friendica/issues?state=open">' . L10n::t('the bugtracker at github') . '</a>',
82 'info' => L10n::t('Suggestions, praise, etc. - please email "info" at "friendi - dot - ca'),
84 'visible_addons' => $addon,
86 'block_list' => $blocked,
91 public static function rawContent(array $parameters = [])
95 // @TODO: Replace with parameter from router
96 if ($app->argc <= 1 || ($app->argv[1] !== 'json')) {
100 $config = DI::config();
102 $register_policies = [
103 Register::CLOSED => 'REGISTER_CLOSED',
104 Register::APPROVE => 'REGISTER_APPROVE',
105 Register::OPEN => 'REGISTER_OPEN'
108 $register_policy_int = intval($config->get('config', 'register_policy'));
109 if ($register_policy_int !== Register::CLOSED && $config->get('config', 'invitation_only')) {
110 $register_policy = 'REGISTER_INVITATION';
112 $register_policy = $register_policies[$register_policy_int];
117 if (!empty($config->get('config', 'admin_nickname'))) {
118 $condition['nickname'] = $config->get('config', 'admin_nickname');
120 if (!empty($config->get('config', 'admin_email'))) {
121 $adminList = explode(',', str_replace(' ', '', $config->get('config', 'admin_email')));
122 $condition['email'] = $adminList[0];
123 $administrator = User::getByEmail($adminList[0], ['username', 'nickname']);
124 if (!empty($administrator)) {
126 'name' => $administrator['username'],
127 'profile' => DI::baseUrl()->get() . '/profile/' . $administrator['nickname'],
132 $visible_addons = Addon::getVisibleList();
134 $config->load('feature_lock');
135 $locked_features = [];
136 $featureLocks = $config->get('config', 'feature_lock');
137 if (isset($featureLocks)) {
138 foreach ($featureLocks as $feature => $lock) {
139 if ($feature === 'config_loaded') {
143 $locked_features[$feature] = intval($lock);
148 'version' => FRIENDICA_VERSION,
149 'url' => DI::baseUrl()->get(),
150 'addons' => $visible_addons,
151 'locked_features' => $locked_features,
152 'explicit_content' => intval($config->get('system', 'explicit_content', 0)),
153 'language' => $config->get('system', 'language'),
154 'register_policy' => $register_policy,
156 'site_name' => $config->get('config', 'sitename'),
157 'platform' => FRIENDICA_PLATFORM,
158 'info' => $config->get('config', 'info'),
159 'no_scrape_url' => DI::baseUrl()->get() . '/noscrape',
162 header('Content-type: application/json; charset=utf-8');
163 echo json_encode($data);