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