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 = [])
22 $config = $app->getConfig();
24 $visibleAddonList = Addon::getVisibleList();
25 if (!empty($visibleAddonList)) {
27 $sorted = $visibleAddonList;
30 $sortedAddonList = '';
32 foreach ($sorted as $addon) {
34 if (strlen($sortedAddonList)) {
35 $sortedAddonList .= ', ';
37 $sortedAddonList .= $addon;
41 'title' => L10n::t('Installed addons/apps:'),
42 'list' => $sortedAddonList,
46 'title' => L10n::t('No installed addons/apps'),
50 $tos = ($config->get('system', 'tosdisplay')) ?
51 L10n::t('Read about the <a href="%1$s/tos">Terms of Service</a> of this node.', $app->getBaseURL()) :
54 $blockList = $config->get('system', 'blocklist');
56 if (!empty($blockList)) {
58 'title' => L10n::t('On this server the following remote servers are blocked.'),
60 L10n::t('Blocked domain'),
61 L10n::t('Reason for the block'),
71 Hook::callAll('about_hook', $hooked);
73 $tpl = Renderer::getMarkupTemplate('friendica.tpl');
75 return Renderer::replaceMacros($tpl, [
76 '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.',
77 '<strong>' . FRIENDICA_VERSION . '</strong>',
79 '<strong>' . DB_UPDATE_VERSION . '</strong>',
80 '<strong>' . $config->get('system', 'post_update_version') . '</strong>'),
81 'friendica' => L10n::t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.'),
82 '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>',
83 'info' => L10n::t('Suggestions, praise, etc. - please email "info" at "friendi - dot - ca'),
85 'visible_addons' => $addon,
87 'block_list' => $blocked,
92 public static function rawContent(array $parameters = [])
96 // @TODO: Replace with parameter from router
97 if ($app->argc <= 1 || ($app->argv[1] !== 'json')) {
101 $config = $app->getConfig();
103 $register_policies = [
104 Register::CLOSED => 'REGISTER_CLOSED',
105 Register::APPROVE => 'REGISTER_APPROVE',
106 Register::OPEN => 'REGISTER_OPEN'
109 $register_policy_int = intval($config->get('config', 'register_policy'));
110 if ($register_policy_int !== Register::CLOSED && $config->get('config', 'invitation_only')) {
111 $register_policy = 'REGISTER_INVITATION';
113 $register_policy = $register_policies[$register_policy_int];
118 if (!empty($config->get('config', 'admin_nickname'))) {
119 $condition['nickname'] = $config->get('config', 'admin_nickname');
121 if (!empty($config->get('config', 'admin_email'))) {
122 $adminList = explode(',', str_replace(' ', '', $config->get('config', 'admin_email')));
123 $condition['email'] = $adminList[0];
124 $administrator = User::getByEmail($adminList[0], ['username', 'nickname']);
125 if (!empty($administrator)) {
127 'name' => $administrator['username'],
128 'profile' => $app->getBaseURL() . '/profile/' . $administrator['nickname'],
133 $visible_addons = Addon::getVisibleList();
135 $config->load('feature_lock');
136 $locked_features = [];
137 $featureLocks = $config->get('config', 'feature_lock');
138 if (isset($featureLocks)) {
139 foreach ($featureLocks as $feature => $lock) {
140 if ($feature === 'config_loaded') {
144 $locked_features[$feature] = intval($lock);
149 'version' => FRIENDICA_VERSION,
150 'url' => $app->getBaseURL(),
151 'addons' => $visible_addons,
152 'locked_features' => $locked_features,
153 'explicit_content' => intval($config->get('system', 'explicit_content', 0)),
154 'language' => $config->get('system', 'language'),
155 'register_policy' => $register_policy,
157 'site_name' => $config->get('config', 'sitename'),
158 'platform' => FRIENDICA_PLATFORM,
159 'info' => $config->get('config', 'info'),
160 'no_scrape_url' => $app->getBaseURL() . '/noscrape',
163 header('Content-type: application/json; charset=utf-8');
164 echo json_encode($data);