]> git.mxchange.org Git - friendica.git/blob - mod/friendica.php
2629a0a19e3c3bdd4b89f4745edb4b7d43248015
[friendica.git] / mod / friendica.php
1 <?php
2 /**
3  * @file mod/friendica.php
4  */
5
6 use Friendica\App;
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;
12
13 function friendica_init(App $a)
14 {
15         if (!empty($a->argv[1]) && ($a->argv[1] == "json")) {
16                 $register_policy = ['REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'];
17
18                 $sql_extra = '';
19                 if (x($a->config, 'admin_nickname')) {
20                         $sql_extra = sprintf(" AND `nickname` = '%s' ", DBA::escape(Config::get('config', 'admin_nickname')));
21                 }
22                 if (!empty(Config::get('config', 'admin_email'))) {
23                         $adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
24
25                         $r = q("SELECT `username`, `nickname` FROM `user` WHERE `email` = '%s' $sql_extra", DBA::escape($adminlist[0]));
26                         $admin = [
27                                 'name' => $r[0]['username'],
28                                 'profile'=> System::baseUrl() . '/profile/' . $r[0]['nickname'],
29                         ];
30                 } else {
31                         $admin = false;
32                 }
33
34                 $visible_addons = Addon::getVisibleList();
35
36                 Config::load('feature_lock');
37                 $locked_features = [];
38                 if (!empty($a->config['feature_lock']) && count($a->config['feature_lock'])) {
39                         foreach ($a->config['feature_lock'] as $k => $v) {
40                                 if ($k === 'config_loaded') {
41                                         continue;
42                                 }
43
44                                 $locked_features[$k] = intval($v);
45                         }
46                 }
47
48                 $data = [
49                         'version'          => FRIENDICA_VERSION,
50                         'url'              => System::baseUrl(),
51                         'addons'           => $visible_addons,
52                         'locked_features'  => $locked_features,
53                         'explicit_content' => (int)Config::get('system', 'explicit_content', false),
54                         'language'         => Config::get('system','language'),
55                         'register_policy ' => $register_policy[intval(Config::get('config', 'register_policy'))],
56                         'admin'            => $admin,
57                         'site_name'        => Config::get('config', 'sitename'),
58                         'platform'         => FRIENDICA_PLATFORM,
59                         'info'             => Config::get('config', 'info'),
60                         'no_scrape_url'    => System::baseUrl().'/noscrape'
61                 ];
62
63                 header('Content-type: application/json; charset=utf-8');
64                 echo json_encode($data);
65                 killme();
66         }
67 }
68
69 function friendica_content(App $a)
70 {
71         $o = '<h1>Friendica</h1>' . PHP_EOL;
72         $o .= '<p>';
73         $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.',
74                 '<strong>' . FRIENDICA_VERSION . '</strong>', System::baseUrl(), '<strong>' . DB_UPDATE_VERSION . '</strong>',
75                 '<strong>' . Config::get("system", "post_update_version") . '</strong>');
76         $o .= '</p>' . PHP_EOL;
77
78         $o .= '<p>';
79         $o .= L10n::t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.') . PHP_EOL;
80         $o .= '</p>' . PHP_EOL;
81
82         $o .= '<p>';
83         $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>';
84         $o .= '</p>' . PHP_EOL;
85         $o .= '<p>';
86         $o .= L10n::t('Suggestions, praise, etc. - please email "info" at "friendi - dot - ca');
87         $o .= '</p>' . PHP_EOL;
88
89         $visible_addons = Addon::getVisibleList();
90         if (count($visible_addons)) {
91                 $o .= '<p>' . L10n::t('Installed addons/apps:') . '</p>' . PHP_EOL;
92                 $sorted = $visible_addons;
93                 $s = '';
94                 sort($sorted);
95                 foreach ($sorted as $p) {
96                         if (strlen($p)) {
97                                 if (strlen($s)) {
98                                         $s .= ', ';
99                                 }
100                                 $s .= $p;
101                         }
102                 }
103                 $o .= '<div style="margin-left: 25px; margin-right: 25px; margin-bottom: 25px;">' . $s . '</div>' . PHP_EOL;
104         } else {
105                 $o .= '<p>' . L10n::t('No installed addons/apps') . '</p>' . PHP_EOL;
106         }
107
108         if (Config::get('system', 'tosdisplay'))
109         {
110                 $o .= '<p>'.L10n::t('Read about the <a href="%1$s/tos">Terms of Service</a> of this node.', System::baseurl()).'</p>';
111         }
112
113         $blocklist = Config::get('system', 'blocklist', []);
114         if (!empty($blocklist)) {
115                 $o .= '<div id="about_blocklist"><p>' . L10n::t('On this server the following remote servers are blocked.') . '</p>' . PHP_EOL;
116                 $o .= '<table class="table"><thead><tr><th>' . L10n::t('Blocked domain') . '</th><th>' . L10n::t('Reason for the block') . '</th></thead><tbody>' . PHP_EOL;
117                 foreach ($blocklist as $b) {
118                         $o .= '<tr><td>' . $b['domain'] .'</td><td>' . $b['reason'] . '</td></tr>' . PHP_EOL;
119                 }
120                 $o .= '</tbody></table></div>' . PHP_EOL;
121         }
122
123         Addon::callHooks('about_hook', $o);
124
125         return $o;
126 }