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