]> git.mxchange.org Git - friendica.git/blob - mod/friendica.php
Fixes:
[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\DBM;
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' ", dbesc(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", dbesc($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 = [];
35                 if (is_array($a->addons) && count($a->addons)) {
36                         $r = q("SELECT * FROM `addon` WHERE `hidden` = 0");
37                         if (DBM::is_result($r)) {
38                                 foreach ($r as $rr) {
39                                         $visible_addons[] = $rr['name'];
40                                 }
41                         }
42                 }
43
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') {
49                                         continue;
50                                 }
51
52                                 $locked_features[$k] = intval($v);
53                         }
54                 }
55
56                 $data = [
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'))],
62                         'admin'           => $admin,
63                         'site_name'       => Config::get('config', 'sitename'),
64                         'platform'        => FRIENDICA_PLATFORM,
65                         'info'            => Config::get('config', 'info'),
66                         'no_scrape_url'   => System::baseUrl().'/noscrape'
67                 ];
68
69                 echo json_encode($data);
70                 killme();
71         }
72 }
73
74 function friendica_content(App $a)
75 {
76         $o = '<h1>Friendica</h1>' . PHP_EOL;
77         $o .= '<p>';
78         $o .= L10n::t('This is Friendica, version') . ' <strong>' . FRIENDICA_VERSION . '</strong> ';
79         $o .= L10n::t('running at web location') . ' ' . System::baseUrl();
80         $o .= '</p>' . PHP_EOL;
81
82         $o .= '<p>';
83         $o .= L10n::t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.') . PHP_EOL;
84         $o .= '</p>' . PHP_EOL;
85
86         $o .= '<p>';
87         $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>';
88         $o .= '</p>' . PHP_EOL;
89         $o .= '<p>';
90         $o .= L10n::t('Suggestions, praise, etc. - please email "info" at "friendi - dot - ca');
91         $o .= '</p>' . PHP_EOL;
92
93         $visible_addons = [];
94         if (is_array($a->addons) && count($a->addons)) {
95                 $r = q("SELECT * FROM `addon` WHERE `hidden` = 0");
96                 if (DBM::is_result($r)) {
97                         foreach ($r as $rr) {
98                                 $visible_addons[] = $rr['name'];
99                         }
100                 }
101         }
102
103         if (count($visible_addons)) {
104                 $o .= '<p>' . L10n::t('Installed addons/apps:') . '</p>' . PHP_EOL;
105                 $sorted = $visible_addons;
106                 $s = '';
107                 sort($sorted);
108                 foreach ($sorted as $p) {
109                         if (strlen($p)) {
110                                 if (strlen($s)) {
111                                         $s .= ', ';
112                                 }
113                                 $s .= $p;
114                         }
115                 }
116                 $o .= '<div style="margin-left: 25px; margin-right: 25px; margin-bottom: 25px;">' . $s . '</div>' . PHP_EOL;
117         } else {
118                 $o .= '<p>' . L10n::t('No installed addons/apps') . '</p>' . PHP_EOL;
119         }
120
121         if (Config::get('system', 'tosdisplay'))
122         {
123                 $o .= '<p>'.L10n::t('Read about the <a href="%1$s/tos">Terms of Service</a> of this node.', System::baseurl()).'</p>';
124         }
125
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;
132                 }
133                 $o .= '</tbody></table></div>' . PHP_EOL;
134         }
135
136         Addon::callHooks('about_hook', $o);
137
138         return $o;
139 }