首页 > 其他 > 详细

非法词屏蔽

时间:2016-02-17 19:00:05      阅读:139      评论:0      收藏:0      [点我收藏+]
<?php
class Text_Filter
{
    var $words;  //文字
    function Text_Filter()
    {
        $this->words=NULL;
    }
    
    function wordsFilter(&$message=null, &$matche_row=array())
    {
        //$matche_row 非法词组
        if(empty($this->words))
        {
            global $config;
            @include_once($config[‘webroot‘].‘/config/filter.inc.php‘);
            $this->words =& $_CACHE[‘word_filter‘];
        }
        else
        {
            
        }

        $message = empty($this->words[‘filter‘]) ? $message : @preg_replace($this->words[‘filter‘][‘find‘], $this->words[‘filter‘][‘replace‘], $message);

        if($this->words[‘banned‘] && preg_match($this->words[‘banned‘], $message, $matche_row))
        {
            echo "<div align=‘center‘>Content contains illegal characters.<br>";
            foreach($matche_row as $v)
            {
                echo $v.‘,‘;
            }
            echo "<br> <a href=‘javascript:history.back();‘ > Back </a> </div>";
            die;//有非法词
        }
        else
        {
            return $message;//被替换后的信息
        }
    }
}
?>

 

非法词屏蔽

原文:http://www.cnblogs.com/Asatic/p/5196092.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!