aboutsummaryrefslogtreecommitdiffstats
path: root/include/items.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/items.php')
-rwxr-xr-xinclude/items.php55
1 files changed, 39 insertions, 16 deletions
diff --git a/include/items.php b/include/items.php
index 1009530a4..01b4a3460 100755
--- a/include/items.php
+++ b/include/items.php
@@ -161,7 +161,7 @@ function filter_insecure($channel_id, $arr) {
$ret = array();
- if((! intval(get_config($channel_id, 'system', 'filter_insecure_collections'))) || (! $arr))
+ if((! intval(get_pconfig($channel_id, 'system', 'filter_insecure_collections'))) || (! $arr))
return $arr;
$str = '';
@@ -866,6 +866,9 @@ function get_item_elements($x) {
$arr['sig'] = (($x['signature']) ? htmlspecialchars($x['signature'], ENT_COMPAT,'UTF-8',false) : '');
+ if(array_key_exists('diaspora_signature',$x) && is_array($x['diaspora_signature']))
+ $x['diaspora_signature'] = json_encode($x['diaspora_signature']);
+
$arr['diaspora_meta'] = (($x['diaspora_signature']) ? json_encode(crypto_encapsulate($x['diaspora_signature'],$key)) : '');
$arr['object'] = activity_sanitise($x['object']);
$arr['target'] = activity_sanitise($x['target']);
@@ -1198,12 +1201,15 @@ function encode_item($item,$mirror = false) {
case 2:
$x['item_restrict'] |= ITEM_PDL;
break;
- case 2:
+ case 3:
$x['item_restrict'] |= ITEM_WEBPAGE;
break;
- case 2:
+ case 4:
$x['item_restrict'] |= ITEM_BUG;
break;
+ case 5:
+ $x['item_restrict'] |= ITEM_DOC;
+ break;
default:
break;
}
@@ -2654,11 +2660,12 @@ function item_store_update($arr,$allow_exec = false) {
return $ret;
}
+ $r = q("delete from term where oid = %d and otype = %d",
+ intval($orig_post_id),
+ intval(TERM_OBJ_POST)
+ );
+
if(is_array($terms)) {
- $r = q("delete from term where oid = %d and otype = %d",
- intval($orig_post_id),
- intval(TERM_OBJ_POST)
- );
foreach($terms as $t) {
q("insert into term (uid,oid,otype,type,term,url)
values(%d,%d,%d,%d,'%s','%s') ",
@@ -2670,7 +2677,6 @@ function item_store_update($arr,$allow_exec = false) {
dbesc($t['url'])
);
}
-
$arr['term'] = $terms;
}
@@ -3332,6 +3338,9 @@ function check_item_source($uid, $item) {
if($r[0]['src_channel_xchan'] === $item['owner_xchan'])
return false;
+
+ // since we now have connection filters with more features, the source filter is redundant and can probably go away
+
if(! $r[0]['src_patt'])
return true;
@@ -3346,10 +3355,10 @@ function check_item_source($uid, $item) {
foreach($words as $word) {
if(substr($word,0,1) === '#' && $tags) {
foreach($tags as $t)
- if(($t['type'] == TERM_HASHTAG) && ((substr($t,1) === substr($word,1)) || (substr($word,1) === '*')))
+ if(($t['type'] == TERM_HASHTAG) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*')))
return true;
}
- elseif((strpos($word,'/') === 0) && preg_match($word,$body))
+ elseif((strpos($word,'/') === 0) && preg_match($word,$text))
return true;
elseif(stristr($text,$word) !== false)
return true;
@@ -3370,14 +3379,21 @@ function post_is_importable($item,$abook) {
if(! $item)
return false;
- if((! $abook['abook_incl']) && (! $abook['abook_excl']))
+ if(! ($abook['abook_incl'] || $abook['abook_excl']))
return true;
-
require_once('include/html2plain.php');
+
+ unobscure($item);
+
$text = prepare_text($item['body'],$item['mimetype']);
$text = html2plain($text);
+ $lang = null;
+
+ if((strpos($abook['abook_incl'],'lang=') !== false) || (strpos($abook['abook_excl'],'lang=') !== false)) {
+ $lang = detect_language($text);
+ }
$tags = ((count($item['term'])) ? $item['term'] : false);
// exclude always has priority
@@ -3389,10 +3405,12 @@ function post_is_importable($item,$abook) {
$word = trim($word);
if(substr($word,0,1) === '#' && $tags) {
foreach($tags as $t)
- if(($t['type'] == TERM_HASHTAG) && ((substr($t,1) === substr($word,1)) || (substr($word,1) === '*')))
+ if(($t['type'] == TERM_HASHTAG) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*')))
return false;
}
- elseif((strpos($word,'/') === 0) && preg_match($word,$body))
+ elseif((strpos($word,'/') === 0) && preg_match($word,$text))
+ return false;
+ elseif((strpos($word,'lang=') === 0) && ($lang) && (strcasecmp($lang,trim(substr($word,5))) == 0))
return false;
elseif(stristr($text,$word) !== false)
return false;
@@ -3406,10 +3424,12 @@ function post_is_importable($item,$abook) {
$word = trim($word);
if(substr($word,0,1) === '#' && $tags) {
foreach($tags as $t)
- if(($t['type'] == TERM_HASHTAG) && ((substr($t,1) === substr($word,1)) || (substr($word,1) === '*')))
+ if(($t['type'] == TERM_HASHTAG) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*')))
return true;
}
- elseif((strpos($word,'/') === 0) && preg_match($word,$body))
+ elseif((strpos($word,'/') === 0) && preg_match($word,$text))
+ return true;
+ elseif((strpos($word,'lang=') === 0) && ($lang) && (strcasecmp($lang,trim(substr($word,5))) == 0))
return true;
elseif(stristr($text,$word) !== false)
return true;
@@ -3751,6 +3771,9 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
$author['owner_avatar'] = $contact['thumb'];
}
+ if(! post_is_importable($datarray,$contact))
+ continue;
+
logger('consume_feed: author ' . print_r($author,true),LOGGER_DEBUG);
logger('consume_feed: ' . print_r($datarray,true),LOGGER_DATA);