⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 globals.asp

📁 利用ASP+SQL制作的在线考试系统
💻 ASP
字号:

<%
  '全局数据库参数.
   set schooldb = server.createobject("ADODB.connection")
   schooldb.open  "dsn=school;uid=sa;pwd="

  DBParams=schooldb
  '生成HTML脚本时美化生成结果时,自动带上回车换行符.
  CRLF = Chr(13)&Chr(10)
  
function DateToStr(dtDateTime)
    DateToStr = year(dtDateTime) & doublenum(Month(dtdateTime)) & doublenum(Day(dtdateTime)) & doublenum(Hour(dtdateTime)) & doublenum(Minute(dtdateTime)) & doublenum(Second(dtdateTime)) & ""
end function
function doublenum(fNum)
    if fNum > 9 then 
        doublenum = fNum 
    else 
        doublenum = "0" & fNum
    end if
end function




  Function PassWordOK(Byval UserID,Password) 'PasswordOK(UserID,PassWord)
    passwordok=true
    Set PWrs = Server.CreateObject("ADODB.Recordset")
    SQL = "select * from UserInfo where UserID='"&UserID&"'"
    PWrs.Open SQL,DBParams
    if not PWrs.eof then
        if PWrs("userpassword")=password then
            passwordok=true
        else
            passwordok=false
        end if
    else
        passwordok=false
    end if
    if len(password)>8 or not instr(password,"or")=0 then
        passwordok=false
    end if
    PWrs.Close
    set PWrs = nothing
  End Function
  
  
%>

<%
set rs=server.createobject("adodb.recordset")
set rss=server.createobject("adodb.recordset")

userids=trim(session("userid"))

userips = Request.ServerVariables("REMOTE_ADDR")

if userids<>"" then

	flag=0
	sql="select * from online where userid='"&userids&"'"
	rs.open SQL,schooldb
	if not rs.eof  then
   	flag=1
	end if
	rs.close
	sql="select * from userinfo where userid='"&userids&"'"
	
	rs.open SQL,schooldb
	if not rs.eof then
  	session("realnames")=rs("realname")
	end if
	rs.close

	SQL = "select * from userjoinclassinfo where userid='"&userids&"' order by joindate"
	rs.open SQL,schooldb
		if rs.eof then
			if flag=0 then
  			sql1="select  * from online"
  			rss.open SQL1,schooldb,1,3
  			rss.AddNew
  			rss("userid")=userids
  			rss("userip")=userips
  			rss("usercometime")=now()
  			rss("classid")="nothing"
  			rss.Update
  			rss.Close
			else
			set rsup=schooldb.execute("update online set userid='"&userids&"',userip='"&userips&"',usercometime='"&now()&"' where userid='"&userids&"'")
	
			end if 
		else
		fs=0
		curclassids=trim(session("classid"))
		if curclassids="" then
		fs=1
		curclassids=rs("classid")
		end if 

		if flag=0 then
  		sql1="select * from online"
  		rss.open SQL1,schooldb,1,3
  		rss.AddNew
  		rss("userid")=userids
  		rss("userip")=userips
  		rss("usercometime")=now()
  		rss("classid")=curclassids
  		rss.Update
  		rss.Close
			else
		set rsup=schooldb.execute("update online set userid='"&userids&"',userip='"&userips&"',usercometime='"&now()&"',classid='"&curclassids&"' where userid='"&userids&"'")
		end if 
		
		  if fs=0 then
     'rss("logintimes")=rss("logintimes")+1
     set rs1=schooldb.execute("update userjoinclassinfo set lastlogintime='"&now&"',logintimes="&(rs("logintimes")+1)&" where userid='"&userids&"' and classid='"&session("classid")&"'")
	
  		end if
	end if 
		rs.close
end if 

%>

<%timeouts=DateToStr(now())-1200
times=cdbl(timeouts)
set rsss=schooldb.execute ("select * from online")
while not rsss.eof
if cdbl(DateToStr(rsss("usercometime")))<times then
id=rsss("id")

	SQL = "delete online  where id="&id&""
	
	set rs3=schooldb.execute(sql)	
	
 
  end if 
  rsss.movenext
  wend 
  
  
  	 

%>

<html><script language="JavaScript">                                                                  </script></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -