]> git.mxchange.org Git - friendica.git/blob - mod/oexchange.php
Merge pull request #4312 from zeroadam/feature/L10n
[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
10 function oexchange_init(App $a) {
11
12         if (($a->argc > 1) && ($a->argv[1] === 'xrd')) {
13                 $tpl = get_markup_template('oexchange_xrd.tpl');
14
15                 $o = replace_macros($tpl, ['$base' => System::baseUrl()]);
16                 echo $o;
17                 killme();
18         }
19 }
20
21 function oexchange_content(App $a) {
22
23         if (! local_user()) {
24                 $o = Login::form();
25                 return $o;
26         }
27
28         if (($a->argc > 1) && $a->argv[1] === 'done') {
29                 info(L10n::t('Post successful.') . EOL);
30                 return;
31         }
32
33         $url = (((x($_REQUEST,'url')) && strlen($_REQUEST['url']))
34                 ? urlencode(notags(trim($_REQUEST['url']))) : '');
35         $title = (((x($_REQUEST,'title')) && strlen($_REQUEST['title']))
36                 ? '&title=' . urlencode(notags(trim($_REQUEST['title']))) : '');
37         $description = (((x($_REQUEST,'description')) && strlen($_REQUEST['description']))
38                 ? '&description=' . urlencode(notags(trim($_REQUEST['description']))) : '');
39         $tags = (((x($_REQUEST,'tags')) && strlen($_REQUEST['tags']))
40                 ? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : '');
41
42         $s = fetch_url(System::baseUrl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
43
44         if (! strlen($s)) {
45                 return;
46         }
47
48         require_once('include/html2bbcode.php');
49
50         $post = [];
51
52         $post['profile_uid'] = local_user();
53         $post['return'] = '/oexchange/done' ;
54         $post['body'] = html2bbcode($s);
55         $post['type'] = 'wall';
56
57         $_REQUEST = $post;
58         require_once('mod/item.php');
59         item_post($a);
60 }