X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=nsfw%2Fnsfw.php;h=6d8acbf034d7d440899cbf06609497ca0ccaade5;hb=c3e93f1ed9a487f823bcc75ddd43024334c25bfc;hp=57511f0055730c28cf1585743fb4440483bfa3a1;hpb=6782f223032caa4b6d8b0143a42bde1a7ae0cd11;p=friendica-addons.git
diff --git a/nsfw/nsfw.php b/nsfw/nsfw.php
index 57511f00..6d8acbf0 100755
--- a/nsfw/nsfw.php
+++ b/nsfw/nsfw.php
@@ -9,6 +9,8 @@
*
*/
+use Friendica\Core\PConfig;
+
function nsfw_install() {
register_hook('prepare_body', 'addon/nsfw/nsfw.php', 'nsfw_prepare_body', 10);
register_hook('plugin_settings', 'addon/nsfw/nsfw.php', 'nsfw_addon_settings');
@@ -69,23 +71,29 @@ 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');
+ $enable_checked = (intval(PConfig::get(local_user(),'nsfw','disable')) ? '' : ' checked="checked" ');
+ $words = PConfig::get(local_user(),'nsfw','words');
if(! $words)
$words = 'nsfw,';
- $s .= '
';
- $s .= '
' . t('Not Safe For Work (General Purpose Content Filter) settings') . ' ';
+ $s .= '
';
+ $s .= '' . t('Not Safe For Work (General Purpose Content Filter)') . ' ';
+ $s .= ' ';
+ $s .= '
';
+ $s .= '
';
+ $s .= '' . t('Not Safe For Work (General Purpose Content Filter)') . ' ';
+ $s .= ' ';
+
$s .= '
';
$s .= '
' . t ('This plugin looks in posts for the words/text you specify below, and collapses any content containing those keywords so it is not displayed at inappropriate times, such as sexual innuendo that may be improper in a work setting. It is polite and recommended to tag any content containing nudity with #NSFW. This filter can also match any other word/text you specify, and can thereby be used as a general purpose content filter.') . '
';
$s .= '
' . t('Enable Content filter') . ' ';
$s .= '
';
$s .= '
';
$s .= '
' . t('Comma separated list of keywords to hide') . ' ';
- $s .= '
';
+ $s .= '
';
$s .= '
';
- $s .= '
';
+ $s .= '
';
$s .= '
' . t('Use /expression/ to provide regular expressions') . '
';
return;
@@ -98,10 +106,10 @@ function nsfw_addon_settings_post(&$a,&$b) {
return;
if($_POST['nsfw-submit']) {
- set_pconfig(local_user(),'nsfw','words',trim($_POST['nsfw-words']));
+ PConfig::set(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);
+ PConfig::set(local_user(),'nsfw','disable', $disable);
info( t('NSFW Settings saved.') . EOL);
}
}
@@ -110,11 +118,11 @@ function nsfw_prepare_body(&$a,&$b) {
$words = null;
- if(get_pconfig(local_user(),'nsfw','disable'))
+ if(PConfig::get(local_user(),'nsfw','disable'))
return;
if(local_user()) {
- $words = get_pconfig(local_user(),'nsfw','words');
+ $words = PConfig::get(local_user(),'nsfw','words');
}
if($words) {
$arr = explode(',',$words);
@@ -126,7 +134,7 @@ function nsfw_prepare_body(&$a,&$b) {
$found = false;
if(count($arr)) {
- $body = $b['title'] . ' ' . nsfw_extract_photos($b['html']);
+ $body = $b['item']['title'] . "\n" . nsfw_extract_photos($b['html']);
foreach($arr as $word) {
$word = trim($word);
@@ -144,13 +152,16 @@ function nsfw_prepare_body(&$a,&$b) {
$found = true;
break;
}
- if(stristr($b['item']['tag'], ']' . $word . '[' )) {
- $found = true;
- 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);