X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fitems.php;h=d1c91b940345d2738ce7b41adb043e8d46c124c4;hb=e40c3a9d7c980c4287c273bc12d934ceb8b55fc0;hp=35e01cbc747ea8efeec031379b85a77bef6d0d14;hpb=c22920edba4f80fee2d828a9fe265a9cb702e81c;p=friendica.git diff --git a/include/items.php b/include/items.php index 35e01cbc74..d1c91b9403 100644 --- a/include/items.php +++ b/include/items.php @@ -364,9 +364,13 @@ function item_add_language_opt(&$arr) { $postopts = ""; } + require_once('library/langdet/Text/LanguageDetect.php'); + $naked_body = preg_replace('/\[(.+?)\]/','', $arr['body']); - $LanguageDetect = new Text_LanguageDetect(); - $lng = $LanguageDetect->detect($naked_body, 3); + $l = new Text_LanguageDetect(); + //$lng = $l->detectConfidence($naked_body); + //$arr['postopts'] = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : ''); + $lng = $l->detect($naked_body, 3); if (sizeof($lng) > 0) { if ($postopts != "") $postopts .= '&'; // arbitrary separator, to be reviewed @@ -568,7 +572,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f $expire_interval = Config::get('system', 'dbclean-expire-days', 0); $r = dba::select('user', array('expire'), array('uid' => $uid), array("limit" => 1)); - if (dbm::is_result($r) && ($r['expire'] > 0) && ($r['expire'] < $expire_interval)) { + if (dbm::is_result($r) && ($r['expire'] > 0) && (($r['expire'] < $expire_interval) || ($expire_interval == 0))) { $expire_interval = $r['expire']; } @@ -757,10 +761,20 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f $arr["author-id"] = get_contact($arr["author-link"], 0); } + if (blockedContact($arr["author-id"])) { + logger('Contact '.$arr["author-id"].' is blocked, item '.$arr["uri"].' will not be stored'); + return 0; + } + if ($arr["owner-id"] == 0) { $arr["owner-id"] = get_contact($arr["owner-link"], 0); } + if (blockedContact($arr["owner-id"])) { + logger('Contact '.$arr["owner-id"].' is blocked, item '.$arr["uri"].' will not be stored'); + return 0; + } + if ($arr['guid'] != "") { // Checking if there is already an item with the same guid logger('checking for an item for user '.$arr['uid'].' on network '.$arr['network'].' with the guid '.$arr['guid'], LOGGER_DEBUG); @@ -1689,7 +1703,7 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) { intval($importer['uid']) ); - if (dbm::is_result($r) && !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) { + if (dbm::is_result($r) && !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY))) { // create notification $hash = random_string(); @@ -1725,7 +1739,7 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) { )); } - } elseif (dbm::is_result($r) && in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) { + } elseif (dbm::is_result($r) && in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY))) { $r = q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1", intval($importer['uid']), dbesc($url)