]> git.mxchange.org Git - friendica.git/blob - mod/friendica.php
Merge pull request #3392 from Hypolite/issue/#3387
[friendica.git] / mod / friendica.php
1 <?php
2
3 use \Friendica\Core\Config;
4
5 function friendica_init(App $a) {
6         if ($a->argv[1] == "json"){
7                 $register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
8
9                 $sql_extra = '';
10                 if (x($a->config,'admin_nickname')) {
11                         $sql_extra = sprintf(" AND `nickname` = '%s' ", dbesc($a->config['admin_nickname']));
12                 }
13                 if (isset($a->config['admin_email']) && $a->config['admin_email']!='') {
14                         $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
15
16                         $r = q("SELECT `username`, `nickname` FROM `user` WHERE `email` = '%s' $sql_extra", dbesc($adminlist[0]));
17                         $admin = array(
18                                 'name' => $r[0]['username'],
19                                 'profile'=> App::get_baseurl() . '/profile/' . $r[0]['nickname'],
20                         );
21                 } else {
22                         $admin = false;
23                 }
24
25                 $visible_plugins = array();
26                 if (is_array($a->plugins) && count($a->plugins)) {
27                         $r = q("SELECT * FROM `addon` WHERE `hidden` = 0");
28                         if (dbm::is_result($r)) {
29                                 foreach($r as $rr) {
30                                         $visible_plugins[] = $rr['name'];
31                                 }
32                         }
33                 }
34
35                 Config::load('feature_lock');
36                 $locked_features = array();
37                 if (is_array($a->config['feature_lock']) && count($a->config['feature_lock'])) {
38                         foreach ($a->config['feature_lock'] as $k => $v) {
39                                 if ($k === 'config_loaded') {
40                                         continue;
41                                 }
42
43                                 $locked_features[$k] = intval($v);
44                         }
45                 }
46
47                 $data = Array(
48                         'version'         => FRIENDICA_VERSION,
49                         'url'             => z_root(),
50                         'plugins'         => $visible_plugins,
51                         'locked_features' => $locked_features,
52                         'register_policy' =>  $register_policy[$a->config['register_policy']],
53                         'admin'           => $admin,
54                         'site_name'       => $a->config['sitename'],
55                         'platform'        => FRIENDICA_PLATFORM,
56                         'info'            => ((x($a->config,'info')) ? $a->config['info'] : ''),
57                         'no_scrape_url'   => App::get_baseurl().'/noscrape'
58                 );
59
60                 echo json_encode($data);
61                 killme();
62         }
63 }
64
65 function friendica_content(App $a) {
66         $o = '<h1>Friendica</h1>' . PHP_EOL;
67         $o .= '<p>';
68         $o .= t('This is Friendica, version') . ' <strong>' . FRIENDICA_VERSION . '</strong> ';
69         $o .= t('running at web location') . ' ' . z_root();
70         $o .= '</p>' . PHP_EOL;
71
72         $o .= '<p>';
73         $o .= t('Please visit <a href="http://friendica.com">Friendica.com</a> to learn more about the Friendica project.') . PHP_EOL;
74         $o .= '</p>' . PHP_EOL;
75
76         $o .= '<p>';
77         $o .= t('Bug reports and issues: please visit') . ' ' . '<a href="https://github.com/friendica/friendica/issues?state=open">'.t('the bugtracker at github').'</a>';
78         $o .= '</p>' . PHP_EOL;
79         $o .= '<p>';
80         $o .= t('Suggestions, praise, donations, etc. - please email "Info" at Friendica - dot com');
81         $o .= '</p>' . PHP_EOL;
82
83         $visible_plugins = array();
84         if (is_array($a->plugins) && count($a->plugins)) {
85                 $r = q("SELECT * FROM `addon` WHERE `hidden` = 0");
86                 if (dbm::is_result($r)) {
87                         foreach($r as $rr) {
88                                 $visible_plugins[] = $rr['name'];
89                         }
90                 }
91         }
92
93         if (count($visible_plugins)) {
94                 $o .= '<p>' . t('Installed plugins/addons/apps:') . '</p>' . PHP_EOL;
95                 $sorted = $visible_plugins;
96                 $s = '';
97                 sort($sorted);
98                 foreach ($sorted as $p) {
99                         if (strlen($p)) {
100                                 if (strlen($s)) {
101                                         $s .= ', ';
102                                 }
103                                 $s .= $p;
104                         }
105                 }
106                 $o .= '<div style="margin-left: 25px; margin-right: 25px;">' . $s . '</div>' . PHP_EOL;
107         } else {
108                 $o .= '<p>' . t('No installed plugins/addons/apps') . '</p>' . PHP_EOL;
109         }
110
111         $blocklist = Config::get('system', 'blocklist');
112         if (count($blocklist)) {
113                 $o .= '<div id="about_blocklist"><p>' . t('On this server the following remote servers are blocked.') . '</p>' . PHP_EOL;
114                 $o .= '<table class="table"><thead><tr><th>' . t('Blocked domain') . '</th><th>' . t('Reason for the block') . '</th></thead><tbody>' . PHP_EOL;
115                 foreach ($blocklist as $b) {
116                         $o .= '<tr><td>' . $b['domain'] .'</td><td>' . $b['reason'] . '</td></tr>' . PHP_EOL;
117                 }
118                 $o .= '</tbody></table></div>' . PHP_EOL;
119         }
120
121         call_hooks('about_hook', $o);
122
123         return $o;
124 }