%
dim conn,db
dim connstr
db="comdshuju1/hhgh13.mdb" '数据库文件位置
on error resume next
connstr="DBQ="+server.mappath(""&db&"")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
if err then
response.Write(err)
err.clear
else
end if
sub CloseConn()
conn.close
set conn=nothing
end sub
%>
<%
'常用函数建立连接数据库记录
Function RsName(Rs_Name,Sql,A,B)
Set Rs_Name=Server.CreateObject("Adodb.RecordSet")
Rs_Name.open Sql,conn,A,B
End Function
'************************************************************************
'L.C.H-002释放记录集
Sub CloseRs()
rs.close
set rs=nothing
End Sub
'************************************************************************
'L.C.H-003释放conn
Sub CloseConn()
conn.close
set conn=nothing
End Sub
'************************************************************************
'L.C.H-004显示错误提示且返回上一页
Function ShowError(a)
response.write("")
response.end()
End Function
'************************************************************************
'L.C.H-005显示错误提示且重新载入另一页
Function ShowErrorTo(a,b)
response.write("")
response.end()
End Function
'************************************************************************
'L.C.H-006显示错误提示且关闭该窗口
Function ShowErrorClose(a)
response.write("")
response.end()
End Function
'L.C.H-008禁止外部提交
Sub Remote()
if not (instr(1,Request.ServerVariables("http_Referer"),Request.ServerVariables ("SERVER_NAME"),1)=8) then
Call ShowError("参数错误!")
end if
end Sub
'************************************************************************
'L.C.H-010是否为数字
Function IsDigit(a)
if isnumeric(a)=false then
Call ShowError("参数错误!")
end if
end Function
'************************************************************************
'L.C.H-011传递ID的有效性
Function Isid(a)
if a="" or isnumeric(a)=false then
Call ShowError("参数错误!")
end if
end Function
'************************************************************************
'L.C.H-012关闭当前弹出窗口,并且刷新父窗口
Sub Refresh()
response.write("")
response.end()
end sub
'L.C.H-013根据传入语句得到是否存在此记录
Function Countid(sql)
RsName rs,sql,1,1
if not rs.eof then
Countid=rs("num")
else
Countid=0
end if
call CloseRs()
end Function
Function Input(s)
s = Trim(Request(s))
s = Replace(s,"'","‘")
s = Replace(s,"--","--")
s = Replace(s,";",";")
s = Replace(s,"declare","Declare")
s = Replace(s,"insert","")
s = Replace(s,".js",".JS")
s = Replace(s,"set",".Set")
s = Replace(s,"update","UPDATE")
s = Replace(s,"shell","Shell")
s = Replace(s,"master","MASTER")
s = Replace(s,"table","Table")
s = Replace(s,"exec","Exec")
s = Replace(s,"and","and")
s = Replace(s,"%","%")
s = Replace(s,"*","*")
Input = s
End Function
Function NoHTML(s)
If IsNull(s) Then s= ""
s = Server.HTMLEncode(s)
s = Replace(s,VBCRLF,"
")
NoHTML = s
End Function
function SplitToSQL(str,deli)
if str<>"" then
tmp=split(str,deli)
tmpstr=""
for i=0 to ubound(tmp)
tmpstr=tmpstr&"'"&trim(tmp(i))&"'"
if i
")
fString = Replace(fString, CHR(10) & CHR(10), "
")
fString = Replace(fString, CHR(13), "
")
fString = Replace(fString, CHR(10), "
")
fString = Replace(fString, " "," ")
fstring = replace(fstring,"'","''")
else
fString=""
end if
HTMLEncode = fString
end function
function HTMLDecode(fString)
if fString<>"" then
fString = replace(fString, ">", ">")
fString = replace(fString, "<", "<")
fString = Replace(fString, "
", CHR(10) & CHR(10))
fString = Replace(fString, "
", CHR(13)& CHR(10))
fString = Replace(fString, " "," ")
fstring = replace(fstring,"''","'")
else
fString=""
end if
HTMLDecode = fString
end function
function getSystime()
set grs=conn.execute("select t=getdate()")
getSystime=grs(0)
end function
'*************************************
'防止外部提交
'*************************************
Function CheckPost()
Dim server_v1,server_v2
Dim bReturn
bReturn = False
server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))
If Mid(server_v1,8,Len(server_v2))<>server_v2 Then
Else
bReturn=True
End If
'CheckPost = bReturn
CheckPost = False
End Function
'通用的正则表达式
Function DoRegExpSearch(sPattern,s)
Dim oRegEx
Dim bReturn
bReturn = False
Set oRegEx = New RegExp
oRegEx.Pattern = sPattern
oRegEx.IgnoreCase = False
bReturn = oRegEx.Test(s)
DoRegExpSearch = bReturn
End Function
'****************
'检查用户名
'CheckUserName
'****************
Function CheckUserName(s)
Dim bReturn
bReturn = 0
sPattern = "^\w+$"
If DoRegExpSearch(sPattern,s) Then
If Len(s) < 5 Or Len(s) > 15 Then
'sErrMessage = sErrMessage & "