本帖最后由 cr180 于 2009-11-18 22:44 编辑
近来有很多dz上面的朋友都问我这个问题,就是在数据调用主题简短内容的时候经常会有[font] [img] [url] ......等等这些内置代码.
下面就给大家说下过滤这些代码的修改方法.
1、打开include/request.func.php
2、查找 $replace['{message}'] = $value['message'];
修改成:$replace['{message}'] = replace($value['message']);
3、最后一行?>前面加上下面的代码即可(注意备份文件)
4、更新缓存后看看效果 - function replace($text){
- $text=eregi_replace(" ","",$text);
- $text=eregi_replace(" ","",$text);
- $text=eregi_replace(" ","",$text);
- $text=eregi_replace("\[i\]","",$text);
- $text=eregi_replace("\[/i\]","",$text);
- $text=eregi_replace("\[b\]","",$text);
- $text=eregi_replace("\[/b\]","",$text);
-
- $text=eregi_replace("\[p\]","",$text);
- $text=eregi_replace("\[/p\]","",$text);
-
- $text=eregi_replace("\[u\]","",$text);
- $text=eregi_replace("\[/u\]","",$text);
- $text=eregi_replace("\[h1\]","",$text);
- $text=eregi_replace("\[/h1\]","",$text);
- $text=eregi_replace("\[h2\]","",$text);
- $text=eregi_replace("\[/h2\]","",$text);
- $text=eregi_replace("\[h3\]","",$text);
- $text=eregi_replace("\[/h3\]","",$text);
- $text=eregi_replace("\[h4\]","",$text);
- $text=eregi_replace("\[/h4\]","",$text);
- $text=eregi_replace("\[h5\]","",$text);
- $text=eregi_replace("\[/h5\]","",$text);
- $text=eregi_replace("\[h6\]","",$text);
- $text=eregi_replace("\[/h6\]","",$text);
- $text=eregi_replace("\[center\]","",$text);
- $text=eregi_replace("\[/center\]","",$text);
- $text=eregi_replace("\[right\]","",$text);
- $text=eregi_replace("\[/right\]","",$text);
- $text=eregi_replace("\[color=#([a-fA-F0-9]{6})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{3})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{4})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{5})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{6})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{7})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{8})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{9})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{10})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{11})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{12})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{13})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{14})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{15})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{16})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{17})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{18})\]","",$text);
- $text=eregi_replace("\[color=([a-zA-Z0-9]{19})\]","",$text);
- $text=eregi_replace("\[/color\]","",$text);
- $text=eregi_replace("\[size=([0-9])\]","",$text);
- $text=eregi_replace("\[/size\]","",$text);
- //$text=eregi_replace("\[font=(.+)\](.+)\[/font\]","\\2",$text);
- $text=eregi_replace("\[email=(.+)\](.+)\[/email\]","\\2",$text);
- $text=eregi_replace("\[attach\](.+)\[/attach\]","",$text);
- $text=eregi_replace("\[email\](.+)\[/email\]","\\1",$text);
- $text=preg_replace("/\[url=(.+)\](.+)\[\/url\]/isU","",$text);
- $text=preg_replace("/\[url\]((http|ftp):\/\/.+)\[\/url\]/isU","\\1",$text);
- $text=preg_replace("/\[img\](http:\/\/.+)\[\/img\]/isU","",$text);
- $text=preg_replace("/\<img\>(http:\/\/.+)\<\/img\>/isU","",$text);
- $text=preg_replace("/\[wmv=(.+)\](http:\/\/.+)\[\/wmv\]/isU","",$text);
- $text=preg_replace("/\[flash=(.+)\](http:\/\/.+)\[\/flash\]/isU","",$text);
- $text=preg_replace("/\[rm=(.+)\](http:\/\/.+)\[\/rm\]/isU","",$text);
- $text=preg_replace("/\[attachment=(.+)\]/isU","",$text);
- $text=preg_replace("/\[media\](http:\/\/.+(\.mp3|\.mpeg|\.ra|\.wav|\.wma|\.wmv|\.rm|\.rmvb|\.asf|\.mov|\.qt|\.swf))\[\/media\]/isU","",$text);
- $text=eregi_replace("\[font=宋体\]","",$text);
- $text=eregi_replace("\[font=黑体\]","",$text);
- $text=eregi_replace("\[font=TimesNewRoman\]","",$text);
- $text=eregi_replace("\[font=仿宋_GB2312\]","",$text);
- $text=eregi_replace("\[font=楷体_GB2312\]","",$text);
- $text=eregi_replace("\[font=新宋体\]","",$text);
- $text=eregi_replace("\[font=微软雅黑\]","",$text);
- $text=eregi_replace("\[font=TrebuchetMS\]","",$text);
- $text=eregi_replace("\[font=Tahom\]","",$text);
- $text=eregi_replace("\[font=Arial\]","",$text);
- $text=eregi_replace("\[font=Impact\]","",$text);
- $text=eregi_replace("\[font=Tahoma\]","",$text);
- $text=eregi_replace("\[/font\]","",$text);
- $text=eregi_replace("\[size=([0-9])([0-9]).([0-9])pt\]","",$text);
- $text=eregi_replace("\[size=([0-9])([0-9])pt\]","",$text);
- $text=eregi_replace("\[size=([0-9])pt\]","",$text);
- $text=eregi_replace("\[hr\]","",$text);
-
- $text=eregi_replace("\[p=([0-9])([0-9]),([0-9]),left\]","",$text);
- $text=eregi_replace("\[p=([0-9])([0-9]),([0-9]),center\]","",$text);
- $text=eregi_replace("\[p=([0-9])([0-9]),([0-9]),right\]","",$text);
- $text=eregi_replace("\[align=center\]","",$text);
- $text=eregi_replace("\[/align\]","",$text);
- $text=eregi_replace("\[i=([a-z])\]","",$text);
- $text=eregi_replace("\[float=left\]","",$text);
- $text=eregi_replace("\[float=right\]","",$text);
- $text=eregi_replace("\[/float\]","",$text);
- $text=eregi_replace("<imgsrc=*>","",$text);
- $text=eregi_replace("<divclass="*">","",$text);
- $text=eregi_replace("</div>","",$text);
- $text=eregi_replace("<p>","",$text);
- $text=eregi_replace("</p>","",$text);
- return $text;
- }
复制代码 |