]> git.mxchange.org Git - friendica.git/blob - mod/oexchange.php
Make frio more consistent by replacing textual links with icons everywhere. (#5415)
[friendica.git] / mod / oexchange.php
1 <?php
2 /**
3  * @file mod/oexchange.php
4  */
5 use Friendica\App;
6 use Friendica\Core\L10n;
7 use Friendica\Core\System;
8 use Friendica\Module\Login;
9 use Friendica\Util\Network;
10
11 function oexchange_init(App $a) {
12
13         if (($a->argc > 1) && ($a->argv[1] === 'xrd')) {
14                 $tpl = get_markup_template('oexchange_xrd.tpl');
15
16                 $o = replace_macros($tpl, ['$base' => System::baseUrl()]);
17                 echo $o;
18                 killme();
19         }
20 }
21
22 function oexchange_content(App $a) {
23
24         if (!local_user()) {
25                 $o = Login::form();
26                 return $o;
27         }
28
29         if (($a->argc > 1) && $a->argv[1] === 'done') {
30                 info(L10n::t('Post successful.') . EOL);
31                 return;
32         }
33
34         $url = ((x($_REQUEST,'url') && strlen($_REQUEST['url']))
35                 ? urlencode(notags(trim($_REQUEST['url']))) : '');
36         $title = ((x($_REQUEST,'title') && strlen($_REQUEST['title']))
37                 ? '&title=' . urlencode(notags(trim($_REQUEST['title']))) : '');
38         $description = ((x($_REQUEST,'description') && strlen($_REQUEST['description']))
39                 ? '&description=' . urlencode(notags(trim($_REQUEST['description']))) : '');
40         $tags = ((x($_REQUEST,'tags') && strlen($_REQUEST['tags']))
41                 ? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : '');
42
43         $s = Network::fetchUrl(System::baseUrl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
44
45         if (!strlen($s)) {
46                 return;
47         }
48
49         $post = [];
50
51         $post['profile_uid'] = local_user();
52         $post['return'] = '/oexchange/done';
53         $post['body'] = Friendica\Content\Text\HTML::toBBCode($s);
54
55         $_REQUEST = $post;
56         require_once('mod/item.php');
57         item_post($a);
58 }