<%
if session("admin")<>"on" then
Response.Redirect"login.asp"
end if
%>
<!--#include file="mdb/conn.asp" -->
<!--#include file="info.asp" -->
<%

if Request.QueryString("cz")="" then
Response.Redirect"info.asp?info=错误的参数"
else
cz=Request.QueryString("cz")
end if

if cz="del" then

conn.execute "delete from desktop where id="&Request.QueryString("id")
Response.Redirect"adminfile.asp"

else

REM ------判断数据有效性------

founderr=false
if trim(Request.Form("name"))="" then
founderr=true
info=info+"<li>请填写文件名称</li>"
end if
if trim(Request.Form("typeid"))="" then
founderr=true
info=info+"<li>请选择分类</li>"
end if
if trim(Request.Form("pic"))="" then
founderr=true
info=info+"<li>请填写放大图或者Flash文件地址</li>"
end if

REM ------如果数据是有效的则开始存储数据并显示相关信息------

if founderr=false then 
set rs=server.createobject("adodb.recordset")
if cz="addfile" then
sql="select * from desktop where (id is null)" 
rs.open sql,conn,1,3
rs.addnew
rs("time")=now()
else
sql="select * from desktop where id="&Request.QueryString("id") 
rs.open sql,conn,1,3
end if
rs("name")=Request.Form("name")
rs("pic")=Request.Form("pic")
rs("typeid")=Request.Form("typeid")
rs("classid")=Request.QueryString("classid")
rs("hot")=Request.Form("hot")
rs("lx")=Request.Form("lx")
if Request.Form("url")<>"" then
rs("url")=Request.Form("url")
end if
if Request.Form("dx")<>"" then
rs("dx")=Request.Form("dx")
end if
if Request.Form("jj")<>"" then
rs("jj")=HTMLEncode2(Request.Form("jj"))
end if
if Request.Form("minipic")="" then
rs("minipic")="images/nominipic.gif"
else
rs("minipic")=Request.Form("minipic")
end if
rs.update
rs.close
set rs=nothing
conn.close
Set conn=Nothing
if cz="addfile" then
Response.Redirect"admin.asp"
else
Response.Redirect"adminfile.asp"
end if

REM ------如果数据是无效的则开始显示错误信息------

else
call infom()
end if

end if

function HTMLEncode2(fString)
	fString = Replace(fString, CHR(13), "")
	fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
	fString = Replace(fString, CHR(10), "<BR>")
	HTMLEncode2 = fString
end function
%>