| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?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 '';
- }
- /**
- * 上传路径转化,默认路径 UPLOAD_PATH
- * $type 类型
- */
- function makePathToUrl($path,$type = 2)
- {
- $path = DS.ltrim(rtrim($path));
- switch ($type){
- case 1:
- $path .= DS.date('Y');
- break;
- case 2:
- $path .= DS.date('Y').DS.date('m');
- break;
- case 3:
- $path .= DS.date('Y').DS.date('m').DS.date('d');
- break;
- }
- if (is_dir(ROOT_PATH.UPLOAD_PATH.$path) == true || mkdir(ROOT_PATH.UPLOAD_PATH.$path, 0777, true) == true) {
- return trim(str_replace(DS, '/',UPLOAD_PATH.$path),'.');
- }else return '';
- }
|