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