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