<%
function UBBCode(content)
	dim check
   Set re = New RegExp
   re.IgnoreCase =True
   re.Global=True

'回复可见
if instr(lcase(content),"[replyview]")>0 then
   re.Pattern="(\[replyview\])(.*)(\[/replyview\])"
  if CookieUserName=empty then
    content=re.replace(content,"<hr noshade size=1><font color=ff0000>以下内容需要<B>回复</B>才能浏览，请先登陆</font><hr noshade size=1>")   
  else
  if CookieUserName=rs("username") or conn.execute("select count(id) from [BBSXP_Posts"&conn.Execute("Select PostsTableName From [BBSXP_Threads] where IsDel=0 order by lasttime desc")(0)&"] where ThreadID="&int(request.QueryString("ThreadID"))&" and username='"&CookieUserName&"'")(0)>0 then 
		     content=re.replace(content,"<hr noshade size=1><font color=gray><font color=ff0000>此内容需要<B>回复</B>才能浏览，以下为隐藏内容</font><br>$2</font><hr noshade size=1>")   
		  else
		      content=re.replace(content,"<hr noshade size=1><font color=ff0000>以下内容需要<B>回复</B>才能浏览</font><hr noshade size=1>")      
	     end if
	end if
end if


'帖子达到可见
if instr(lcase(content),"[ybbtopic=")>0 then
  if CookieUserName=empty then
   re.Pattern="(.*)(\[ybbtopic=)(\d*)(\])(.*)(\[/ybbtopic\])(.*)"
  check=re.replace(content,"$3")   
  check=checkint(check)
  content=re.replace(content,"<hr noshade size=1><font color=gray><br><font color=FF0000>以下内容要求发贴数达到<B>"&check&"</B>以上才可以浏览，请先<b>登陆</b></font><br><hr noshade size=1>")   
  else
   re.Pattern="(.*)(\[ybbtopic=)(\d*)(\])(.*)(\[/ybbtopic\])(.*)"
  check=re.replace(content,"$3")   
  check=checkint(check)

dim Ttopic,Ptopic,Rtopic
Ptopic=conn.execute("select PostTopic from [BBSXP_Users] where username='"&CookieUserName&"'")(0)
Rtopic=conn.execute("select PostRevert from [BBSXP_Users] where username='"&CookieUserName&"'")(0)
Ttopic=Ptopic+Rtopic
	    if CookieUserName=rs("username") or Ttopic>=check then
		     content=re.replace(content,"$1<hr noshade size=1><font color=gray><br><font color=FF0000>此内容要求发贴数达到<B>"&check&"</B>以上才可以浏览</font><br>$5<hr noshade size=1>$7")   
		  else
		      content=re.replace(content,"$1<hr noshade size=1><font color=gray><br><font color=FF0000>以下内容要求发贴数达到<B>"&check&"</B>以上才可以浏览</font><br><hr noshade size=1>$7")      
	     end if
	end if
end if


'经验达到可见
if instr(lcase(content),"[ybbexp=")>0 then
  if CookieUserName=empty then
   re.Pattern="(.*)(\[ybbexp=)(\d*)(\])(.*)(\[/ybbexp\])(.*)"
  check=re.replace(content,"$3")   
  check=checkint(check)
  content=re.replace(content,"<hr noshade size=1><font color=gray><br><font color=FF0000>以下内容要求经验值达到<B>"&check&"</B>以上才可以浏览，请先<b>登陆</b></font><br><hr noshade size=1>")   
  else
   re.Pattern="(.*)(\[ybbexp=)(\d*)(\])(.*)(\[/ybbexp\])(.*)"
  check=re.replace(content,"$3")   
  check=checkint(check)
	    if CookieUserName=rs("username") or conn.execute("select Experience from [BBSXP_Users] where username='"&CookieUserName&"'")(0)>=check then
		     content=re.replace(content,"$1<hr noshade size=1><font color=gray><br><font color=FF0000>此内容要求经验值达到<B>"&check&"</B>以上才可以浏览</font><br>$5<hr noshade size=1>$7")   
		  else
		      content=re.replace(content,"$1<hr noshade size=1><font color=gray><br><font color=FF0000>以下内容要求经验值达到<B>"&check&"</B>以上才可以浏览</font><br><hr noshade size=1>$7")      
	     end if
	end if
end if


'工会可见
if instr(lcase(content),"[ybbfaction]")>0 then
   re.Pattern="(\[ybbfaction\])(.*)(\[/ybbfaction\])"
   dim topname
   topname=conn.execute("select Username From [BBSXP_Threads] where ID="&int(request.QueryString("ThreadID"))&"")(0)
   check=conn.execute("select Consortia from [BBSXP_Users] where username='"&topname&"'")(0)
  if CookieUserName=empty then
    content=re.replace(content,"<hr noshade size=1><font color=ff0000>以下内容仅&nbsp;<B>"&check&"</B>&nbsp;的会员才能浏览，请先登陆</font><hr noshade size=1>")   
  else
  if CookieUserName=rs("Username") or conn.execute("select Consortia from [BBSXP_Users] where username='"&CookieUserName&"'")(0)=check then 
		     content=re.replace(content,"<hr noshade size=1><font color=gray><font color=ff0000>此内容仅&nbsp;<B>"&check&"</B>&nbsp;的会员才能浏览，以下为隐藏内容</font><br>$2</font><hr noshade size=1>")   
		  else
		      content=re.replace(content,"<hr noshade size=1><font color=ff0000>以下内容仅&nbsp;<B>"&check&"</B>&nbsp;的会员才能浏览</font><hr noshade size=1>")      
	     end if
	end if
end if



	set re=Nothing
	UBBCode=content
end function

function checkint(check)
	if IsNumeric(check) then
		check=Cint(check)
	else
                response.write("<font color=red><b><u>Error!Please Input Int.</u></b></font>")
		check=0
	end if
	checkint=check
end function

%>