www.gusucode.com > ASP+ACCESS学生信息管理系统设计(源代码+论文) > ASP+ACCESS学生信息管理系统设计(源代码+论文)\赵超\Conn.asp
<% connstr="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" +server.mappath("DataBase/Data.mdb") Set conn= Server.CreateObject("ADODB.Connection") conn.Open connstr Str="Select * From XcAdmin" Set Rs=Conn.execute(Str) TTitle=Rs("XcTitle") CopyRight=Rs("XcCopyRight") XcScript=Rs("XcScript") '----------------------------------------------------------------------- '显示弹出窗口 '----------------------------------------------------------------------- Sub ShowMessAge(strChar,url) Str="<Script Language=JavaScript>alert('" & StrChar & "');location.href='" & url & "';</script>" Response.Write(Str) end Sub function ShowMess(strChar) Str="<Script Language=JavaScript>alert('" & StrChar & "');</script>" Response.Write(Str) end function '----------------------------------------------------------------------- '去处非法的SQL代码 '----------------------------------------------------------------------- function ReplaceBadChar(strChar) StrChar=Trim(StrChar) if strChar="" then ReplaceBadChar="" else ReplaceBadChar=replace(replace(replace(replace(replace(replace(replace(strChar,"'",""),"*",""),"?",""),"(",""),")",""),"<",""),".","") end if end function function ReplaceBadChar2(strChar) StrChar=Trim(StrChar) if strChar="" then ReplaceBadChar1="" else ReplaceBadChar1=replace(replace(replace(replace(replace(replace(replace(strChar,"'",""),"*",""),"?",""),"(",""),")",""),"<",""),".","") end if if ReplaceBadChar1<> "" then ReplaceBadChar2=ReplaceBadChar1 Else ReplaceBadChar2=" " End if end function function system(text) if Instr(text,"NT 5.1")>0 then system=system+"Windows XP" elseif Instr(text,"NT 5")>0 then system=system+"Windows 2000" elseif Instr(text,"NT 4")>0 then system=system+"Windows NT4" elseif Instr(text,"4.9")>0 then system=system+"Windows ME" elseif Instr(text,"98")>0 then system=system+"Windows 98" elseif Instr(text,"95")>0 then system=system+"Windows 95" else system=system+"未知" end if end function '----------------------------------------------------------------------- '写入登陆日志 '----------------------------------------------------------------------- Sub UserLog(UserName,LogIP,LogSys,LogOpr) Str="Insert Into XcUserLog(LogUser,LogIP,LogSys,LogOpr) Values('" Str=Str & UserName & "','" & LogIP & "','" & LogSys & "'," & LogOpr & ")" 'Response.Write(Str) Conn.execute(Str) end Sub '----------------------------------------------------------------------- '写入操作日志 '----------------------------------------------------------------------- Sub UserOpr(OprInfo) OprIP=Request.ServerVariables("REMOTE_ADDR") OprSys=system(Request.ServerVariables("ALL_HTTP")) UserName=Session("UserName") Str="Insert Into XcOprLog(OprUser,OprIP,OprSys,OprInfo) Values('" Str=Str & UserName & "','" & OprIP & "','" & OprSys & "','" & OprInfo & "')" 'Response.Write(Str) Conn.execute(Str) end Sub '----------------------------------------------------------------------- '用户是否登陆 '----------------------------------------------------------------------- Sub IsLog() IF Session("UserName")="" or Session("Useropr")= "" Then Call ShowMessAge("请不要非法登陆","AdminLogin.asp") Response.End() End if End Sub '----------------------------------------------------------------------- '用户可以浏览吗 '----------------------------------------------------------------------- Sub IsBrower() PageName=Request.ServerVariables("URL") PName=Split(PageName,"/") PageName=PName(Ubound(PName)) PName=Split(PageName,"?") PageName=PName(Lbound(PName)) Str="Select PageOpr From UserPage Where PageName='" & PageName & "'" Set Rs1=Conn.execute(Str) If Rs1("PageOpr") < Cint(Session("UserOpr")) Then Call ShowMess("对不起,您没有浏览此页的权限!") Response.End() End if End Sub '----------------------------------------------------------------------- '用户可以操作吗 '----------------------------------------------------------------------- Sub IsOpr() PageName=Request.ServerVariables("URL") PName=Split(PageName,"/") PageName=PName(Ubound(PName)) PName=Split(PageName,"?") PageName=PName(Lbound(PName)) Str="Select PageOpr From UserPage Where PageName='" & PageName & "'" Set Rs1=Conn.execute(Str) If Rs1("PageOpr") < Cint(Session("UserOpr")) Then Call ShowMess("对不起,您没有操作此项目的权限!") Response.End() End if End Sub function UserToStr(UserOpr) Str="Select * From IsOpr where OprValue=" & Cint(UserOpr) Set Rs2=Conn.execute(Str) UserToStr=Rs2("OprName") end function function suijishu() dim suiji Randomize Timer suiji=Int(rnd()*10) suijishu=suiji End Function %>