📄 admin_newscatadelete.asp
字号:
<!--#include file = "../inc/dbclass.inc.asp" -->
<!--#include file = "../inc/syslogincheck.inc.asp" -->
<%
' =============================================================
' made by xiasp & 智多网络 http://www.cq18.com/ qq群:12403617
' =============================================================
%>
<%
call header("删除信息类别")
call content()
call footer()
' 本页内容区
sub content()
dim h_level
h_level = session("sys_level")
'验证权限
if h_level > 1 then
' 传入参数:新闻id
dim srootid
srootid = getsafestr(trim(request("delrootid")))
' 新闻id有效性验证,防止有些人恶意的破坏此演示程序
if len(srootid) < 5 then
goerror "请通过页面上的链接进行操作,不要试图进行任何非法操作。"
end if
dim ars, asql, alen
set ars = server.createobject( "adodb.recordset" )
asql = "select * from newscata where c_rootid = '"&srootid&"'"
ars.open asql, oconn, 1, 1
if not ars.eof then
alen = len(srootid)
else
call oktowhere("请通过页面上的链接进行操作,不要试图进行任何非法操作。","-1")
end if
ars.close
set ars = nothing
dim brs, bsql, brootid
set brs = server.createobject( "adodb.recordset" )
bsql = "select * from newscata order by c_id desc"
brs.open bsql, oconn, 1, 3
do while not brs.eof
brootid = brs("c_rootid")
if mid(brootid,1,alen) = srootid then
call delnews(brootid)
' 删除信息类别
brs.delete
brs.update
end if
'其实这里应该还有一个非常重要的操作,由于时间的关系,暂时不写,留待以后再扩充。
'如果不是频繁的对类别进行操作,这里写不写都无所谓的。
'但是作为一个严谨的程序来讲,此操作必不可少!-----踏雪无痕
brs.movenext
loop
brs.close
set brs = nothing
call oktowhere("信息类别删除成功,确认返回!","-1")
else
call oktowhere("您的权限不足以进行次操作!","-1")
end if
end sub
sub delnews(idstr)
' 从新闻数据表中取出相关的上传文件
' 上传后保存到本地服务器的路径文件名,多个以"|"分隔
' 删除文件,要取带路径的文件名才可以,并且只要这个就可以了!
dim crs, csql, ssavepathfilename
set crs = server.createobject( "adodb.recordset" )
csql = "select * from newsdata where d_cataid = '"&idstr&"'"
crs.open csql, oconn, 1, 3
do while not crs.eof
ssavepathfilename = crs("d_savepathfilename")
' 把带"|"的字符串转为数组
dim asavepathfilename
asavepathfilename = split(ssavepathfilename, "|")
' 删除新闻相关的文件,从文件夹中
dim j
for j = 0 to ubound(asavepathfilename)
' 按路径文件名删除文件
call dodelfile(asavepathfilename(j))
next
' 删除新闻
crs.delete
crs.update
crs.movenext
loop
crs.close
set crs = nothing
end sub
' 删除指定的文件
sub dodelfile(spathfile)
on error resume next
dim ofso
set ofso = server.createobject("scripting.filesystemobject")
ofso.deletefile(server.mappath(spathfile))
set ofso = nothing
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -