<%

function gotTopic(str,strlen)
	if str="" then
		gotTopic=""
		exit function
	end if
	dim l,t,c, i
	str=replace(replace(replace(replace(str,"&nbsp;"," "),"&quot;",chr(34)),"&gt;",">"),"&lt;","<")
	l=len(str)
	t=0
	for i=1 to l
		c=Abs(Asc(Mid(str,i,1)))
		if c>255 then
			t=t+2
		else
			t=t+1
		end if
		if t>=strlen then
			gotTopic=left(str,i) & "..."
			exit for
		else
			gotTopic=str
		end if
	next
	gotTopic=replace(replace(replace(replace(gotTopic," ","&nbsp;"),chr(34),"&quot;"),">","&gt;"),"<","&lt;")
end function
'**************************************************
'函数名：ReplaceBadChar
'作  用：过滤非法的SQL字符
'参  数：strChar-----要过滤的字符
'返回值：过滤后的字符
'**************************************************
Function ReplaceBadChar(strChar)
    If strChar = "" Or IsNull(strChar) Then
        ReplaceBadChar = ""
        Exit Function
    End If
    Dim strBadChar, arrBadChar, tempChar, i
    strBadChar = "',%,^,&,?,(,),<,>,[,],{,},/,\,;,:," & Chr(34) & "," & Chr(0) & ""
    arrBadChar = Split(strBadChar, ",")
    tempChar = strChar
    For i = 0 To UBound(arrBadChar)
        tempChar = Replace(tempChar, arrBadChar(i), "")
    Next
    ReplaceBadChar = tempChar
End Function
'**************************************************
'函数名：CheckNull
'作  用：检查是否为空
'参  数：para--传入的参数 info--中文描述
'返回值：不为空时传回para
'**************************************************
Function CheckNull(para,info)
	if IsNull(para) or IsEmpty(para) or para="" then
		AlertInfo info&"不能为空",,0
		response.end
	else
		CheckNull=para
	end if
end function
'**************************************************
'函数名：AlertInfo
'作  用：警告信息
'参  数：Alert_Info--警告信息，aNextPage--下一页面地址，aType--警告类型
'返回值：无
'**************************************************
Function AlertInfo(Alert_Info,aNextPage,aType)
  aType=cint(aType)
  Select Case aType
    Case 0:
	Response.Write"<script language='javascript'>alert('"& Alert_Info &"');history.back(-1);</script>"
  	Response.End
    Case 1:
	Response.Write"<script language='javascript'>alert('"& Alert_Info &"');location.href='"& aNextPage &"';</script>"
  	Response.End
    Case else:
	Response.Write"<script language='javascript'>alert('"& Alert_Info &"');</script>"
  	Response.End
  End Select
End Function
'**************************************************
'函数名：HTMLEncode(reString)
'作  用：将HTML代码转化为文本
'参  数：reString--传入代码
'返回值：转化后的文本
'**************************************************
Function HTMLEncode(reString) 
	Dim Str:Str=reString
	If Not IsNull(Str) Then
		Str = Replace(Str, "&", "&amp;")
		Str = Replace(Str, ">", "&gt;")
		Str = Replace(Str, "<", "&lt;")
		Str = Replace(Str, CHR(32), "&nbsp;")
		Str = Replace(Str, CHR(9), "&nbsp;&nbsp;&nbsp;&nbsp;")
		Str = Replace(Str, CHR(9), "&#160;&#160;&#160;&#160;")
		Str = Replace(Str, CHR(34),"&quot;")
		Str = Replace(Str, CHR(39),"&#39;")
		Str = Replace(Str, CHR(13), "")
		Str = Replace(Str, CHR(10), "<br>")
		HTMLEncode = Str
	End If
End Function
'**************************************************
'函数名：ReHTMLEncode
'作  用：将文本转化为有格式的HTML代码
'参  数：reString--传入文本
'返回值：转化后的代码
'**************************************************
Function ReHTMLEncode(reString)
	Dim Str:Str=reString
	If Not IsNull(Str) Then
		Str = Replace(Str, "&amp;" ,"&")
		Str = Replace(Str, "&gt;", ">")
		Str = Replace(Str, "&lt;", "<")
		Str = Replace(Str, "&nbsp;", CHR(32))
		Str = Replace(Str, "&nbsp;&nbsp;&nbsp;&nbsp;", CHR(9))
		Str = Replace(Str, "&#160;&#160;&#160;&#160;", CHR(9))
		Str = Replace(Str, "&quot;", CHR(34))
		Str = Replace(Str, "&#39;", CHR(39))
		Str = Replace(Str, "", CHR(13))
		Str = Replace(Str, "<br>", CHR(10))
		Str = Replace(Str, "<br/>", CHR(10))
		ReHTMLEncode = Str
	End If
End Function
%>