Exemplo n.º 1
0
function nsfw_prepare_body(&$a, &$b)
{
    $words = null;
    if (get_pconfig(local_channel(), 'nsfw', 'disable')) {
        return;
    }
    if (local_channel()) {
        $words = get_pconfig(local_channel(), 'nsfw', 'words');
    }
    if ($words) {
        $arr = explode(',', $words);
    } else {
        $arr = array('nsfw');
    }
    $found = false;
    if (count($arr)) {
        $body = nsfw_extract_photos($b['html']);
        foreach ($arr as $word) {
            $word = trim($word);
            $author = '';
            if (!strlen($word)) {
                continue;
            }
            if (strpos($word, 'lang=') === 0) {
                if (!$b['item']['lang']) {
                    continue;
                }
                $l = substr($word, 5);
                if (strlen($l) && strcasecmp($l, $b['item']['lang']) !== 0) {
                    continue;
                }
                $found = true;
                $orig_word = $word;
                break;
            }
            if (strpos($word, 'lang!=') === 0) {
                if (!$b['item']['lang']) {
                    continue;
                }
                $l = substr($word, 6);
                if (strlen($l) && strcasecmp($l, $b['item']['lang']) === 0) {
                    continue;
                }
                $found = true;
                $orig_word = $word;
                break;
            }
            $orig_word = $word;
            if (strpos($word, '::') !== false) {
                $author = substr($word, 0, strpos($word, '::'));
                $word = substr($word, strpos($word, '::') + 2);
            }
            if ($author && stripos($b['item']['author']['xchan_name'], $author) === false) {
                continue;
            }
            if (!$word) {
                $found = true;
            }
            if (strpos($word, '/') === 0) {
                if (preg_match($word, $body)) {
                    $found = true;
                    break;
                }
            } else {
                if (stristr($body, $word)) {
                    $found = true;
                    break;
                }
                if ($b['item']['term']) {
                    foreach ($b['item']['term'] as $t) {
                        if (stristr($t['term'], $word)) {
                            $found = true;
                            break;
                        }
                    }
                }
                if ($found) {
                    break;
                }
            }
        }
    }
    $ob_hash = get_observer_hash();
    if (!$ob_hash && (intval($b['item']['author']['xchan_censored']) || intval($b['item']['author']['xchan_selfcensored']))) {
        $found = true;
        $orig_word = t('Possible adult content');
    }
    if ($found) {
        $rnd = random_string(8);
        $b['html'] = '<div id="nsfw-wrap-' . $rnd . '" class="fakelink nsfw-wrap" onclick="openClose(\'nsfw-html-' . $rnd . '\'); openClose(\'nsfw-photo-' . $rnd . '\');">' . sprintf(t('%s - click to open/close'), $orig_word) . '</div><div id="nsfw-html-' . $rnd . '" style="display: none; " >' . $b['html'] . '</div>';
        $b['photo'] = $b['photo'] ? '<div id="nsfw-photo-' . $rnd . '" style="display: none; " >' . $b['photo'] . '</div>' : '';
    }
}
Exemplo n.º 2
0
function nsfw_prepare_body(&$a, &$b)
{
    $words = null;
    if (get_pconfig(local_channel(), 'nsfw', 'disable')) {
        return;
    }
    if (local_channel()) {
        $words = get_pconfig(local_channel(), 'nsfw', 'words');
    }
    if ($words) {
        $arr = explode(',', $words);
    } else {
        $arr = array('nsfw');
    }
    $found = false;
    if (count($arr)) {
        $body = nsfw_extract_photos($b['html']);
        foreach ($arr as $word) {
            $word = trim($word);
            $author = '';
            if (!strlen($word)) {
                continue;
            }
            $orig_word = $word;
            if (strpos($word, '::') !== false) {
                $author = substr($word, 0, strpos($word, '::'));
                $word = substr($word, strpos($word, '::') + 2);
            }
            if ($author && stripos($b['item']['author']['xchan_name'], $author) === false) {
                continue;
            }
            if (!$word) {
                $found = true;
            }
            if (strpos($word, '/') === 0) {
                if (preg_match($word, $body)) {
                    $found = true;
                    break;
                }
            } else {
                if (stristr($body, $word)) {
                    $found = true;
                    break;
                }
                if ($b['item']['term']) {
                    foreach ($b['item']['term'] as $t) {
                        if (stristr($t['term'], $word)) {
                            $found = true;
                            break;
                        }
                    }
                }
                if ($found) {
                    break;
                }
            }
        }
    }
    $ob_hash = get_observer_hash();
    if (!$ob_hash && $b['item']['author']['xchan_flags'] & (XCHAN_FLAGS_CENSORED | XCHAN_FLAGS_SELFCENSORED)) {
        $found = true;
        $orig_word = t('Possible adult content');
    }
    if ($found) {
        $rnd = random_string(8);
        $b['html'] = '<div id="nsfw-wrap-' . $rnd . '" class="fakelink" onclick=openClose(\'nsfw-' . $rnd . '\'); >' . sprintf(t('%s - Click to open/close'), $orig_word) . '</div><div id="nsfw-' . $rnd . '" style="display: none; " >' . $b['html'] . '</div>';
    }
}
Exemplo n.º 3
0
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');
    }
    if ($words) {
        $arr = explode(',', $words);
    } else {
        $arr = array('nsfw');
    }
    $found = false;
    if (count($arr)) {
        $body = $b['item']['title'] . "\n" . nsfw_extract_photos($b['html']);
        foreach ($arr as $word) {
            $word = trim($word);
            if (!strlen($word)) {
                continue;
            }
            if (strpos($word, '/') === 0) {
                if (preg_match($word, $body)) {
                    $found = true;
                    break;
                }
            } else {
                if (stristr($body, $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);
        $b['html'] = '<div id="nsfw-wrap-' . $rnd . '" class="fakelink" onclick=openClose(\'nsfw-' . $rnd . '\'); >' . sprintf(t('%s - Click to open/close'), $word) . '</div><div id="nsfw-' . $rnd . '" style="display: none; " >' . $b['html'] . '</div>';
    }
}