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