]> git.mxchange.org Git - friendica.git/blob - mod/oexchange.php
oexchange updates to new bookmark API
[friendica.git] / mod / oexchange.php
1 <?php
2
3
4 function oexchange_init(&$a) {
5
6         if(($a->argc > 1) && ($a->argv[1] === 'xrd')) {
7                 $tpl = get_markup_template('oexchange_xrd.tpl');
8
9                 $o = replace_macros($tpl, array('$base' => $a->get_baseurl()));
10                 echo $o;
11                 killme();
12         }
13
14                 
15
16
17 }
18
19 function oexchange_content(&$a) {
20
21         if(! local_user()) {
22                 $o = login(false);
23                 return $o;
24         }
25
26         if(($a->argc > 1) && $a->argv[1] === 'done') {
27                 info( t('Post successful.') . EOL);
28                 return;
29         }
30
31         $url = (((x($_GET,'url')) && strlen($_GET['url'])) 
32                 ? urlencode(notags(trim($_GET['url']))) : '');
33         $title = (((x($_GET,'title')) && strlen($_GET['title'])) 
34                 ? '&title=' . urlencode(notags(trim($_GET['title']))) : '');
35         $description = (((x($_GET,'description')) && strlen($_GET['description'])) 
36                 ? '&description=' . urlencode(notags(trim($_GET['description']))) : '');
37         $tags = (((x($_GET,'tags')) && strlen($_GET['tags'])) 
38                 ? '&tags=' . urlencode(notags(trim($_GET['tags']))) : '');
39
40         $s = fetch_url($a->get_baseurl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
41
42         if(! strlen($s))
43                 return;
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         $_POST = $post;
55         require_once('mod/item.php');
56         item_post($a);
57
58 }
59
60