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