X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=nsfw%2Fnsfw.php;h=41799f14ef88623ccab7c47f156581c8fabf1e99;hb=b58629e86028899418b1f504529f504f6e5b9c7f;hp=22d65d052726ae4494fc58ce4b9c253e892e0466;hpb=94e8c206ec0b465b71df36203682174a881d0085;p=friendica-addons.git diff --git a/nsfw/nsfw.php b/nsfw/nsfw.php old mode 100644 new mode 100755 index 22d65d05..41799f14 --- a/nsfw/nsfw.php +++ b/nsfw/nsfw.php @@ -38,19 +38,24 @@ function nsfw_addon_settings(&$a,&$s) { $a->page['htmlhead'] .= '' . "\r\n"; - + $enable_checked = (intval(get_pconfig(local_user(),'nsfw','disable')) ? '' : ' checked="checked" '); $words = get_pconfig(local_user(),'nsfw','words'); if(! $words) $words = 'nsfw,'; $s .= '
'; - $s .= '

' . t('"Not Safe For Work" Settings') . '

'; + $s .= '

' . t('Content Filter Settings') . '

'; $s .= '
'; - $s .= ''; + + $s .= ''; + $s .= ''; + $s .= '
'; + $s .= ''; $s .= ''; $s .= '
'; - $s .= '
'; + $s .= '
'; + $s .= '
' . t('Use /expression/ to provide regular expressions') . '
'; return; @@ -63,6 +68,9 @@ function nsfw_addon_settings_post(&$a,&$b) { if($_POST['nsfw-submit']) { set_pconfig(local_user(),'nsfw','words',trim($_POST['nsfw-words'])); + $enable = ((x($_POST,'nsfw-enable')) ? intval($_POST['nsfw-enable']) : 0); + $disable = 1-$enable; + set_pconfig(local_user(),'nsfw','disable', $disable); info( t('NSFW Settings saved.') . EOL); } } @@ -70,6 +78,9 @@ function nsfw_addon_settings_post(&$a,&$b) { function nsfw_prepare_body(&$a,&$b) { $words = null; + if(get_pconfig(local_user(),'nsfw','disable')) + return; + if(local_user()) { $words = get_pconfig(local_user(),'nsfw','words'); } @@ -86,19 +97,26 @@ function nsfw_prepare_body(&$a,&$b) { if(! strlen(trim($word))) { continue; } - - if(stristr($b['html'],$word)) { - $found = true; - break; + if(strpos($word,'/') === 0) { + if(preg_match($word,$b['html'])) { + $found = true; + break; + } } - if(stristr($b['item']['tag'], ']' . $word . '[' )) { - $found = true; - break; + else { + if(stristr($b['html'],$word)) { + $found = true; + break; + } + if(stristr($b['item']['tag'], ']' . $word . '[' )) { + $found = true; + break; + } } } } if($found) { $rnd = random_string(8); - $b['html'] = ''; + $b['html'] = ''; } }