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