]> git.mxchange.org Git - friendica.git/blob - mod/hcard.php
Fixes:
[friendica.git] / mod / hcard.php
1 <?php
2 /**
3  * @file mod/hcard.php
4  */
5 use Friendica\App;
6 use Friendica\Core\Config;
7 use Friendica\Core\L10n;
8 use Friendica\Core\System;
9 use Friendica\Model\Profile;
10
11 function hcard_init(App $a)
12 {
13         $blocked = Config::get('system', 'block_public') && !local_user() && !remote_user();
14
15         if ($a->argc > 1) {
16                 $which = $a->argv[1];
17         } else {
18                 notice(L10n::t('No profile') . EOL);
19                 $a->error = 404;
20                 return;
21         }
22
23         $profile = 0;
24         if ((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
25                 $which   = $a->user['nickname'];
26                 $profile = $a->argv[1];
27         }
28
29         Profile::load($a, $which, $profile);
30
31         if ((x($a->profile, 'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
32                 $a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
33         }
34         if (x($a->profile, 'openidserver')) {
35                 $a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
36         }
37         if (x($a->profile, 'openid')) {
38                 $delegate = ((strstr($a->profile['openid'], '://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
39                 $a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
40         }
41
42         if (!$blocked) {
43                 $keywords = ((x($a->profile, 'pub_keywords')) ? $a->profile['pub_keywords'] : '');
44                 $keywords = str_replace([',',' ',',,'], [' ',',',','], $keywords);
45                 if (strlen($keywords)) {
46                         $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
47                 }
48         }
49
50         $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
51         $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
52         $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->urlpath) ? '/' . $a->urlpath : ''));
53         $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
54         header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
55
56         $dfrn_pages = ['request', 'confirm', 'notify', 'poll'];
57         foreach ($dfrn_pages as $dfrn) {
58                 $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".System::baseUrl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
59         }
60 }