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