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

📄 function.asp

📁 可作为课程设计或者毕业设计 也可以作为学校精品课程网站使用
💻 ASP
字号:
<%@  language="VBSCRIPT" codepage="65001" %>
<%
dim requestStr,strType,sql,rs,conn,id,id1,id2

sub conn_open()
set conn=server.createobject("adodb.connection")
	conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("..\data\data.mdb")
end sub

sub conn_close()
conn.close
set conn=nothing
end sub

function rqst(requestStr,strType)
'过滤级别
'0-------不过滤
'1-------过滤sql注入
'2-------过滤html
'3-------只能是数字
rqst=trim(request(requestStr))
if strType=0 then 
rqst=rqst
elseif strType=1 then 
rqst=replace(rqst,"'","&sbquo;")
rqst=replace(rqst,";",";")
rqst=replace(rqst,"""","&quot;")
rqst=replace(rqst,"|","|")
elseif strType=2 then 
rqst=replace(rqst,"<","&lt;")
rqst=replace(rqst,">","&gt;")
rqst=replace(rqst,"'","&sbquo;")
rqst=replace(rqst,";",";")
rqst=replace(rqst,"""","&quot;")
rqst=replace(rqst,"|","|")
elseif strType=3 then
   if isnumeric(rqst) then rqst=rqst else rqst=0
else
rqst=""
end if
end function

function fileList()
set rs=conn.execute("select [ID],[文件名],[添加时间] from [教学文件表] order by [ID]")
if rs.eof then response.Write("<center>没有添加教学文件!</center>"):response.End()
do while not rs.eof
list=list&"<br />--><a href='code/do.asp?flag=11&id="&rs("ID")&"' target='mainContent' title='添加时间:"&rs("添加时间")&"'>"&rs("文件名")&"</a><br />"
if not rs.bof then rs.movenext()
loop
rs.close()
set rs=nothing
response.Write("index~"+escape(list))
end function

function fileContent(id)
set rs=conn.execute("select * from [教学文件表] where id="&id)
if rs.eof then response.Write("<center>没有找到所请求的文件!</center>"):response.End()
list="<center><span style=""font-size:20px"">"&rs("文件名")&"</span></center>"&rs("文件内容")
rs.close()
set rs=nothing
response.Write(list)
end function

function pptList()
set rs=conn.execute("select * from [视频教学表] order by [章节编号]")
if rs.eof then response.Write("<center>没有添加视频文件!</center>"):response.End()
do while not rs.eof
list=list&"<br />第"&rs("章节编号")&"章<br /><a href='"&rs("文件路径")&"' target='mainContent' title='添加时间:"&rs("添加时间")&"'>"&rs("标题")&"</a>"
if not rs.bof then rs.movenext()
loop
rs.close()
set rs=nothing
response.Write("index~"+escape(list))
end function

function egList()
set rs=conn.execute("select * from [章节表] order by [章节编号]")
if rs.eof then response.Write("<center>没有添加章节!</center>"):response.End()
do while not rs.eof
list=list&"第"&rs("章节编号")&"章<br /><a href='eg.html?charid="&rs("章节编号")&"' target='mainContent' >"&rs("章节名称")&"</a><br />"
if not rs.bof then rs.movenext()
loop
rs.close()
set rs=nothing
response.Write("index~"+escape(list))
end function

function egContent(id)
set rs=conn.execute("select * from [题型表] order by [类型编号]")
if rs.eof then response.Write("<center>没有找到题型!</center>"):response.End()
do while not rs.eof
list=list&"<a href=""javascript:show('6&charid="&id&"&egtypeid="&rs("id")&"')"">"&rs("题目类型")&"</a>(每题"&rs("分值")&"分)"
if not rs.bof then rs.movenext()
loop
rs.close()
set rs=nothing
response.Write("egType~"&escape(list))
end function

function eg(id,id1,id2,thisid)
if id<>0 then
set rs=conn.execute("select * from [典型例题表] where id="&id)
if not rs.eof then
rs.movefirst()
if thisid=0 then thisid=rs("id")
list="题目:<br />"&rs("题目")&"<br />"
else
response.Write("eg~该题目不存在!")
response.End()
end if
rs.close()
set rs=nothing
else
set rs=conn.execute("select * from [典型例题表] where [章节编号]="&id1&" and [题型编号]="&id2)
if not rs.eof then
if id=0 then
rs.movefirst()
thisid=rs("id")
list="题目:<br />"&rs("题目")&"<br />"
end if
end if
rs.close
set rs=nothing
end if
if id<>0 and thisid<>0 then list=list&"<a href=""javascript:show('6&id="&thisid&"&charid="&id1&"&egtypeid="&id2&"')"">上一题</a>|"
set rs=conn.execute("select * from [典型例题表] where [章节编号]="&id1&" and [题型编号]="&id2)
on error resume next
if not rs.bof then
rs.movenext() 
if thisid<>id then list=list&"<a href=""javascript:show('6&id="&rs("id")&"&thisid="&thisid&"&charid="&id1&"&egtypeid="&id2&"')"">下一题</a>"
end if
rs.close
set rs=nothing
if id=0 then id=thisid
response.Write("eg~"&escape(list)&"|ans~"&escape("|<a href=""javascript:show('7&id="&id&"')"">[答案解析]</a>"))
end function

function showAnswer(id)
set rs=conn.execute("select * from [典型例题表] where id="&id)
if rs.eof then
list="暂无答案!"
else
list="答案解析:<br />"&rs("答案")
end if
response.Write("ans~"&escape(list))
end function

function bbsList(flag)
if flag=0 then
list="<li><a href=""bbs.html?pageID=1"" target=""mainContent"">留言查看</a></li><li><a href=""javascript:MM_showHideLayers('commentBox','','show')"">发布留言</a></li>"
response.Write("index~"&escape(list))
elseif flag=1 then
set rs=conn.execute("select * from [网上答疑表] order by [提问时间]")
do while not rs.eof
list=list&"<font color=white>标题:<u>"&rs("问题标题")&"</u>&nbsp;&nbsp;提问者:<u>"&rs("提问者")&"</u>&nbsp;&nbsp;提问时间:<u>"&rs("提问时间")&"</u></font><br />内容:"&rs("提问内容")&"<br /><font color=red>老师回复:<u>"&rs("回复")&"</u></font><hr />"
if not rs.bof then
rs.movenext()
else
exit do
end if
loop
response.Write("bbslist~"&list)
elseif flag=2 then
guestname=rqst("guestname",2)
commenttitle=rqst("comment_title",2)
comment_content=rqst("comment_content",2)
if unescape(guestname)="" or len(unescape(commenttitle))>20 or len(unescape(commenttitle))<1 or len(unescape(comment_content))<6 or len(unescape(comment_content))>200 then response.Write("msg~留言失败,名字长度不能为空,标题长度不能为空且不能大于20,评论内容长度必须在6到200之间!"&len(unescape(guestname))&len(unescape(commenttitle))&len(unescape(comment_content))):response.End()
set rs=conn.execute("insert into [网上答疑表] (提问者,问题标题,提问内容) values ('"&guestname&"','"&commenttitle&"','"&comment_content&"')")
response.Write("comment_ok")
end if
end function

function ExamList()
list="<ui>考试须知</ui><li>本考试模拟系统将从试题库中随机抽取笔试题,本试题分为选择题、填空题、问答题和编程题。</li><li>本试卷满分100分,考试时间90分钟,请考生注意把握好考试时间,认真答题。</li><li>考试时间结束后,系统会提示时间到,这时候系统会显示各题的答案,各位同学可以对照答案对自己的考试成绩进行评估。</li><li>选择题总分40分,填空题总分20分,问答题20分,编程题20分。</li><hr /><fieldset><legend><input id=""startBtn"" type=""button"" value=""点击此处开始答题"" onclick=""mystart()"" /></legend><div style=""height:100px;width:100%;font-size:36px; text-justify: distribute; vertical-align: middle; text-align: justify; text-align:center;""><span id=""clock"">00:00:00</span></div></fieldset>"
response.Write("index~"&escape(list))
end function

function exam(id1,id)
if id=0 then
set rs=conn.execute("select * from [题型表] order by [类型编号]")
if rs.eof then response.Write("<center>没有找到题型!</center>"):response.End()
do while not rs.eof
bid=bid+1
list=list&"<a href=""javascript:exam("&bid&","&rs("类型编号")&")"">"&rs("题目类型")&"</a>(每题"&rs("分值")&"分)"
if not rs.bof then rs.movenext()
loop
rs.close()
set rs=nothing
response.Write("exType~"&escape(list))
else
set rs=conn.execute("select * from [题型表] where [类型编号]="&id)
if rs.eof then response.Write("ex"&id1&"~"&escape("没有该类型的题目,请选择其它题型。")):response.End()
TiCount=int(4/rs("分值"))
rs.close()
set rs=nothing
set rs=server.CreateObject("adodb.recordset")
sql="select * from [考试题库表] where [类型编号]="&id
rs.open sql,conn,1,1
rc=rs.recordcount
if rs.eof then response.Write("ex"&id1&"~"&escape("没有该类型的题目,请选择其它题型。")):response.End()
if rc<TiCount then response.Write("ex"&id1&"~"&escape("该题型题目数量不够,请与老师联系。")):response.End()
dim TiNum(40)
for i=1 to TiCount
r=RndNumber(rc,1)
do while isInArry(TiNum,r)
if i=1 then exit do
r=RndNumber(rc,1)
loop
TiNum(i-1)=r
rs.movefirst()
rs.move int(r-1)
list=list&rs("题目")&"<br />"&rs("题目选项")&r&"<hr />"
ans=ans&i&"、"&rs("参考答案")&"<br />"
next
rs.close()
set rs=nothing
response.Write("ex"&id1&"~"&escape(list)&"|ans"&id1&"~"&escape(ans))
end if
end function

Function RndNumber(MaxNum,MinNum)
Randomize timer-int(timer)
RndNumber=int((MaxNum-MinNum+1)*rnd+MinNum)
RndNumber=RndNumber
End Function

function isInArry(Arry,tag)
isInArry=false
    for j=0 to ubound(Arry)
        if tag=Arry(j) then
        isInArry=true
        exit for
        end if
     next
end function
%>

⌨️ 快捷键说明

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