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];
32 if (!empty($a->config['admin_nickname'])) {
33 $sql_extra = sprintf(" AND `nickname` = '%s' ", DBA::escape(Config::get('config', 'admin_nickname')));
35 if (!empty(Config::get('config', 'admin_email'))) {
36 $adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
38 $r = q("SELECT `username`, `nickname` FROM `user` WHERE `email` = '%s' $sql_extra", DBA::escape($adminlist[0]));
40 'name' => $r[0]['username'],
41 'profile'=> System::baseUrl() . '/profile/' . $r[0]['nickname'],
47 $visible_addons = Addon::getVisibleList();
49 Config::load('feature_lock');
50 $locked_features = [];
51 if (!empty($a->config['feature_lock'])) {
52 foreach ($a->config['feature_lock'] as $k => $v) {
53 if ($k === 'config_loaded') {
57 $locked_features[$k] = intval($v);
62 'version' => FRIENDICA_VERSION,
63 'url' => System::baseUrl(),
64 'addons' => $visible_addons,
65 'locked_features' => $locked_features,
66 'explicit_content' => (int)Config::get('system', 'explicit_content', false),
67 'language' => Config::get('system','language'),
68 'register_policy' => $register_policy,
70 'site_name' => Config::get('config', 'sitename'),
71 'platform' => FRIENDICA_PLATFORM,
72 'info' => Config::get('config', 'info'),
73 'no_scrape_url' => System::baseUrl().'/noscrape'
76 header('Content-type: application/json; charset=utf-8');
77 echo json_encode($data);
82 function friendica_content(App $a)
84 $o = '<h1>Friendica</h1>' . PHP_EOL;
86 $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.',
87 '<strong>' . FRIENDICA_VERSION . '</strong>', System::baseUrl(), '<strong>' . DB_UPDATE_VERSION . '</strong>',
88 '<strong>' . Config::get("system", "post_update_version") . '</strong>');
89 $o .= '</p>' . PHP_EOL;
92 $o .= L10n::t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.') . PHP_EOL;
93 $o .= '</p>' . PHP_EOL;
96 $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>';
97 $o .= '</p>' . PHP_EOL;
99 $o .= L10n::t('Suggestions, praise, etc. - please email "info" at "friendi - dot - ca');
100 $o .= '</p>' . PHP_EOL;
102 $visible_addons = Addon::getVisibleList();
103 if (count($visible_addons)) {
104 $o .= '<p>' . L10n::t('Installed addons/apps:') . '</p>' . PHP_EOL;
105 $sorted = $visible_addons;
108 foreach ($sorted as $p) {
116 $o .= '<div style="margin-left: 25px; margin-right: 25px; margin-bottom: 25px;">' . $s . '</div>' . PHP_EOL;
118 $o .= '<p>' . L10n::t('No installed addons/apps') . '</p>' . PHP_EOL;
121 if (Config::get('system', 'tosdisplay'))
123 $o .= '<p>'.L10n::t('Read about the <a href="%1$s/tos">Terms of Service</a> of this node.', System::baseurl()).'</p>';
126 $blocklist = Config::get('system', 'blocklist', []);
127 if (!empty($blocklist)) {
128 $o .= '<div id="about_blocklist"><p>' . L10n::t('On this server the following remote servers are blocked.') . '</p>' . PHP_EOL;
129 $o .= '<table class="table"><thead><tr><th>' . L10n::t('Blocked domain') . '</th><th>' . L10n::t('Reason for the block') . '</th></thead><tbody>' . PHP_EOL;
130 foreach ($blocklist as $b) {
131 $o .= '<tr><td>' . $b['domain'] .'</td><td>' . $b['reason'] . '</td></tr>' . PHP_EOL;
133 $o .= '</tbody></table></div>' . PHP_EOL;
136 Hook::callAll('about_hook', $o);