2015-08-23 22:38:18 +02:00
|
|
|
<?php /** @file */
|
|
|
|
|
2016-04-17 16:29:18 +02:00
|
|
|
require_once('include/acl_selectors.php');
|
2015-08-23 22:38:18 +02:00
|
|
|
require_once('include/crypto.php');
|
|
|
|
require_once('include/items.php');
|
|
|
|
require_once('include/taxonomy.php');
|
|
|
|
require_once('include/conversation.php');
|
|
|
|
require_once('include/zot.php');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* remote post
|
|
|
|
*
|
|
|
|
* https://yoursite/rpost?f=&title=&body=&remote_return=
|
|
|
|
*
|
|
|
|
* This can be called via either GET or POST, use POST for long body content as suhosin often limits GET parameter length
|
|
|
|
*
|
|
|
|
* f= placeholder, often required
|
|
|
|
* title= Title of post
|
|
|
|
* body= Body of post
|
|
|
|
* url= URL which will be parsed and the results appended to the body
|
|
|
|
* source= Source application
|
|
|
|
* remote_return= absolute URL to return after posting is finished
|
|
|
|
* type= choices are 'html' or 'bbcode', default is 'bbcode'
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function rpost_content(&$a) {
|
|
|
|
|
|
|
|
$o = '';
|
|
|
|
|
|
|
|
if(! local_channel()) {
|
|
|
|
if(remote_channel()) {
|
|
|
|
// redirect to your own site.
|
|
|
|
// We can only do this with a GET request so you'll need to keep the text short or risk getting truncated
|
|
|
|
// by the wretched beast called 'suhosin'. All the browsers now allow long GET requests, but suhosin
|
|
|
|
// blocks them.
|
|
|
|
|
2016-04-17 16:29:18 +02:00
|
|
|
$url = get_rpost_path(App::get_observer());
|
2015-08-23 22:38:18 +02:00
|
|
|
// make sure we're not looping to our own hub
|
2016-04-17 16:29:18 +02:00
|
|
|
if(($url) && (! stristr($url, App::get_hostname()))) {
|
2015-08-23 22:38:18 +02:00
|
|
|
foreach($_REQUEST as $key => $arg) {
|
|
|
|
$url .= '&' . $key . '=' . $arg;
|
|
|
|
}
|
|
|
|
goaway($url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The login procedure is going to bugger our $_REQUEST variables
|
|
|
|
// so save them in the session.
|
|
|
|
|
|
|
|
if(array_key_exists('body',$_REQUEST)) {
|
|
|
|
$_SESSION['rpost'] = $_REQUEST;
|
|
|
|
}
|
|
|
|
return login();
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we have saved rpost session variables, but nothing in the current $_REQUEST, recover the saved variables
|
|
|
|
|
|
|
|
if((! array_key_exists('body',$_REQUEST)) && (array_key_exists('rpost',$_SESSION))) {
|
|
|
|
$_REQUEST = $_SESSION['rpost'];
|
|
|
|
unset($_SESSION['rpost']);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(array_key_exists('channel',$_REQUEST)) {
|
|
|
|
$r = q("select channel_id from channel where channel_account_id = %d and channel_address = '%s' limit 1",
|
|
|
|
intval(get_account_id()),
|
|
|
|
dbesc($_REQUEST['channel'])
|
|
|
|
);
|
|
|
|
if($r) {
|
|
|
|
require_once('include/security.php');
|
|
|
|
$change = change_channel($r[0]['channel_id']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($_REQUEST['remote_return']) {
|
|
|
|
$_SESSION['remote_return'] = $_REQUEST['remote_return'];
|
|
|
|
}
|
|
|
|
if(argc() > 1 && argv(1) === 'return') {
|
|
|
|
if($_SESSION['remote_return'])
|
|
|
|
goaway($_SESSION['remote_return']);
|
|
|
|
goaway(z_root() . '/network');
|
|
|
|
}
|
|
|
|
|
|
|
|
$plaintext = true;
|
|
|
|
// if(feature_enabled(local_channel(),'richtext'))
|
|
|
|
// $plaintext = false;
|
|
|
|
|
|
|
|
if(array_key_exists('type', $_REQUEST) && $_REQUEST['type'] === 'html') {
|
|
|
|
require_once('include/html2bbcode.php');
|
|
|
|
$_REQUEST['body'] = html2bbcode($_REQUEST['body']);
|
|
|
|
}
|
|
|
|
|
2016-04-17 16:29:18 +02:00
|
|
|
$channel = App::get_channel();
|
2015-08-23 22:38:18 +02:00
|
|
|
|
2015-10-24 13:04:14 +02:00
|
|
|
|
2016-03-20 08:06:33 +01:00
|
|
|
$acl = new Zotlabs\Access\AccessList($channel);
|
2015-10-24 13:04:14 +02:00
|
|
|
|
|
|
|
$channel_acl = $acl->get();
|
2015-08-23 22:38:18 +02:00
|
|
|
|
|
|
|
if($_REQUEST['url']) {
|
2015-10-24 13:04:14 +02:00
|
|
|
$x = z_fetch_url(z_root() . '/linkinfo?f=&url=' . urlencode($_REQUEST['url']));
|
2015-08-23 22:38:18 +02:00
|
|
|
if($x['success'])
|
|
|
|
$_REQUEST['body'] = $_REQUEST['body'] . $x['body'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$x = array(
|
|
|
|
'is_owner' => true,
|
|
|
|
'allow_location' => ((intval(get_pconfig($channel['channel_id'],'system','use_browser_location'))) ? '1' : ''),
|
|
|
|
'default_location' => $channel['channel_location'],
|
|
|
|
'nickname' => $channel['channel_address'],
|
2015-10-24 13:04:14 +02:00
|
|
|
'lockstate' => (($acl->is_private()) ? 'lock' : 'unlock'),
|
2016-01-12 02:47:38 +01:00
|
|
|
'acl' => populate_acl($channel_acl,true,(($channel['channel_r_stream'] & PERMS_PUBLIC) ? t('Public') : '')),
|
2015-08-23 22:38:18 +02:00
|
|
|
'bang' => '',
|
|
|
|
'visitor' => true,
|
|
|
|
'profile_uid' => local_channel(),
|
|
|
|
'title' => $_REQUEST['title'],
|
|
|
|
'body' => $_REQUEST['body'],
|
|
|
|
'attachment' => $_REQUEST['attachment'],
|
|
|
|
'source' => ((x($_REQUEST,'source')) ? strip_tags($_REQUEST['source']) : ''),
|
|
|
|
'return_path' => 'rpost/return'
|
|
|
|
);
|
|
|
|
|
|
|
|
$editor = status_editor($a,$x);
|
|
|
|
|
|
|
|
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
|
|
|
|
'$title' => t('Edit post'),
|
|
|
|
'$editor' => $editor
|
|
|
|
));
|
|
|
|
|
|
|
|
return $o;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|