📄 hxrtj.asp
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="const.asp"-->
<!--#include file="conn.asp"-->
<!--#include file=upload_5xsoft.inc-->
<% if session("admin")<>"tfot" then
response.Redirect("admin.asp")
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><%=schoolname%><%=schoolvote%>管理后台</title>
</head>
<body>
<%
' 如果编辑的内容很多,上传速度太慢,请设置以下的时间,单位秒
'Server.ScriptTimeout = 600
select case request.QueryString("action")
case "add"
call add
case "bj"
call bj
case else
response.Redirect("index.asp")
end select
sub add
Dim upload,file,formName,FileExp,iCount,TotalSize
set upload=new upload_5xsoft
stuname=Trim(upload.form("stuname"))
yuanxi=Trim(upload.form("yuanxi"))
zhuanye=Trim(upload.form("zhuanye"))
banji=Trim(upload.form("banji"))
zhuti=Trim(upload.form("zhuti"))
content=upload.Form("content1")
iCount=0
For each formName in upload.objFile
Set file=upload.file(formName)
If file.FileSize>0 Then
FileExp=Right(file.FileName,Len(file.FileName)-InstrRev(file.FileName,".")+1)
If not CheckExp(FileExp) Then
response.Write("<script>window.alert('上传照片出错!当前设置不能上传该格式的文件!');history.go(-1)</script>")
Set File=nothing
response.End()
End IF
PhotoFormat=FileExp
filename=GetRndFileName&FileExp
File.SaveAs Server.mappath("UploadFile/"&filename) ''保存文件
iCount=iCount+1
Else
response.Write("<script>window.alert('上传失败!可能您没有选择文件上传');history.go(-1)</script>")
Set File=nothing
response.End()
End If
Set File=nothing
next
set upload=nothing
'------保存文件开始
dim Rs,id
sql="select top 1 * from stu order by id desc"
set Rs=Server.CreateObject("Adodb.Recordset")
Rs.open sql,conn,1,3
Rs.addnew()
Rs("stuname")=stuname
Rs("images")="UploadFile/"&filename
Rs("yuanxi")=yuanxi
Rs("banji")=banji
Rs("zhuanye")=zhuanye
Rs("content")=Content
Rs("zhuti")=zhuti
Rs.Update
Rs.close
Set Rs=nothing
response.Write("<script>window.alert('添加成功!');window.location.href='./admin_index.asp'</script>")
response.End()
end sub
sub bj
dim id
id=request.QueryString("id")
id=replace(id,"'","")
id=replace(id,">","")
id=replace(id,"<","")
id=replace(id,"?","")
Dim upload,file,formName,FileExp,iCount,TotalSize
set upload=new upload_5xsoft
yuanxi=Trim(upload.form("yuanxi"))
zhuanye=Trim(upload.form("zhuanye"))
banji=Trim(upload.form("banji"))
zhuti=Trim(upload.form("zhuti"))
content=upload.Form("content1")
images=trim(upload.form("images"))
iCount=0
For each formName in upload.objFile
Set file=upload.file(formName)
If file.FileSize>0 Then
FileExp=Right(file.FileName,Len(file.FileName)-InstrRev(file.FileName,".")+1)
If not CheckExp(FileExp) Then
response.Write("<script>window.alert('上传照片出错!当前设置不能上传该格式的文件!');history.go(-1)</script>")
Set File=nothing
response.End()
End IF
PhotoFormat=FileExp
filename=GetRndFileName&FileExp
File.SaveAs Server.mappath("UploadFile/"&filename) ''保存文件
iCount=iCount+1
Else
img=true
End If
Set File=nothing
next
set upload=nothing
'------保存文件开始
dim Rs
sql="select * from stu where id="&id&""
set Rs=Server.CreateObject("Adodb.Recordset")
Rs.open sql,conn,1,3
if img=false then
Rs("images")="UploadFile/"&filename
end if
Rs("yuanxi")=yuanxi
Rs("banji")=banji
Rs("zhuanye")=zhuanye
Rs("content")=Content
Rs("zhuti")=zhuti
Rs.Update
Rs.close
Set Rs=nothing
response.Write("<script>window.alert('编辑修改成功!');window.location.href='./admin_index.asp'</script>")
response.End()
end sub
Rem 文件扩展名检测
Function CheckExp(TheFileExp)
Dim defaultPhotoFormat,i
TheFileExp=lcase(TheFileExp)
CheckExp=False
If TheFileExp="" Then
CheckExp=False
Exit Function
End If
If Instr(const_PhotoFormat,",")>0 Then
defaultPhotoFormat=Split(const_PhotoFormat,",")
Else
defaultPhotoFormat=const_PhotoFormat
End If
If IsArray(defaultPhotoFormat) Then
For i=0 To Ubound(defaultPhotoFormat)
If TheFileExp=defaultPhotoFormat(i) Then
CheckExp=True
Exit For
End If
Next
Else
If TheFileExp=defaultPhotoFormat Then
CheckExp=True
End If
End If
End Function
Rem 得到随即文件名,时间加随机数,理论上不会重名
Function GetRndFileName()
Dim tmpstr
randomize
tmpstr=Int(1000*rnd)
tmpstr="J_G"&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&tmpstr
GetRndFileName=tmpstr
End Function
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -