3 * @file mod/friendica.php
7 use Friendica\Core\Addon;
8 use Friendica\Core\Config;
9 use Friendica\Core\Hook;
10 use Friendica\Core\L10n;
11 use Friendica\Core\System;
12 use Friendica\Database\DBA;
13 use Friendica\Module\Register;
15 function friendica_init(App $a)
17 if (!empty($a->argv[1]) && ($a->argv[1] == "json")) {
18 $register_policies = [
19 Register::CLOSED => 'REGISTER_CLOSED',
20 Register::APPROVE => 'REGISTER_APPROVE',
21 Register::OPEN => 'REGISTER_OPEN'
24 $register_policy_int = intval(Config::get('config', 'register_policy'));
25 if ($register_policy_int !== Register::CLOSED && Config::get('config', 'invitation_only')) {
26 $register_policy = 'REGISTER_INVITATION';
28 $register_policy = $register_policies[$register_policy_int];
33 if (!empty(Config::get('config', 'admin_nickname'))) {
34 $condition['nickname'] = Config::get('config', 'admin_nickname');
36 if (!empty(Config::get('config', 'admin_email'))) {
37 $adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
38 $condition['email'] = $adminlist[0];
39 $administrator = DBA::selectFirst('user', ['username', 'nickname'], $condition);
40 if (DBA::isResult($administrator)) {
42 'name' => $administrator['username'],
43 'profile'=> System::baseUrl() . '/profile/' . $administrator['nickname'],
48 $visible_addons = Addon::getVisibleList();
50 Config::load('feature_lock');
51 $locked_features = [];
52 $featureLock = Config::get('config', 'feature_lock');
53 if (isset($featureLock)) {
54 foreach ($featureLock as $k => $v) {
55 if ($k === 'config_loaded') {
59 $locked_features[$k] = intval($v);
64 'version' => FRIENDICA_VERSION,
65 'url' => System::baseUrl(),
66 'addons' => $visible_addons,
67 'locked_features' => $locked_features,
68 'explicit_content' => (int)Config::get('system', 'explicit_content', false),
69 'language' => Config::get('system','language'),
70 'register_policy' => $register_policy,
72 'site_name' => Config::get('config', 'sitename'),
73 'platform' => FRIENDICA_PLATFORM,
74 'info' => Config::get('config', 'info'),
75 'no_scrape_url' => System::baseUrl().'/noscrape'
78 header('Content-type: application/json; charset=utf-8');
79 echo json_encode($data);
84 function friendica_content(App $a)
86 $o = '<h1>Friendica</h1>' . PHP_EOL;
88 $o .= 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.',
89 '<strong>' . FRIENDICA_VERSION . '</strong>', System::baseUrl(), '<strong>' . DB_UPDATE_VERSION . '</strong>',
90 '<strong>' . Config::get("system", "post_update_version") . '</strong>');
91 $o .= '</p>' . PHP_EOL;
94 $o .= L10n::t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.') . PHP_EOL;
95 $o .= '</p>' . PHP_EOL;
98 $o .= 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>';
99 $o .= '</p>' . PHP_EOL;
101 $o .= L10n::t('Suggestions, praise, etc. - please email "info" at "friendi - dot - ca');
102 $o .= '</p>' . PHP_EOL;
104 $visible_addons = Addon::getVisibleList();
105 if (count($visible_addons)) {
106 $o .= '<p>' . L10n::t('Installed addons/apps:') . '</p>' . PHP_EOL;
107 $sorted = $visible_addons;
110 foreach ($sorted as $p) {
118 $o .= '<div style="margin-left: 25px; margin-right: 25px; margin-bottom: 25px;">' . $s . '</div>' . PHP_EOL;
120 $o .= '<p>' . L10n::t('No installed addons/apps') . '</p>' . PHP_EOL;
123 if (Config::get('system', 'tosdisplay'))
125 $o .= '<p>'.L10n::t('Read about the <a href="%1$s/tos">Terms of Service</a> of this node.', System::baseurl()).'</p>';
128 $blocklist = Config::get('system', 'blocklist', []);
129 if (!empty($blocklist)) {
130 $o .= '<div id="about_blocklist"><p>' . L10n::t('On this server the following remote servers are blocked.') . '</p>' . PHP_EOL;
131 $o .= '<table class="table"><thead><tr><th>' . L10n::t('Blocked domain') . '</th><th>' . L10n::t('Reason for the block') . '</th></thead><tbody>' . PHP_EOL;
132 foreach ($blocklist as $b) {
133 $o .= '<tr><td>' . $b['domain'] .'</td><td>' . $b['reason'] . '</td></tr>' . PHP_EOL;
135 $o .= '</tbody></table></div>' . PHP_EOL;
138 Hook::callAll('about_hook', $o);