















米香博客,与你分享! JUST BLOG YOUR BEAUTY LIFE TO WORLD!
















$post['ratings'] = karmaimg($post['rate'], $post['ratetimes']);
1. 如果只切字符不过滤的,后面插入下面代码
if(!$discuz_user && $post['count'] == 0 && strlen($post['message']) > 1000){
$post['message'] = cutstr($post['message'], 1000);
$post['message'] = $post['message']."[quote][b][color=black]您的等级为游客,目前仅能浏览此贴的部分内容,请[url= http://www.discuz.net/logging.php?action=login]登录[/url][/color][/b] [/quote]";
$post['bbcodeoff'] = 0;
}
2. 如果要切字符后过滤一些代码的,在后面插入下面代码
if(!$discuz_user && $post['count'] == 0 && strlen($post['message']) > 1000){
$find = array(
"/\[hide=?\d*\](.+?)\[\/hide\]/is",
"/\[quote](.*)\[\/quote]/siU",
"/\[table=?.*\]/iU",
"/\[\/table\]/i",
"/\[tr=?.*\]/iU",
"/\[\/tr\]/i",
"/\[td=?.*\]/iU",
"/\[\/td\]/i",
"/\[color=?.*\]/iU",
"/\[\/color\]/i",
"/\[url=?.*\]/iU",
"/\[\/url\]/i",
"/\[b\]/iU",
"/\[\/b\]/i",
"/\[u\]/iU",
"/\[\/u\]/i",
"/\[i\]/iU",
"/\[\/i\]/i",
"/\[font=?.*\]/iU",
"/\[\/font\]/i",
"/\[size=?.*\]/iU",
"/\[\/size\]/i",
"/\[align=?.*\]/iU",
"/\[\/align\]/i",
"/\[list\]/iU",
"/\[\/list\]/i",
"/\[indent\]/iU",
"/\[\/indent\]/i",
"/\[email=?.*\]/iU",
"/\[\/email\]/i",
"/\[code\]/iU",
"/\[\/code\]/i",
"/\[free\]/iU",
"/\[\/free\]/i",
"/\[swf=?.*\]/iU",
"/\[\/swf\]/i",
"/\[payto=?.*\]/iU",
"/\[\/payto\]/i",
"/\[float=?.*\]/iU",
"/\[\/float\]/i",
"/\[img]/iU",
"/\[\/img\]/i",
"/\[attach\](\d+)\[\/attach\]/i"
);
$replace = array('');
$post['message'] = cutstr($post['message'], 1000);
$post['message'] = preg_replace($find,$replace,$post['message']);
$find = "/http:\/\/[a-z0-9\/\-_+=.~!%@?#%&;:$\\()|]+?\.(jpg|gif|png|bmp)/is";
$replace = "[img]\\0[/img]";
$post['message'] = preg_replace($find,$replace,$post['message']);
$post['message'] = $post['message']."[quote][b][color=black]您的等级为游客,目前仅能浏览此贴的部分内容,请[url= http://www.discuz.net/logging.php?action=login]登录[/url][/color][/b] [/quote]";
$post['bbcodeoff'] = 0;
}
说明:
上面2段代码自己选择一个用。
如果还要过滤其他 BBCODE ,在代码2的$find数组"/\[attach\](\d+)\[\/attach\]/i"前面按格式自己插入。如果不想过滤一些代码,可以自己删掉 $find数组中的一些代码。关于图片,如果你运气好,图片链接没在1000字符那里被切断,会正常显示。
1楼的帖子,字数大于1000才会被屏蔽,不限制文字长度删除掉代码 && strlen($post['message']) > 1000,不想限制楼层删除掉代码 && $post['count'] == 0 更改 && $post['count'] == 后面的值,可对其他楼层的进行设置,值0为1楼,值1位2楼,以此类推。
注:代码内的登录链接自己修改成自己的。
演示地址 http://www.spkcn.net/forums/viewthread.php?tid=533 想看的就点,不想看的别点。![]()
这段代码无效?用过的都知道,会无效?真是好笑.....![]()


screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.kaca100.com/images/kaca100.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.kaca100.com/images/kaca100-1.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.kaca100.com/images/002.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.kaca100.com/images/003.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.kaca100.com/images/004.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.kaca100.com/images/005.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.kaca100.com/images/006.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.kaca100.com/images/007.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.kaca100.com/images/008.jpg');}" onmousewheel="return imgzoom(this);" alt="" border="0">

