<%
'----------------------获取随机字符串----------------------
Function gen_key(digits)
'定义并初始化数组
    dim char_array(80)
'初始化数字
    For i = 0 To 9
        char_array(i) = CStr(i)
    Next
'初始化大写字母
    For i = 10 To 35
        char_array(i) = Chr(i + 55)
    Next
'初始化小写字母
    For i = 36 To 61
        char_array(i) = Chr(i + 61)
    Next
Randomize   '初始化随机数生成器。
do while len(output) < digits
        num = char_array(Int((62 - 0 + 1) * Rnd + 0))
        output = output & num
    loop
'设置返回值
    gen_key    =    output
End Function
'----------------------获取网站的基本参数----------------------
Set rs= Server.CreateObject("ADODB.RecordSet")
sql="select * from config"
rs.open sql,conn,1,1
if not rs.eof then
C_no=rs("C_no")
D_version=rs("C_no")
C_title=rs("C_title")
C_keywords=rs("C_keywords")
C_content=rs("C_content")
C_code=rs("C_code")
C_fx=rs("C_fx")
C_fenxiang=rs("C_fenxiang")
C_qq=rs("C_qq")
C_qqon=rs("C_qqon")
C_mobileon=rs("C_mobileon")
C_wb=rs("C_wb")
C_swbid=rs("C_swbid")
C_twbid=rs("C_twbid")
C_search=rs("C_search")
C_member=rs("C_member")
C_shop=rs("C_shop")
C_foot=rs("C_foot")
C_logo=rs("C_logo")
C_logoC=rs("C_logoC")
C_logox=rs("C_logox")
C_logoy=rs("C_logoy")
C_music=rs("C_music")
C_cut=rs("C_cut")
end if
rs.close
set rs=nothing
'----------------------关闭数据库连接,在每页调用该函数,将连接放入连接池----------------------
Sub CloseConn()
   conn.close()
   set conn=nothing
End Sub
'----------------------删除文件------------------------------
function filedelete(filepath)
Set fso = CreateObject("Scripting.FileSystemObject")      
fso.DeleteFile(Server.mappath(filepath))      
Set fso = nothing
end function

'-----------------------获取远程验证-----------------------------
Function GetBody(D_domain) 
Set https = Server.CreateObject("MSXML2.XMLHTTP") 
With https 
.Open "Post", "http://www.flash-soul.com/domain/xml2.asp", False
.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
.Send "D_domain="&D_domain
GetBody = .ResponseBody
End With 
GetBody = BytesToBstr(GetBody,"GB2312")
Set https = Nothing 
End Function
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText 
objstream.Close
set objstream = nothing
End Function

'----------------------大写转小写------------------------------
function Replace_Text(fString)
	if isnull(fString) then
		Replace_Text=""
		exit function
	else
		fString=trim(fString)
		fString=replace(fString,"'","''")
		fString=replace(fString,";","；")
		fString=replace(fString,"--","—")
		fString=server.htmlencode(fString)
		Replace_Text=fString
	end if	
end function

'----------------------SQL防注入------------------------------
function Replace_Text(fString)
	if isnull(fString) then
		Replace_Text=""
		exit function
	else
		fString=trim(fString)
		fString=replace(fString,"'","''")
		fString=replace(fString,";","；")
		fString=replace(fString,"--","—")
		fString=server.htmlencode(fString)
		Replace_Text=fString
	end if	
end function

'----------------------清除HTML格式(全清)------------------------------
Function LoseHtml(ContentStr)
  Dim ClsTempLoseStr,regEx
  ClsTempLoseStr = Cstr(ContentStr)
  Set regEx = New RegExp
  regEx.Pattern = "<\/*[^<>]*>"
  regEx.IgnoreCase = True
  regEx.Global = True
  ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
  LoseHtml = ClsTempLoseStr
End function
'----------------------清除HTML格式（只清font）------------------------------

Function RemoveHTML(str) 
dim a,re 
set re=new RegExp 
re.pattern="<(?!P|B|U|I|IMG|/P|/B|/U|/I|/IMG).*?>" 
re.global=true 
a=str 
RemoveHTML=re.replace(a,"") 
End Function 

%>