| 123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkPHP [ WE CAN DO IT JUST THINK ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
- // +----------------------------------------------------------------------
- // | Author: 流年 <liu21st@gmail.com>
- // +----------------------------------------------------------------------
- // 应用公共文件
- /**
- * 敏感词过滤
- *
- * @param string
- * @return string
- */
- function sensitive_words_filter($str)
- {
- if (!$str) return '';
- $file = ROOT_PATH. PUBILC_PATH.'/static/plug/censorwords/CensorWords';
- $words = file($file);
- foreach($words as $word)
- {
- $word = str_replace(array("\r\n","\r","\n","/","<",">","="," "), '', $word);
- if (!$word) continue;
- $ret = preg_match("/$word/", $str, $match);
- if ($ret) {
- return $match[0];
- }
- }
- return '';
- }
|