]> git.mxchange.org Git - friendica.git/blob - mod/friendica.php
Merge pull request #2148 from annando/issue-1871
[friendica.git] / mod / friendica.php
1 <?php
2
3 function friendica_init(&$a) {
4         if ($a->argv[1]=="json"){
5                 $register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
6
7                 $sql_extra = '';
8                 if(x($a->config,'admin_nickname')) {
9                         $sql_extra = sprintf(" AND nickname = '%s' ",dbesc($a->config['admin_nickname']));
10                 }
11                 if (isset($a->config['admin_email']) && $a->config['admin_email']!=''){
12                         $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
13
14                         //$r = q("SELECT username, nickname FROM user WHERE email='%s' $sql_extra", dbesc($a->config['admin_email']));
15                         $r = q("SELECT username, nickname FROM user WHERE email='%s' $sql_extra", dbesc($adminlist[0]));
16                         $admin = array(
17                                 'name' => $r[0]['username'],
18                                 'profile'=> $a->get_baseurl().'/profile/'.$r[0]['nickname'],
19                         );
20                 } else {
21                         $admin = false;
22                 }
23
24                 $visible_plugins = array();
25                 if(is_array($a->plugins) && count($a->plugins)) {
26                         $r = q("select * from addon where hidden = 0");
27                         if(count($r))
28                                 foreach($r as $rr)
29                                         $visible_plugins[] = $rr['name'];
30                 }
31
32                 $data = Array(
33                         'version' => FRIENDICA_VERSION,
34                         'url' => z_root(),
35                         'plugins' => $visible_plugins,
36                         'register_policy' =>  $register_policy[$a->config['register_policy']],
37                         'admin' => $admin,
38                         'site_name' => $a->config['sitename'],
39                         'platform' => FRIENDICA_PLATFORM,
40                         'info' => ((x($a->config,'info')) ? $a->config['info'] : ''),
41                         'no_scrape_url' => $a->get_baseurl().'/noscrape'
42                 );
43
44                 echo json_encode($data);
45                 killme();
46         }
47 }
48
49
50
51 function friendica_content(&$a) {
52
53         $o = '';
54         $o .= '<h3>Friendica</h3>';
55
56
57         $o .= '<p></p><p>';
58
59         $o .= t('This is Friendica, version') . ' ' . FRIENDICA_VERSION . ' ';
60         $o .= t('running at web location') . ' ' . z_root() . '</p><p>';
61
62         $o .= t('Please visit <a href="http://friendica.com">Friendica.com</a> to learn more about the Friendica project.') . '</p><p>';        
63
64         $o .= t('Bug reports and issues: please visit') . ' ' . '<a href="https://github.com/friendica/friendica/issues?state=open">'.t('the bugtracker at github').'</a></p><p>';
65         $o .= t('Suggestions, praise, donations, etc. - please email "Info" at Friendica - dot com') . '</p>';
66
67         $o .= '<p></p>';
68
69         $visible_plugins = array();
70         if(is_array($a->plugins) && count($a->plugins)) {
71                 $r = q("select * from addon where hidden = 0");
72                 if(count($r))
73                         foreach($r as $rr)
74                                 $visible_plugins[] = $rr['name'];
75         }
76
77
78         if(count($visible_plugins)) {
79                 $o .= '<p>' . t('Installed plugins/addons/apps:') . '</p>';
80                 $sorted = $visible_plugins;
81                 $s = '';
82                 sort($sorted);
83                 foreach($sorted as $p) {
84                         if(strlen($p)) {
85                                 if(strlen($s)) $s .= ', ';
86                                 $s .= $p;
87                         }
88                 }
89                 $o .= '<div style="margin-left: 25px; margin-right: 25px;">' . $s . '</div>';
90         }
91         else
92                 $o .= '<p>' . t('No installed plugins/addons/apps') . '</p>';
93
94         call_hooks('about_hook', $o);   
95
96         return $o;
97
98 }