aboutsummaryrefslogtreecommitdiffstats
path: root/include/items.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/items.php')
-rw-r--r--include/items.php289
1 files changed, 0 insertions, 289 deletions
diff --git a/include/items.php b/include/items.php
index ba4e79a75..5bb99c91c 100644
--- a/include/items.php
+++ b/include/items.php
@@ -1502,143 +1502,6 @@ function encode_item_flags($item) {
return $ret;
}
-function encode_mail($item,$extended = false) {
- $x = [];
- $x['type'] = 'mail';
- $x['encoding'] = 'zot';
-
- if(array_key_exists('mail_obscured',$item) && intval($item['mail_obscured'])) {
- if($item['title'])
- $item['title'] = base64url_decode(str_rot47($item['title']));
- if($item['body'])
- $item['body'] = base64url_decode(str_rot47($item['body']));
- }
-
- $x['message_id'] = $item['mid'];
- $x['message_parent'] = $item['parent_mid'];
- $x['created'] = $item['created'];
- $x['expires'] = $item['expires'];
- $x['title'] = $item['title'];
- $x['body'] = $item['body'];
- $x['from'] = encode_item_xchan($item['from']);
- $x['to'] = encode_item_xchan($item['to']);
- $x['raw'] = $item['mail_raw'];
- $x['mimetype'] = $item['mail_mimetype'];
- $x['sig'] = $item['sig'];
-
- if($item['attach'])
- $x['attach'] = json_decode($item['attach'],true);
-
- $x['flags'] = array();
-
- if(intval($item['mail_recalled'])) {
- $x['flags'][] = 'recalled';
- $x['title'] = '';
- $x['body'] = '';
- }
-
- if($extended) {
- $x['conv_guid'] = $item['conv_guid'];
- if(intval($item['mail_deleted']))
- $x['flags'][] = 'deleted';
- if(intval($item['mail_replied']))
- $x['flags'][] = 'replied';
- if(intval($item['mail_isreply']))
- $x['flags'][] = 'isreply';
- if(intval($item['mail_seen']))
- $x['flags'][] = 'seen';
- }
-
- return $x;
-}
-
-
-
-function get_mail_elements($x) {
-
- $arr = array();
-
- if(intval($x['raw'])) {
- $arr['mail_raw'] = intval($x['raw']);
- $arr['body'] = $x['body'];
- }
- else {
- $arr['body'] = (($x['body']) ? htmlspecialchars($x['body'], ENT_COMPAT,'UTF-8',false) : '');
-
- $maxlen = get_max_import_size();
-
- if($maxlen && mb_strlen($arr['body']) > $maxlen) {
- $arr['body'] = mb_substr($arr['body'],0,$maxlen,'UTF-8');
- logger('message length exceeds max_import_size: truncated');
- }
- }
-
- $arr['title'] = (($x['title'])? htmlspecialchars($x['title'],ENT_COMPAT,'UTF-8',false) : '');
- $arr['mail_mimetype'] = (($x['mimetype']) ? htmlspecialchars($x['mimetype'],ENT_COMPAT,'UTF-8',false) : 'text/bbcode');
- $arr['conv_guid'] = (($x['conv_guid'])? htmlspecialchars($x['conv_guid'],ENT_COMPAT,'UTF-8',false) : '');
-
- $arr['created'] = datetime_convert('UTC','UTC',$x['created']);
- if((! array_key_exists('expires',$x)) || ($x['expires'] <= NULL_DATE))
- $arr['expires'] = NULL_DATE;
- else
- $arr['expires'] = datetime_convert('UTC','UTC',$x['expires']);
-
- $arr['mail_flags'] = 0;
-
- if(array_key_exists('sig',$x))
- $arr['sig'] = $x['sig'];
-
- if($x['flags'] && is_array($x['flags'])) {
- if(in_array('recalled',$x['flags'])) {
- $arr['mail_recalled'] = 1;
- }
- if(in_array('replied',$x['flags'])) {
- $arr['mail_replied'] = 1;
- }
- if(in_array('isreply',$x['flags'])) {
- $arr['mail_isreply'] = 1;
- }
- if(in_array('seen',$x['flags'])) {
- $arr['mail_seen'] = 1;
- }
- if(in_array('deleted',$x['flags'])) {
- $arr['mail_deleted'] = 1;
- }
- }
-
- $key = get_config('system','pubkey');
- $arr['mail_obscured'] = 1;
- if($arr['body']) {
- $arr['body'] = str_rot47(base64url_encode($arr['body']));
- }
-
- if($arr['title']) {
- $arr['title'] = str_rot47(base64url_encode($arr['title']));
- }
- if($arr['created'] > datetime_convert())
- $arr['created'] = datetime_convert();
-
-
- $arr['mid'] = (($x['message_id']) ? htmlspecialchars($x['message_id'], ENT_COMPAT,'UTF-8',false) : '');
- $arr['parent_mid'] = (($x['message_parent']) ? htmlspecialchars($x['message_parent'], ENT_COMPAT,'UTF-8',false) : '');
-
- if($x['attach'])
- $arr['attach'] = activity_sanitise($x['attach']);
-
- if(($xchan_hash = import_author_xchan($x['from'])) !== false)
- $arr['from_xchan'] = $xchan_hash;
- else
- return array();
-
- if(($xchan_hash = import_author_xchan($x['to'])) !== false)
- $arr['to_xchan'] = $xchan_hash;
- else
- return array();
-
- return $arr;
-}
-
-
function get_profile_elements($x) {
$arr = array();
@@ -3513,158 +3376,6 @@ function post_is_importable($item,$abook) {
}
-
-function mail_store($arr) {
-
- if(! $arr['channel_id']) {
- logger('mail_store: no uid');
- return 0;
- }
-
- $channel = channelx_by_n($arr['channel_id']);
-
- if(! $arr['mail_obscured']) {
- if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false))
- $arr['body'] = escape_tags($arr['body']);
- }
-
- if(array_key_exists('attach',$arr)) {
- if(is_array($arr['attach'])) {
- $arr['attach'] = json_encode($arr['attach']);
- }
- }
- else {
- $arr['attach'] = '';
- }
-
- $arr['account_id'] = ((x($arr,'account_id')) ? intval($arr['account_id']) : 0);
- $arr['mid'] = ((x($arr,'mid')) ? notags(trim($arr['mid'])) : random_string());
- $arr['from_xchan'] = ((x($arr,'from_xchan')) ? notags(trim($arr['from_xchan'])) : '');
- $arr['to_xchan'] = ((x($arr,'to_xchan')) ? notags(trim($arr['to_xchan'])) : '');
- $arr['created'] = ((x($arr,'created') !== false) ? datetime_convert('UTC','UTC',$arr['created']) : datetime_convert());
- $arr['expires'] = ((x($arr,'expires') !== false) ? datetime_convert('UTC','UTC',$arr['expires']) : NULL_DATE);
- $arr['title'] = ((x($arr,'title')) ? trim($arr['title']) : '');
- $arr['parent_mid'] = ((x($arr,'parent_mid')) ? notags(trim($arr['parent_mid'])) : '');
- $arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : '');
- $arr['sig'] = ((x($arr,'sig')) ? trim($arr['sig']) : '');
- $arr['conv_guid'] = ((x($arr,'conv_guid')) ? trim($arr['conv_guid']) : '');
- $arr['mail_mimetype'] = ((x($arr,'mail_mimetype')) ? trim($arr['mail_mimetype']) : 'text/bbcode');
-
- $arr['mail_flags'] = ((x($arr,'mail_flags')) ? intval($arr['mail_flags']) : 0 );
- $arr['mail_raw'] = ((x($arr,'mail_raw')) ? intval($arr['mail_raw']) : 0 );
-
-
- if($arr['parent_mid']) {
- $parent_item = q("select * from mail where mid = '%s' and channel_id = %d limit 1",
- dbesc($arr['parent_mid']),
- intval($arr['channel_id'])
- );
- if(($parent_item) && (! $arr['conv_guid'])) {
- $arr['conv_guid'] = $parent_item[0]['conv_guid'];
- }
- }
- else {
- logger('mail_store: missing parent');
- $arr['parent_mid'] = $arr['mid'];
- }
-
- if($arr['from_xchan'] === $channel['channel_hash'])
- $conversant = $arr['to_xchan'];
- else
- $conversant = $arr['from_xchan'];
-
-
- if(! $arr['conv_guid']) {
- $x = create_conversation($channel,$conversant,(($arr['title']) ? base64url_decode(str_rot47($arr['title'])) : ''));
- $arr['conv_guid'] = (($x) ? $x['guid'] : '');
- }
-
-
- $r = q("SELECT id FROM mail WHERE mid = '%s' AND channel_id = %d LIMIT 1",
- dbesc($arr['mid']),
- intval($arr['channel_id'])
- );
-
- if($r) {
- logger('Duplicate item ignored. ' . print_r($arr,true));
- return 0;
- }
-
- if(! $r && $arr['mail_recalled'] == 1) {
- logger('Recalled item not found. ' . print_r($arr,true));
- return 0;
- }
-
- /**
- * @hooks post_mail
- * Called when a mail message has been composed.
- */
- call_hooks('post_mail', $arr);
-
- if(x($arr,'cancel')) {
- logger('Post cancelled by plugin.');
- return 0;
- }
-
- logger('mail_store: ' . print_r($arr,true), LOGGER_DATA);
-
- create_table_from_array('mail', $arr);
-
- // find the item we just created
-
- $r = q("SELECT id FROM mail WHERE mid = '%s' AND channel_id = %d ORDER BY id ASC ",
- $arr['mid'], // already dbesc'd
- intval($arr['channel_id'])
- );
-
- if($r) {
- $current_post = $r[0]['id'];
- logger('Created item ' . $current_post, LOGGER_DEBUG);
- $arr['id'] = $current_post; // for notification
- }
- else {
- logger('Could not locate created item');
- return 0;
- }
- if(count($r) > 1) {
- logger('Duplicated post occurred. Removing duplicates.');
- q("DELETE FROM mail WHERE mid = '%s' AND channel_id = %d AND id != %d ",
- $arr['mid'],
- intval($arr['channel_id']),
- intval($current_post)
- );
- }
- else {
-
- $notif_params = array(
- 'from_xchan' => $arr['from_xchan'],
- 'to_xchan' => $arr['to_xchan'],
- 'type' => NOTIFY_MAIL,
- 'item' => $arr,
- 'verb' => ACTIVITY_POST,
- 'otype' => 'mail'
- );
-
- Enotify::submit($notif_params);
- }
-
- if($arr['conv_guid']) {
- $c = q("update conv set updated = '%s' where guid = '%s' and uid = %d",
- dbesc(datetime_convert()),
- dbesc($arr['conv_guid']),
- intval($arr['channel_id'])
- );
- }
-
- /**
- * @hooks post_mail_end
- * Called when a mail message has been delivered.
- */
- call_hooks('post_mail_end', $arr);
- return $current_post;
-}
-
-
function fix_private_photos($s, $uid, $item = null, $cid = 0) {
logger('fix_private_photos', LOGGER_DEBUG);