📄 admin_news_act.asp
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<%
if request.cookies("admin_OK")="" then
response.redirect("admin_login.html")
end if
%>
<%dim db
db=0
%>
<!--#include file="../config/db.asp"-->
<!--#include file="../config/function.inc.asp"-->
<%
dim rst,sql,myErrors,fs,rid
rid=request.querystring("id")
set rst=server.CreateObject("adodb.recordset")
set fs=server.CreateObject("scripting.FileSystemObject")
on error resume next
if request.QueryString("act")="add" or request.QueryString("act")="update" then
%>
<!--#include file="../config/formdata.inc.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>处理新闻</title>
</head>
<body>
<%'------------添加新闻,内容,图片--------------------------
if request.QueryString("act")="add" then
sql="shop_news"
rst.open sql,conn,1,3
rst.addnew
if formdata.item("upid1")=0 then
msgboxU "你未选择二级分类"
response.end()
else
rst("n_ncid")=formdata.item("upid1")
rst("n_title")=formdata.item("title")
rst("n_content")=formdata.item("content")
rst("n_image")=formdata.item("image")
end if
rst.update
rst.close
set myErrors=conn.errors
if myErrors.count=0 then
msgboxU "添加新闻<"&formdata.item("title")&">成功!"
else
msgboxU "添加新闻失败!原因:"&myErrors.item(0).description
'删除已经上传的文件
if formdata.item("image")<>"" then fs.DeleteFile server.MapPath("../upfile") & "\" & formdata.item("image")
end if
end if
%>
<%'--------------删除新闻管理---------------------
if request.querystring("act")="del" then
if not isnumeric(rid) or isempty(rid) then
msgboxU "非法参数"
response.end
else
if request.querystring("act")="del" then
sql="delete from shop_news where n_id="&request.querystring("id")
conn.execute sql
set myErrors=conn.errors
if myErrors.count=0 then
msgboxU "删除成功!"
if request.querystring("file")<>"" then fs.DeleteFile server.MapPath("../upfile") & "\" & request.querystring("file")
else
msgboxU "删除失败!原因:"&myErrors.item(0).description
end if
end if
end if
end if
%>
<%'---------------修改新闻--------------------------
if request.querystring("act")="update" then
if not isnumeric(rid) or isempty(rid) then
msgboxU "非法参数"
response.end
else
sql="select * from shop_news where n_id="&rid
rst.open sql,conn,1,3
rst("n_title")=formdata.item("title1")
rst("n_content")=formdata.item("content1")
if formdata.item("image1")<>"" then
if rst("n_image")<>"" then
fs.DeleteFile server.MapPath("../upfile")&"\"&rst("n_image")
end if
rst("n_image")=formdata.item("image1")
end if
rst.update
rst.close
set myErrors=conn.errors
if myErrors.count=0 then
msgboxU "修改成功!"
else
msgboxU "修改失败!原因:"&myErrors.item(0).description
if formdata.item("image1")<>"" then fs.DeleteFile server.MapPath("../upfile")&"\"&formdata.item("image1")
end if
end if
end if
%>
<%'------------------------新闻置顶---------------------------
if request.querystring("act")="top" then
if not isnumeric(rid) or isempty(rid) then
msgboxU "非法参数"
response.end
else
conn.execute "update shop_news set n_top=true where n_id="&request.querystring("id")
set myErrors=conn.errors
if myErrors.count=0 then
msgboxU "置顶成功!"
else
msgboxU "置顶失败!原因:"&myErrors.item(0).description
end if
end if
end if
%>
<%'-----------------------取消新闻置顶----------------------------
if request.querystring("act")="top1" then
if not isnumeric(rid) or isempty(rid) then
msgboxU "非法参数"
response.end
else
conn.execute "update shop_news set n_top=false where n_id="&request.querystring("id")
set myErrors=conn.errors
if myErrors.count=0 then
msgboxU "取消置顶成功!"
else
msgboxU "取消置顶失败!原因:"&myErrors.item(0).description
end if
end if
end if
%>
<%
set rst=nothing
conn.close
set conn=nothing
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -