3 * @file mod/friendica.php
7 use Friendica\Core\Addon;
8 use Friendica\Core\Config;
9 use Friendica\Core\L10n;
10 use Friendica\Core\System;
11 use Friendica\Database\DBA;
13 function friendica_init(App $a)
15 if (!empty($a->argv[1]) && ($a->argv[1] == "json")) {
16 $register_policy = ['REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'];
19 if (x($a->config, 'admin_nickname')) {
20 $sql_extra = sprintf(" AND `nickname` = '%s' ", DBA::escape(Config::get('config', 'admin_nickname')));
22 if (!empty(Config::get('config', 'admin_email'))) {
23 $adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
25 $r = q("SELECT `username`, `nickname` FROM `user` WHERE `email` = '%s' $sql_extra", DBA::escape($adminlist[0]));
27 'name' => $r[0]['username'],
28 'profile'=> System::baseUrl() . '/profile/' . $r[0]['nickname'],
35 if (is_array($a->addons) && count($a->addons)) {
36 $r = q("SELECT * FROM `addon` WHERE `hidden` = 0");
37 if (DBA::isResult($r)) {
39 $visible_addons[] = $rr['name'];
44 Config::load('feature_lock');
45 $locked_features = [];
46 if (!empty($a->config['feature_lock']) && count($a->config['feature_lock'])) {
47 foreach ($a->config['feature_lock'] as $k => $v) {
48 if ($k === 'config_loaded') {
52 $locked_features[$k] = intval($v);
57 'version' => FRIENDICA_VERSION,
58 'url' => System::baseUrl(),
59 'addons' => $visible_addons,
60 'locked_features' => $locked_features,
61 'register_policy' => $register_policy[intval(Config::get('config', 'register_policy'))],
63 'site_name' => Config::get('config', 'sitename'),
64 'platform' => FRIENDICA_PLATFORM,
65 'info' => Config::get('config', 'info'),
66 'no_scrape_url' => System::baseUrl().'/noscrape'
69 echo json_encode($data);
74 function friendica_content(App $a)
76 $o = '<h1>Friendica</h1>' . PHP_EOL;
78 $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.',
79 '<strong>' . FRIENDICA_VERSION . '</strong>', System::baseUrl(), '<strong>' . DB_UPDATE_VERSION . '</strong>',
80 '<strong>' . Config::get("system", "post_update_version") . '</strong>');
81 $o .= '</p>' . PHP_EOL;
84 $o .= L10n::t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.') . PHP_EOL;
85 $o .= '</p>' . PHP_EOL;
88 $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>';
89 $o .= '</p>' . PHP_EOL;
91 $o .= L10n::t('Suggestions, praise, etc. - please email "info" at "friendi - dot - ca');
92 $o .= '</p>' . PHP_EOL;
95 if (is_array($a->addons) && count($a->addons)) {
96 $r = q("SELECT * FROM `addon` WHERE `hidden` = 0");
97 if (DBA::isResult($r)) {
99 $visible_addons[] = $rr['name'];
104 if (count($visible_addons)) {
105 $o .= '<p>' . L10n::t('Installed addons/apps:') . '</p>' . PHP_EOL;
106 $sorted = $visible_addons;
109 foreach ($sorted as $p) {
117 $o .= '<div style="margin-left: 25px; margin-right: 25px; margin-bottom: 25px;">' . $s . '</div>' . PHP_EOL;
119 $o .= '<p>' . L10n::t('No installed addons/apps') . '</p>' . PHP_EOL;
122 if (Config::get('system', 'tosdisplay'))
124 $o .= '<p>'.L10n::t('Read about the <a href="%1$s/tos">Terms of Service</a> of this node.', System::baseurl()).'</p>';
127 $blocklist = Config::get('system', 'blocklist', []);
128 if (!empty($blocklist)) {
129 $o .= '<div id="about_blocklist"><p>' . L10n::t('On this server the following remote servers are blocked.') . '</p>' . PHP_EOL;
130 $o .= '<table class="table"><thead><tr><th>' . L10n::t('Blocked domain') . '</th><th>' . L10n::t('Reason for the block') . '</th></thead><tbody>' . PHP_EOL;
131 foreach ($blocklist as $b) {
132 $o .= '<tr><td>' . $b['domain'] .'</td><td>' . $b['reason'] . '</td></tr>' . PHP_EOL;
134 $o .= '</tbody></table></div>' . PHP_EOL;
137 Addon::callHooks('about_hook', $o);