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