%
response.buffer = true
dim startTime, endtime
startTime = timer()
dim conn
dim connstr
dim rs, rSub
dim sql
connstr = "driver={microsoft Access driver (*.mdb)}; dbq=" & server.mappath("../data/#data.mdb")
set conn = server.createobject("ADODB.CONNECTION")
if err.number<>0 then
err.clear
set conn=nothing
response.write ""
response.end
else
conn.open connstr
if err.number<>0 then
err.clear
set conn=nothing
response.write ""
'''请检查数据库是否存在,以及 ODBC 是否存在
response.end
end if
end if
set rs = Server.CreateObject("ADODB.Recordset") '主程序用
set rSub = Server.CreateObject("ADODB.Recordset") '子程序用
'+++++++++++++++++++++++++++++++上面这段为用户登录后要记录的COOKIES+++++++++++++++++++++++++++
Sub objend()
set rSub=nothing
set rs=nothing
conn.close
set conn=nothing
endtime=timer()
response.write ""
End Sub
'函数功能:获取网站指定属性
Function GetKey(strKeyName,strUserID,strType)
strTemp=Eval(strType & "_" & strKeyName)
if strTemp="" then
GetKey="Null"
else
GetKey=strTemp
end if
End Function
'获取文件所在的用户名称
Function GetUserName()
'Get CurrFolder Name,too The user name
CurrPath=Server.MapPath( "../")
pt=InStrRev(CurrPath,"\")
CurrFolder=Right(CurrPath,len(CurrPath)-pt)
GetUserName=CurrFolder
End Function
'检查用户权限
sub checkuser(limitnum)
if Session("UserFolder")<>WebUserName then response.Redirect("/Error.asp?msg=对不起,您无权访问这个页面,有问题请与管理员联系!") : userlimits=trim(Session("AdminLimit"))
lp=instr(userlimits,limitnum)
if lp<=0 then
response.Redirect("/Error.asp?msg=对不起,您无权访问这个页面,有问题请与管理员联系!")
response.end
end if
end sub
'提示系统信息
sub ShowMsg(msg)
msg=server.URLEncode(msg) '将字符串编码,以便做参数传递
response.Redirect("/error.asp?msg=" + msg)
end sub
'判断访问来源,如果不是本部则无法访问
sub checkPrePage()
url=request.ServerVariables("HTTP_REFERER")
url=trim(replace(url,"http://",""))
url=trim(left(url,len(request.ServerVariables("SERVER_NAME"))))
if url<>trim(request.ServerVariables("server_name")) then
ShowMsg "严重警告:非法访问!
以任何方式攻击、影响本站的正常运转都是一种犯法的行为,都将承担法律责任!"
response.End()
end if
end sub
'===========================专门用来过滤Request的参数值===================================
function GetVariable(strVariableName)
if IsEmpty(Request(strVariableName)) then
GetVariable=empty
exit Function
end if
GetVariable=Replace(Request(strVariableName),"'","''")
GetVariable=Replace(GetVariable,";","")
GetVariable=Replace(GetVariable,"--","")
end function
function GetFormVariable(strVariableName)
if IsEmpty(Request.Form(strVariableName)) then
GetFormVariable=empty
exit Function
end if
GetFormVariable=Replace(Request.Form(strVariableName),"'","''")
GetFormVariable=Replace(GetFormVariable,"--","")
end function
function GetQueryString(strVariableName)
if IsEmpty(Request.QueryString(strVariableName)) then
GetQueryString=empty
exit Function
end if
GetQueryString=Replace(Request.QueryString(strVariableName),"'","''")
GetQueryString=Replace(GetQueryString,";","")
GetQueryString=Replace(GetQueryString,"--","")
end function
'===========================专门用来过滤Request的参数值===================================
'寻找第一个栏目ID号
function FirstMenu()
FirstMenu=0
End function
'添加会员日记
Sub LogIn(strMID,strEvent)
strSQL="Insert Into web_log(m_id,l_event,l_time) Values(" & strMID & ",'" & strEvent & "','"&now()&"')"
conn.execute strSQL
End sub
'检查会员权限
'参数:strSymbol-权限代号,栏目的代号是该栏目的ID,在线购物为sp,新闻内容为new等
Sub ChkMember(strSymbol)
'检查访问者
if Session("m_Code")="" then
strForVisitor=GetKey("Visitor",WebUserID,"member")
if Instr(strForVisitor,strSymbol)>0 then
'此页面已经被加密,拒绝访问者
ShowMsg "拒绝访问!
您不是会员或者尚未登录,[注册会员][登 录]"
end if
end if
'检查普通会员
if Session("m_Code")="0" then
strForMember=GetKey("Member",WebUserID,"member")
if Instr(strForMember,strSymbol)>0 then
'此页面已经被加密,拒绝访问者
ShowMsg "拒绝访问!
您不是VIP会员或者尚未登录,[升级VIP会员][登 录]"
end if
end if
End sub
Function CutStr(Str,Gtype,lennum)
Dim p_num
Dim i,x
If strlen(Str)<=lennum Then
CutStr=str
Else
p_num=0
x=0
Do while not p_num > lennum-2
x=x+1
If asc(mid(str,x,1))<0 Then
p_num=int(p_num) + 2
Else
p_num=int(p_num) + 1
End If
If Gtype = 1 Then
CutStr=left(trim(str),x) & "..."
Else
CutStr="..." & Right(trim(str),x)
End IF
Loop
End If
End Function
'取字符串长度
Function strlen(str)
Dim p_len,xx
p_len=0
strlen=0
If trim(str)<>"" Then
p_len=len(trim(str))
For xx=1 to p_len
If asc(mid(str,xx,1))<0 Then
strlen=clng(strlen) + 2
Else
strlen=clng(strlen) + 1
End If
Next
End If
End Function
%>