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