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