2011-03-30 04:59:28 +00:00
|
|
|
<?php
|
2018-01-21 18:33:59 +00:00
|
|
|
/**
|
|
|
|
* @file mod/oexchange.php
|
|
|
|
*/
|
2017-04-30 04:07:00 +00:00
|
|
|
use Friendica\App;
|
2018-01-21 18:33:59 +00:00
|
|
|
use Friendica\Core\L10n;
|
2017-08-26 06:04:21 +00:00
|
|
|
use Friendica\Core\System;
|
2017-12-17 16:40:59 +00:00
|
|
|
use Friendica\Module\Login;
|
2018-01-27 04:09:48 +00:00
|
|
|
use Friendica\Util\Network;
|
2017-04-30 04:07:00 +00:00
|
|
|
|
2017-01-09 12:14:25 +00:00
|
|
|
function oexchange_init(App $a) {
|
2011-03-30 04:59:28 +00:00
|
|
|
|
2017-01-09 23:10:32 +00:00
|
|
|
if (($a->argc > 1) && ($a->argv[1] === 'xrd')) {
|
2011-05-11 11:37:13 +00:00
|
|
|
$tpl = get_markup_template('oexchange_xrd.tpl');
|
2011-03-30 04:59:28 +00:00
|
|
|
|
2018-01-15 13:05:12 +00:00
|
|
|
$o = replace_macros($tpl, ['$base' => System::baseUrl()]);
|
2011-03-30 04:59:28 +00:00
|
|
|
echo $o;
|
|
|
|
killme();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-09 12:14:25 +00:00
|
|
|
function oexchange_content(App $a) {
|
2011-03-30 04:59:28 +00:00
|
|
|
|
2018-07-19 13:52:05 +00:00
|
|
|
if (!local_user()) {
|
2017-12-17 16:40:59 +00:00
|
|
|
$o = Login::form();
|
2011-03-30 04:59:28 +00:00
|
|
|
return $o;
|
|
|
|
}
|
|
|
|
|
2016-12-20 10:56:34 +00:00
|
|
|
if (($a->argc > 1) && $a->argv[1] === 'done') {
|
2018-01-21 18:33:59 +00:00
|
|
|
info(L10n::t('Post successful.') . EOL);
|
2011-03-30 04:59:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-19 13:52:05 +00:00
|
|
|
$url = ((x($_REQUEST,'url') && strlen($_REQUEST['url']))
|
2012-02-16 02:13:41 +00:00
|
|
|
? urlencode(notags(trim($_REQUEST['url']))) : '');
|
2018-07-19 13:52:05 +00:00
|
|
|
$title = ((x($_REQUEST,'title') && strlen($_REQUEST['title']))
|
2012-02-16 02:13:41 +00:00
|
|
|
? '&title=' . urlencode(notags(trim($_REQUEST['title']))) : '');
|
2018-07-19 13:52:05 +00:00
|
|
|
$description = ((x($_REQUEST,'description') && strlen($_REQUEST['description']))
|
2012-02-16 02:13:41 +00:00
|
|
|
? '&description=' . urlencode(notags(trim($_REQUEST['description']))) : '');
|
2018-07-19 13:52:05 +00:00
|
|
|
$tags = ((x($_REQUEST,'tags') && strlen($_REQUEST['tags']))
|
2012-02-16 02:13:41 +00:00
|
|
|
? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : '');
|
2011-09-20 23:57:05 +00:00
|
|
|
|
2018-01-27 16:13:41 +00:00
|
|
|
$s = Network::fetchUrl(System::baseUrl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
|
2011-03-30 04:59:28 +00:00
|
|
|
|
2018-07-19 13:52:05 +00:00
|
|
|
if (!strlen($s)) {
|
2011-03-30 04:59:28 +00:00
|
|
|
return;
|
2017-01-09 23:10:32 +00:00
|
|
|
}
|
2011-03-30 04:59:28 +00:00
|
|
|
|
2018-01-15 13:05:12 +00:00
|
|
|
$post = [];
|
2011-03-30 04:59:28 +00:00
|
|
|
|
|
|
|
$post['profile_uid'] = local_user();
|
2018-07-19 13:52:05 +00:00
|
|
|
$post['return'] = '/oexchange/done';
|
2018-03-07 21:24:13 +00:00
|
|
|
$post['body'] = Friendica\Content\Text\HTML::toBBCode($s);
|
2011-03-30 04:59:28 +00:00
|
|
|
|
2012-02-16 10:52:35 +00:00
|
|
|
$_REQUEST = $post;
|
2011-03-30 04:59:28 +00:00
|
|
|
require_once('mod/item.php');
|
|
|
|
item_post($a);
|
|
|
|
}
|