论坛风格切换
  • 4096阅读
  • 4回复

怎么把wind code全部过滤掉 [复制链接]

上一主题 下一主题
离线太史慈
 

发帖
766
金币
626
威望
556
只看楼主 倒序阅读 使用道具 楼主  发表于: 2011-08-23
比如[color=red]xxxx[/color][align=center][attachment=1][/align]
把windcode全部过滤掉
[url=http://www.phpwind.com]phpwind[/url]
离线prisk

发帖
278
金币
0
威望
59
只看该作者 沙发  发表于: 2011-08-23
windcode里面过滤
[img]http://appimg.veryapp.com/pbar/img.php?barhash=4b7ee90840c62e74d81ca326e43bb302d7b460c4[/img]
离线太史慈

发帖
766
金币
626
威望
556
只看该作者 板凳  发表于: 2011-08-23
  1. function convert($message)
  2. {
  3.     $message =str_replace(array('[u]','[/u]','[b]','[/b]','[i]','[/i]','[list]','[li]','[/li]','[/list]','[sub]', '[/sub]','[sup]','[/sup]','[strike]','[/strike]','[blockquote]','[/blockquote]','[hr]','[/backcolor]', '[/color]','[/font]','[/size]','[/align]'), array('<u>','</u>','<b>','</b>','<i>','</i>','<ul style="margin:0 0 0 15px">','<li>', '</li>','</ul>','<sub>','</sub>','<sup>','</sup>','<strike>','</strike>','<blockquote>','</blockquote>', '<hr />','</span>','</span>','</span>','</font>','</div>'), $message);
  4.     $searcharray = array(
  5.         "/\[list=([aA1]?)\](.+?)\[\/list\]/is",
  6.         "/\[payto\](.+?)\[\/payto\]/is",
  7.         "/\[font=([^\[\(&]+?)\]/is",
  8.         "/\[color=([#0-9a-z]{1,10})\]/is",
  9.         "/\[backcolor=([#0-9a-z]{1,10})\]/is",
  10.         "/\[email=([^\[]*)\]([^\[]*)\[\/email\]/is",
  11.         "/\[email\]([^\[]*)\[\/email\]/is",
  12.         "/\[size=(\d+)\]/is",
  13.         "/\[align=(left|center|right|justify)\]/is",
  14.         "/\[glow=(\d+)\,([0-9a-zA-Z]+?)\,(\d+)\](.+?)\[\/glow\]/is",
  15.         "/\[img\](.+?)\[\/img\]/is",
  16.         "/\[url=(https?|ftp|gopher|news|telnet|mms|rtsp|thunder)([^\[\s]+?)\](.+?)\[\/url\]/is",
  17.         "/\[url\]www\.([^\[]+?)\[\/url\]/is",
  18.         "/\[url\](https?|ftp|gopher|news|telnet|mms|rtsp|thunder)([^\[]+?)\[\/url\]/is",
  19.         "/\[fly\]([^\[]*)\[\/fly\]/is",
  20.         "/\[move\]([^\[]*)\[\/move\]/is",
  21.         "/\[post\](.+?)\[\/post\]/is",
  22.         "/\[hide=(.+?)\](.+?)\[\/hide\]/is",
  23.         "/\[sell=(.+?)\](.+?)\[\/sell\]/is",
  24.         "/\[quote\](.+?)\[\/quote\]/is",
  25.         "/\[flash=(\d+?)\,(\d+?)(\,(0|1))?\](.+?)\[\/flash\]/is",
  26.         "/\[table(=(\d{1,3}(%|px)?))?\](.*?)\[\/table\]/is",
  27.         "/\[wmv=[01]{1}\](.+?)\[\/wmv\]/is",
  28.         "/\[wmv(?:=[0-9]{1,3}\,[0-9]{1,3}\,[01]{1})?\](.+?)\[\/wmv\]/is",
  29.         "/\[rm(?:=[0-9]{1,3}\,[0-9]{1,3}\,[01]{1})\](.+?)\[\/rm\]/is",
  30.         "/\[iframe\](.+?)\[\/iframe\]/is",
  31.         "/\[code\](.+?)\[\/code\]/is"
  32.     );
  33.     return preg_replace($searcharray,'',$message);
  34. }


仅供参考,调用函数convert($content);
[url=http://www.phpwind.com]phpwind[/url]
离线rickyleo

发帖
315
金币
0
威望
99
只看该作者 地板  发表于: 2011-08-23
require/common.php里边:
  1. function stripWindCode($text) {
  2.     $pattern = array();
  3.     if (strpos($text, "[post]") !== false && strpos($text, "[/post]") !== false) {
  4.         $pattern[] = "/\[post\].+?\[\/post\]/is";
  5.     }
  6.     if (strpos($text, "[img]") !== false && strpos($text, "[/img]") !== false) {
  7.         $pattern[] = "/\[img\].+?\[\/img\]/is";
  8.     }
  9.     if (strpos($text, "[hide=") !== false && strpos($text, "[/hide]") !== false) {
  10.         $pattern[] = "/\[hide=.+?\].+?\[\/hide\]/is";
  11.     }
  12.     if (strpos($text, "[sell") !== false && strpos($text, "[/sell]") !== false) {
  13.         $pattern[] = "/\[sell=.+?\].+?\[\/sell\]/is";
  14.     }
  15.     $pattern[] = "/\[[a-zA-Z]+[^]]*?\]/is";
  16.     $pattern[] = "/\[\/[a-zA-Z]*[^]]\]/is";
  17.     $text = preg_replace($pattern, '', $text);
  18.     return trim($text);
  19. }



离线ensoon

发帖
166
金币
0
威望
15
只看该作者 4楼 发表于: 2011-08-25
是的,用这个函数是可以的 stripWindCode ,要过滤html strip_tags
open source ,like douban.com [color=#ff0000][url]www.ensoon.com[/url][/color]
快速回复
限100 字节
批量上传需要先选择文件,再选择上传
 
提到某人:
选择好友
上一个 下一个