diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php index 23f99f17..37d2ce5c 100644 --- a/jappixmini/jappixmini.php +++ b/jappixmini/jappixmini.php @@ -86,7 +86,7 @@ function jappixmini_install() // set standard configuration $info_text = Config::get("jappixmini", "infotext"); if (!$info_text) - set_confConfig::setig("jappixmini", "infotext", "To get the chat working, you need to know a BOSH host which works with your Jabber account. " . + Config::set("jappixmini", "infotext", "To get the chat working, you need to know a BOSH host which works with your Jabber account. " . "An example of a BOSH server that works for all accounts is https://bind.jappix.com/, but keep " . "in mind that the BOSH server can read along all chat messages. If you know that your Jabber " . "server also provides an own BOSH server, it is much better to use this one!" diff --git a/nsfw/nsfw.php b/nsfw/nsfw.php index 08107151..836f6541 100644 --- a/nsfw/nsfw.php +++ b/nsfw/nsfw.php @@ -1,5 +1,4 @@ ') : false); + } if (!$cnt) { @@ -86,7 +87,7 @@ function nsfw_addon_settings(&$a, &$s) $s .= ''; $s .= '
'; $s .= ''; - $s .= ''; + $s .= ''; $s .= '
'; $s .= '
'; @@ -102,14 +103,14 @@ function nsfw_addon_settings_post(&$a, &$b) if ($_POST['nsfw-submit']) { PConfig::set(local_user(), 'nsfw', 'words', trim($_POST['nsfw-words'])); - $enable = (x($_POST, 'nsfw-enable') ? intval($_POST['nsfw-enable']) : 0); - $disable = 1 - $enable; + $enable = (x($_POST,'nsfw-enable') ? intval($_POST['nsfw-enable']) : 0); + $disable = 1-$enable; PConfig::set(local_user(), 'nsfw', 'disable', $disable); info(L10n::t('NSFW Settings saved.') . EOL); } } -function nsfw_prepare_body(Friendica\App $a, &$b) +function nsfw_prepare_body(&$a, &$b) { // Don't do the check when there is a content warning if (!empty($b['item']['content-warning'])) { @@ -124,58 +125,45 @@ function nsfw_prepare_body(Friendica\App $a, &$b) if (local_user()) { $words = PConfig::get(local_user(), 'nsfw', 'words'); } - if ($words) { - $word_list = explode(',', $words); + $arr = explode(',', $words); } else { - $word_list = ['nsfw']; + $arr = ['nsfw']; } $found = false; - if (count($word_list)) { + if (count($arr)) { $body = $b['item']['title'] . "\n" . nsfw_extract_photos($b['html']); - foreach ($word_list as $word) { + foreach ($arr as $word) { $word = trim($word); if (!strlen($word)) { continue; } - - switch ($word[0]) { - case '/'; // Regular expression - $found = preg_match($word, $body); + if (strpos($word,'/') === 0) { + if (preg_match($word, $body)) { + $found = true; break; - case '#': // Hashtag-only search - $found = nsfw_find_word_in_item_tags($b['item']['hashtags'], substr($word, 1)); + } + } else { + if (stristr($body, $word)) { + $found = true; break; - default: - $found = stripos($body, $word) !== false || nsfw_find_word_in_item_tags($b['item']['tags'], $word); - break; - } - - if ($found) { - break; + } + if (is_array($b['item']['tags']) && count($b['item']['tags'])) { + foreach ($b['item']['tags'] as $t) { + if (stristr($t, '>' . $word . '<')) { + $found = true; + break; + } + } + } } } } if ($found) { $rnd = random_string(8); - $b['html'] = ''; + $b['html'] = ''; } } - -function nsfw_find_word_in_item_tags($item_tags, $word) -{ - if (is_array($item_tags)) { - foreach ($item_tags as $tag) { - if (stripos($tag, '>' . $word . '<') !== false) { - return true; - } - } - } - - return false; -}