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