]> git.mxchange.org Git - friendica.git/blob - mod/oexchange.php
Merge branch 'develop' into task/3954-move-auth-to-src
[friendica.git] / mod / oexchange.php
1 <?php
2
3 use Friendica\App;
4 use Friendica\Core\System;
5 use Friendica\Module\Login;
6
7 function oexchange_init(App $a) {
8
9         if (($a->argc > 1) && ($a->argv[1] === 'xrd')) {
10                 $tpl = get_markup_template('oexchange_xrd.tpl');
11
12                 $o = replace_macros($tpl, array('$base' => System::baseUrl()));
13                 echo $o;
14                 killme();
15         }
16 }
17
18 function oexchange_content(App $a) {
19
20         if (! local_user()) {
21                 $o = Login::form();
22                 return $o;
23         }
24
25         if (($a->argc > 1) && $a->argv[1] === 'done') {
26                 info( t('Post successful.') . EOL);
27                 return;
28         }
29
30         $url = (((x($_REQUEST,'url')) && strlen($_REQUEST['url']))
31                 ? urlencode(notags(trim($_REQUEST['url']))) : '');
32         $title = (((x($_REQUEST,'title')) && strlen($_REQUEST['title']))
33                 ? '&title=' . urlencode(notags(trim($_REQUEST['title']))) : '');
34         $description = (((x($_REQUEST,'description')) && strlen($_REQUEST['description']))
35                 ? '&description=' . urlencode(notags(trim($_REQUEST['description']))) : '');
36         $tags = (((x($_REQUEST,'tags')) && strlen($_REQUEST['tags']))
37                 ? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : '');
38
39         $s = fetch_url(System::baseUrl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
40
41         if (! strlen($s)) {
42                 return;
43         }
44
45         require_once('include/html2bbcode.php');
46
47         $post = array();
48
49         $post['profile_uid'] = local_user();
50         $post['return'] = '/oexchange/done' ;
51         $post['body'] = html2bbcode($s);
52         $post['type'] = 'wall';
53
54         $_REQUEST = $post;
55         require_once('mod/item.php');
56         item_post($a);
57 }