📄 admin_news_lm.asp
字号:
<!--#include file = admin_chk.asp -->
<%
If Not ChkAdmin("News_Class") Then
Call ArtErr("","")
End If
Response.Write "<html>"
Response.Write"<head>"
Response.Write"<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"
Response.Write"<link href=""../images/admin/style.css"" rel=""stylesheet"" type=""text/css"">"
Response.Write"</head><body>"
Response.write " <table cellpadding=2 cellspacing=1 border=0 width=98% class=tableBorder align=center>"
Response.Write"<tr align=center>"
Response.Write"<th height=25 align=center colspan=2><strong>栏目管理</strong></th>"
Response.Write"</tr>"
Response.Write" <tr>"
Response.Write" <td width=12% height=30 class=forumRow> <strong>管理导航:</strong></td>"
Response.Write" <td width=88% height=30 class=forumRow><a href='admin_news_lm.asp'>栏目管理</a> | <a href='admin_news_lm_move.asp'>栏目移动</a>"
Response.Write" </td>"
Response.Write " </tr>"
Response.Write"</TABLE>"
Dim Action,lmid,lmname,delid,lm21,lm22
Action = LCase(Request("action"))
lmid=trim(request("lmid"))
lmname=trim(request("lmname"))
delid=trim(request("delid"))
Select Case Trim(Action)
Case "lmadd"
Call addlm()
Case "lm2add"
Call addlm2()
Case "lm3add"
Call addlm3()
Case "lmhb"
Call lmhb()
Case "del"
Call del()
Case Else
Call showmain()
End Select
call CloseConn()
call AdminPageEnd()
Response.Write "</body></html>"
Sub lmhb()
lm21=trim(request("lm21"))
lm22=trim(request("lm22"))
if lm21<>"" and lm22<>"" then
lm21=split(lm21,"|")
lm22=split(lm22,"|")
conn.Execute = "update news set lm='"&lm22(0)&"',lm2='"&lm22(1)&"' where lm2='"&lm21(1)&"'"
call ArtErr("<li>您已成功合并了栏目!</li>","2")
end if
end Sub
Sub addlm()
if request("lm")<>"" then
if trim(request("lm_path"))<>"" then
lm_path=trim(request("lm_path"))
end if
lm_path_sql = "select * from lm where lm_path='"&lm_path&"'"
Set lm_path_rs = Server.CreateObject("ADODB.RecordSet")
lm_path_rs.Open lm_path_sql,conn,1,3
n_recordcount=lm_path_rs.recordcount
lm_path_rs.close
set lm_path_rs=nothing
if n_recordcount>0 then
call ArtErr("<li>目录名称["&lm_path&"]已重复,请重新命名!</li>","1")
conn.close
set conn=nothing
end if
sql = "select * from lm"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,3
rs.addnew
rs("lm")=trim(request("lm"))
rs.update
'由于SQL数据库不允许在rs.close之前有两次update,所以修改一下。方便SQL数据库调用。
rs.close
set rs=nothing
sql = "select * from lm where lm='"&trim(request("lm"))&"'"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,3
'修改结束。
if trim(request("lm_path"))<>"" then
rs("lm_path")=lm_path
else
rs("lm_path")="lm_"&trim(cstr(rs("id")))
end if
rs.update
rs.close
set rs=nothing
call ArtErr("<li>您已成功添加了一级栏目["&trim(request("lm"))&"]!</li>","2")
end if
End Sub
Sub addlm2
if lmid<>"" and lmname<>"" then
if trim(request("lm_path"))<>"" then
lm_path=trim(request("lm_path"))
end if
lm2_path_sql = "select * from lm where lm_path='"&lm_path&"'"
Set lm2_path_rs = Server.CreateObject("ADODB.RecordSet")
lm2_path_rs.Open lm2_path_sql,conn,1,3
n_recordcount=lm2_path_rs.recordcount
lm2_path_rs.close
set lm2_path_rs=nothing
if n_recordcount>0 then
call ArtErr("<li>目录名称["&lm_path&"]已重复,请重新命名!</li>","1")
end if
if lm_path<>"" then
conn.Execute "insert into [lm] ([lmid],[lm2],[lm_path]) values('"&lmid&"','"&lmname&"','"&lm_path&"')"
else
conn.Execute "insert into [lm] ([lmid],[lm2]) values('"&lmid&"','"&lmname&"')"
lm2_id_sql = "select id from lm where lmid='"&lmid&"' and lm2='"&lmname&"'"
Set lm2_id_rs = Server.CreateObject("ADODB.RecordSet")
lm2_id_rs.Open lm2_id_sql,conn,1,3
id=lm2_id_rs("id")
lm_path="lm_"&trim(cstr(id))
lm2_id_rs.close
set lm2_id_rs=nothing
conn.Execute "update [lm] set lm_path='"&lm_path&"' where id="&id
end if
call ArtErr("<li>您已成功添加了二级栏目["&lmname&"]!</li>","2")
end if
End Sub
Sub addlm3()
if lmid<>"" and lmname<>"" then
if trim(request("lm_path"))<>"" then
lm_path=trim(request("lm_path"))
end if
lm3_path_sql = "select * from lm where lm_path='"&lm_path&"'"
Set lm3_path_rs = Server.CreateObject("ADODB.RecordSet")
lm3_path_rs.Open lm3_path_sql,conn,1,3
n_recordcount=lm3_path_rs.recordcount
lm3_path_rs.close
set lm3_path_rs=nothing
if n_recordcount>0 then
call ArtErr("<li>目录名称["&lm_path&"]已重复,请重新命名!</li>","1")
end if
if lm_path<>"" then
conn.Execute "insert into [lm] ([lmid],[lm3],[lm_path]) values('"&lmid&"','"&lmname&"','"&lm_path&"')"
else
conn.Execute "insert into [lm] ([lmid],[lm3]) values('"&lmid&"','"&lmname&"')"
lm3_id_sql = "select id from lm where lmid='"&lmid&"' and lm3='"&lmname&"'"
Set lm3_id_rs = Server.CreateObject("ADODB.RecordSet")
lm3_id_rs.Open lm3_id_sql,conn,1,3
id=lm3_id_rs("id")
lm_path="lm_"&trim(cstr(id))
lm3_id_rs.close
set lm3_id_rs=nothing
conn.Execute "update lm set lm_path='"&lm_path&"' where id="&id
end if
call ArtErr("<li>您已成功添加了三级栏目["&lmname&"]!</li>","2")
end if
End Sub
Sub Del()
if delid<>"" then
'加强功能,如果有新闻存在,则不允许删除这个栏目,必须要先删除新闻再删除栏目,防止意外删除新闻。
count_news_sql="select count(id) as news_count from [news] where lm='"&delid&"' or lm2='"&delid&"' or lm3='"&delid&"' "
Set count_news_rs = Server.CreateObject("ADODB.RecordSet")
count_news_rs.Open count_news_sql,conn,1,3
news_count=count_news_rs("news_count")
count_news_rs.close
set count_news_rs=nothing
if news_count>=1 then '如果有新闻存在,则不能删除这个栏目,防止新闻无意中丢失.
call ArtErr("<li>不允许删除有新闻的栏目或其子栏目!</li><li>原因是栏目或其子栏目里有新闻存在,请先删除新闻再删除栏目!</li>","1")
else
conn.Execute "delete from [lm] where ID="&clng(delid)& " and lm<>''" '删除一级栏目的操作
'二级栏目下,如果有三级栏目,要删除其三级栏目。修正原没有删除三级栏目的错误。
del_lm2_id_sql="select id from [lm] where lmid='"&delid&"' and lm2<>''"
Set del_lm2_id_rs = Server.CreateObject("ADODB.RecordSet")
del_lm2_id_rs.Open del_lm2_id_sql,conn,1,3
do while not del_lm2_id_rs.eof
conn.Execute "delete from [lm] where lmID='"&del_lm2_id_rs("id")&"' and lm3<>''" '删除三级栏目的操作
del_lm2_id_rs.movenext
loop
del_lm2_id_rs.close
set del_lm2_id_rs=nothing
conn.Execute "delete from [lm] where ID="&clng(delid)& " and lm2<>''" '删除二级栏目的操作
conn.Execute "delete from [lm] where lmID='"&delid&"' and lm2<>''" '删除二级栏目的操作,-2006-9-29补丁,天星发现的
conn.Execute "delete from [lm] where lmID='"&delid&"' and lm3<>''" '删除二级栏目的操作
conn.Execute "delete from [lm] where ID="&clng(delid)& " and lm3<>''" '删除三级栏目的操作
end if
Call ArtErr("<li>此栏目已经删除成功!</li>","2")
end if
End Sub
Sub showmain()
%>
<table border="0" cellpadding="0" cellspacing="0" width="100%" >
<tr>
<td>
<table cellpadding=2 cellspacing=1 border=0 width=98% class=tableBorder align=center>
<form method="POST" action="?action=lmhb">
<tr>
<td width="18%" class="forumRow" height="40" ><b><u>合并栏目:</u></b><br><font color="green">合并栏目中所有数据</font></td>
<td class="Forumrow" height="40">
<select size="1" name="lm21">
<%
sql = "select * from lm where lm<>'' order by id_desc,id asc"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,1
while not rs.eof
response.write "<optgroup label=(ID:"&rs("id")&")"&rs("lm")&">"
sql2 = "select * from lm where lmid='"&rs("id")&"' order by id_desc,id asc"
Set rs2 = Server.CreateObject("ADODB.RecordSet")
rs2.Open sql2,conn,1,1
while not rs2.eof
%>
<option value='<%=rs("id")%>|<%=rs2("id")%>'>├(编号:<%=rs2("id")%>)<%=rs2("lm2")%></option>
<%
rs2.movenext
wend
rs2.close:set rs2=nothing
rs.movenext
wend
rs.close:set rs=nothing
%>
</select> 合并到 <select size="1" name="lm22">
<%
sql = "select * from lm where lm<>'' order by id_desc,id asc"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,1
while not rs.eof
response.write "<optgroup label=(ID:"&rs("id")&")"&rs("lm")&">"
sql2 = "select * from lm where lmid='"&rs("id")&"' order by id_desc,id asc"
Set rs2 = Server.CreateObject("ADODB.RecordSet")
rs2.Open sql2,conn,1,1
while not rs2.eof
%>
<option value='<%=rs("id")%>|<%=rs2("id")%>'>├(编号:<%=rs2("id")%>)<%=rs2("lm2")%></option>
<%
rs2.movenext
wend
rs2.close:set rs2=nothing
rs.movenext
wend
rs.close:set rs=nothing
%>
</select> <input type="submit" value=" 合 并 " name="B2">
<!-- 豪气冲天,增加一个按纽。上面是原代码,一字不改 -->
<input type="button" onClick="location='admin_news_lm_move.asp'" value="栏目移动">
<!-- 豪气冲天,结束增加一个按纽 下面是原代码,一字不改-->
</td>
</tr></form>
<tr>
<!--webbot BOT="GeneratedScript" PREVIEW=" " startspan --><script Language="JavaScript" Type="text/javascript"><!--
function FrontPage_Form2_Validator(theForm)
{
if (theForm.lm.value == "")
{
alert("请在 lm 域中输入值。");
theForm.lm.focus();
return (false);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -