3 * @file mod/friendica.php
6 use Friendica\Core\Addon;
7 use Friendica\Core\System;
8 use Friendica\Core\Config;
9 use Friendica\Core\L10n;
10 use Friendica\Database\DBM;
12 function friendica_init(App $a)
14 if ($a->argv[1] == "json") {
15 $register_policy = ['REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'];
18 if (x($a->config, 'admin_nickname')) {
19 $sql_extra = sprintf(" AND `nickname` = '%s' ", dbesc($a->config['admin_nickname']));
21 if (isset($a->config['admin_email']) && $a->config['admin_email']!='') {
22 $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
24 $r = q("SELECT `username`, `nickname` FROM `user` WHERE `email` = '%s' $sql_extra", dbesc($adminlist[0]));
26 'name' => $r[0]['username'],
27 'profile'=> System::baseUrl() . '/profile/' . $r[0]['nickname'],
34 if (is_array($a->addons) && count($a->addons)) {
35 $r = q("SELECT * FROM `addon` WHERE `hidden` = 0");
36 if (DBM::is_result($r)) {
38 $visible_addons[] = $rr['name'];
43 Config::load('feature_lock');
44 $locked_features = [];
45 if (is_array($a->config['feature_lock']) && count($a->config['feature_lock'])) {
46 foreach ($a->config['feature_lock'] as $k => $v) {
47 if ($k === 'config_loaded') {
51 $locked_features[$k] = intval($v);
56 'version' => FRIENDICA_VERSION,
57 'url' => System::baseUrl(),
58 'addons' => $visible_addons,
59 'locked_features' => $locked_features,
60 'register_policy' => $register_policy[$a->config['register_policy']],
62 'site_name' => $a->config['sitename'],
63 'platform' => FRIENDICA_PLATFORM,
64 'info' => ((x($a->config, 'info')) ? $a->config['info'] : ''),
65 'no_scrape_url' => System::baseUrl().'/noscrape'
68 echo json_encode($data);
73 function friendica_content(App $a)
75 $o = '<h1>Friendica</h1>' . PHP_EOL;
77 $o .= L10n::t('This is Friendica, version') . ' <strong>' . FRIENDICA_VERSION . '</strong> ';
78 $o .= L10n::t('running at web location') . ' ' . System::baseUrl();
79 $o .= '</p>' . PHP_EOL;
82 $o .= L10n::t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.') . PHP_EOL;
83 $o .= '</p>' . PHP_EOL;
86 $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>';
87 $o .= '</p>' . PHP_EOL;
89 $o .= L10n::t('Suggestions, praise, etc. - please email "info" at "friendi - dot - ca');
90 $o .= '</p>' . PHP_EOL;
93 if (is_array($a->addons) && count($a->addons)) {
94 $r = q("SELECT * FROM `addon` WHERE `hidden` = 0");
95 if (DBM::is_result($r)) {
97 $visible_addons[] = $rr['name'];
102 if (count($visible_addons)) {
103 $o .= '<p>' . L10n::t('Installed addons/apps:') . '</p>' . PHP_EOL;
104 $sorted = $visible_addons;
107 foreach ($sorted as $p) {
115 $o .= '<div style="margin-left: 25px; margin-right: 25px; margin-bottom: 25px;">' . $s . '</div>' . PHP_EOL;
117 $o .= '<p>' . L10n::t('No installed addons/apps') . '</p>' . PHP_EOL;
120 if (Config::get('system', 'tosdisplay'))
122 $o .= '<p>'.L10n::t('Read about the <a href="%1$s/tos">Terms of Service</a> of this node.', System::baseurl()).'</p>';
125 $blocklist = Config::get('system', 'blocklist', []);
126 if (!empty($blocklist)) {
127 $o .= '<div id="about_blocklist"><p>' . L10n::t('On this server the following remote servers are blocked.') . '</p>' . PHP_EOL;
128 $o .= '<table class="table"><thead><tr><th>' . L10n::t('Blocked domain') . '</th><th>' . L10n::t('Reason for the block') . '</th></thead><tbody>' . PHP_EOL;
129 foreach ($blocklist as $b) {
130 $o .= '<tr><td>' . $b['domain'] .'</td><td>' . $b['reason'] . '</td></tr>' . PHP_EOL;
132 $o .= '</tbody></table></div>' . PHP_EOL;
135 Addon::callHooks('about_hook', $o);