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