admin_column.asp
来自「关于网络渗透技术的详细讲解」· ASP 代码 · 共 354 行
ASP
354 行
<!-- #include file="../Conn.asp" -->
<!-- #include file="inc.asp" -->
<%
'====================================================================
'= Copyright (c) 2004,NB联盟 E.P.K开发小组 =
'= All rights reserved. =
'=------------------------------------------------------------------=
'= 文件名称:Admin_Column.asp =
'= 摘 要:后台—栏目管理 =
'=------------------------------------------------------------------=
'= 最后更新:eason007 =
'= 最后日期:2004-12-18 =
'====================================================================
Admin_Nav
If Instr(1,Session("Master_Power"),"21,")<=0 Then
ErrMsg="对不起,你没有访问该页面的权限"
Call Error(1)
End If
Dim Atcion
Dim PostId,Typer
Atcion=Request.QueryString ("atcion")
PostId=Request.QueryString ("postid")
%>
<table width="98%" cellpadding="5" cellspacing="0" align="center">
<tr>
<th width="100%" height="22" valign="middle"><a href="?"><font color=ffffff>管理首页</font></a> | <a href="?atcion=add"><font color=ffffff>新增栏目</font></a></th>
</tr>
</table>
<br>
<%
Select Case Atcion
Case "save"
Call Save
Case "del"
Call del
Case "add"
Call Add
Case "up"
Call MoveColumn(1)
Case "down"
Call MoveColumn(0)
Case Else
Call Main
End Select
Sub Main
Dim Ds
Dim Level,i
Sql="select id,Title,code,countnum,iif(type=0,null,'[专题]'),iif(istop=0,null,'[导航]') from [NB_Column] order by code"
'Response.Write (sql)
Set Rs=Conn.Execute(Sql)
If Not rs.eof And Not rs.bof Then Ds=rs.getrows()
%>
<table width="95%" cellpadding="0" cellspacing="0" align="center" class=TableBorder>
<tr height=22>
<th width="45%">ID/栏目名称</th>
<th width="10%">文章数</th>
<th width="1%"></th>
<th width="10%">排序</th>
<th width="20%">操作</th>
</tr>
<%
If IsArray(Ds) Then
For i=0 To Ubound(Ds,2)
Level=(Len(Ds(2,i))/4-1)*4
'response.write level
'response.flush
Response.Write "<tr valign=""middle"" align=""center"" height=""22"" onmouseover=this.style.backgroundColor='E4E8EF' onmouseout=this.style.backgroundColor=''>"
Response.Write "<td align=""left""> [<font color=3366cc>"&Ds(0,i)&"</font>] "
If Len(Ds(2,i))>4 Then Response.Write "├"
Response.Write String(Level,"-")&"<a href='../list.asp?classid="&Ds(0,i)&"' target='_blank'><b>"&Ds(1,i)&"</b></a> "&Ds(4,i)&Ds(5,i)&"</td>"
Response.Write "<td class=forumRowHighlight>"&Ds(3,i)&"</td>"
Response.Write "<td> </td>"
Response.Write "<td class=forumRow><a href=""?atcion=up&colcode="&Ds(2,i)&""" title=""上升一级"">↑</a> | <a href=""?atcion=down&colcode="&Ds(2,i)&""" title=""下降一级"">↓</a></td>"
Response.Write "<td align=""right""><a href=""?atcion=add&postid="&Ds(0,i)&""" title=""重命名"">编辑</a> <a href=""reload.asp?atcion=update&postid="&Ds(0,i)&""">更新数据</a> <a href=""?atcion=del&table=dept&postID="&Ds(0,i)&""" onclick=""{if(confirm('确定删除吗?')){return true;}return false;}"">删除</a></b> </td>"
Response.Write "</tr>"
Next
Else
Response.Write "<tr>"
Response.Write "<td colspan=""5"" bgcolor=""ffffff"" height=""22""> <font color=red>暂无记录</font></td>"
Response.Write "</tr>"
End If
Response.Write "</table>"
End Sub
Sub Add
Dim i,Level
Dim Title,Code,Typer,Info,Url,Style,IsReview,IsPost,IsTop
IsReview=-1
IsPost=-1
IsTop=-1
If IsNumeric(PostId) And PostId<>"" And PostId<>"0" Then
Sql="select [Id],Title,Code,Type,Info,OutURL,StyleId,IsReview,IsPost,IsTop from [NB_Column] where id="&PostId
set rs=conn.execute(sql)
Title=rs(1)
Code=rs(2)
Typer=rs(3)
Info=rs(4)
Url=rs(5)
Style=rs(6)
IsReview=Rs(7)
IsPost=rs(8)
IsTop=Rs(9)
rs.close
End If
%>
<script>
function change(obj,i) {
he=parseInt(obj.style.height);
if (he>=80&&he<=400)
obj.style.height=he+i+'px';
else
obj.style.height='80px';
}
</script>
<table width="85%" border="0" cellspacing="0" cellpadding="0" align=center>
<form action ="?atcion=save&postid=<%=PostId%>" method=post id=form1 name=form1>
<tr>
<th height=25 colspan=2><B>编辑栏目</b></th>
</tr>
<tr>
<td width="40%" class=forumRow align=center>栏目名称</td>
<td width="60%" class=forumRow><input type="text" name="title" size="35" value="<%=Title%>"></td>
</tr>
<tr>
<td width="40%" class=forumRowHighlight align=center>所属分类</td>
<td width="60%" class=forumRowHighlight><select name=code>
<option value="">根栏目</option>
<%Sql="select id,Title,code from [NB_Column] order by code"
set rs=conn.execute(sql)
Do While Not rs.eof
Level=(Len(rs(2))/4-1)*3
Response.Write "<option value="""&rs(2)&""""
If Code<>"" Then
If Left(Code,Len(Code)-4)=rs(2) Then Response.Write " selected"
End If
Response.Write ">"
If Len(rs(2))>4 Then Response.Write "├"
Response.Write String(Level,"-")
Response.Write rs(1)&"</option>"
rs.movenext
Loop
rs.close%>
</select></td>
</tr>
<tr>
<td width="40%" class=forumRow align=center>栏目简介</td>
<td width="60%" class=forumRow><textarea name="info" cols="30" rows="3" wrap="VIRTUAL"><%=Info%></textarea><br> <a href="javascript:change(document.all.info,-20)"><img src="images/minus.gif" border=0 title="缩小文本框"></a> <a href="javascript:change(document.all.info,20)"><img src="images/plus.gif" border=0 title="放大文本框"></a></td>
</tr>
<tr>
<td width="40%" class=forumRowHighlight align=center>栏目类型</td>
<td width="60%" class=forumRowHighlight><select name=type><option value="0"<%If Typer="0" Then%> selected <%End If%>>正常</option><option value="1"<%If Typer="1" Then%> selected <%End If%>>专题</option></select></td>
</tr>
<tr>
<td width="40%" class=forumRow align=center>显示风格</td>
<td width="60%" class=forumRow><select name="style"><option value="0"<%If Style="0" Then%> selected <%End If%>>列表式</option><option value="1"<%If Style="1" Then%> selected <%End If%>>简介式</option><option value="2"<%If Style="2" Then%> selected <%End If%>>图片式</option><option value="3"<%If Style="3" Then%> selected <%End If%>>图文式</option></select></td>
</tr>
<tr>
<td width="40%" class=forumRowHighlight align=center>外部连接</td>
<td width="60%" class=forumRowHighlight><input type="text" name="url" size="35" value="<%=Url%>"></td>
</tr>
<tr>
<td width="40%" class=forumRow align=center>允许发表评论</td>
<td width="60%" class=forumRow>是<input type="radio" name="isreview" value="1"<%If IsReview=-1 Then%> checked <%End If%>> 否<input type="radio" name="isreview" value="0"<%If IsReview=0 Then%> checked <%End If%>></td>
</tr>
<tr>
<td width="40%" class=forumRowHighlight align=center>允许会员投稿</td>
<td width="60%" class=forumRowHighlight>是<input type="radio" name="ispost" value="1"<%If IsPost=-1 Then%> checked <%End If%>> 否<input type="radio" name="ispost" value="0"<%If IsPost=0 Then%> checked <%End If%>></td>
</tr>
<tr>
<td width="40%" class=forumRow align=center>允许在导航菜单显示</td>
<td width="60%" class=forumRow>是<input type="radio" name="istop" value="1"<%If IsTop=-1 Then%> checked <%End If%>> 否<input type="radio" name="istop" value="0"<%If IsTop=0 Then%> checked <%End If%>></td>
</tr>
<tr bgcolor="f7fbff">
<td colspan="2" height=25 align=center><input type="submit" name="Submit" value="确定"> <input type="reset" name="Submit2" value="重置"></td>
</tr>
</form>
</table>
<%End Sub
Function MoveColumn(IsUp)
On Error Resume Next
If Not ChkPost Then
ErrMsg="对不起,请不要从外部提交数据!"
Call Error(1)
End If
Dim ColumnCode,TempStr,CodeLen,NBStr,WStr
ColumnCode=Request.QueryString ("colcode")
CodeLen=Len(ColumnCode)
NBStr=String(CodeLen,"-")
If ColumnCode<>"" And (Len(ColumnCode) Mod 4)=0 Then
If CodeLen>4 Then WStr="and left(code,"&CodeLen-4&")='"&Left(ColumnCode,CodeLen-4)&"'"
If IsUp Then
SQL="select top 1 code from [NB_Column] where len(code)="&CodeLen&" and code<'"&ColumnCode&"' "&WStr&" order by code desc"
'Response.Write sql&"<br>"
TempStr=conn.execute(sql)(0)
Else
SQL="select top 1 code from [NB_Column] where len(code)="&CodeLen&" and code>'"&ColumnCode&"' "&WStr&" order by code"
'Response.Write sql&"<br>"
TempStr=conn.execute(sql)(0)
End If
If Err Then
ErrMsg="对不起,已经是尽头不能再移动了。"
Call Error(1)
End If
'移动上层栏目
SQL="update nb_column set code='"&NBStr&"'+mid(code,"&CodeLen+1&",len(code)) where left(code,"&CodeLen&")='"&TempStr&"'"
'Response.Write sql&"<br>"
conn.execute(sql)
'更新目标栏目
SQL="update nb_column set code='"&TempStr&"'+mid(code,"&CodeLen+1&",len(code)) where left(code,"&CodeLen&")='"&ColumnCode&"'"
'Response.Write sql&"<br>"
conn.execute(sql)
'更新上层栏目
SQL="update nb_column set code='"&ColumnCode&"'+mid(code,"&CodeLen+1&",len(code)) where left(code,"&CodeLen&")='"&NBStr&"'"
'Response.Write sql&"<br>"
conn.execute(sql)
'修复文章表中栏目信息
SQL="update [NB_Content] left join [NB_Column] c on [NB_Content].columnid=c.id set columncode=c.code,columnname=c.title where columncode like '"&ColumnCode&"%'"
conn.execute(sql)
End If
CloseDataBase
Response.Redirect Request.ServerVariables("HTTP_REFERER")
End Function
Function Del
If Not ChkPost Then
ErrMsg="对不起,请不要从外部提交数据!"
Call Error(1)
End If
If IsNumeric(PostId) And PostId<>"" And PostId<>"0" Then
Dim DelBool,TxtCount,Under
DelBool=False
Sql="select count(id) from [NB_Content] where ColumnId="&PostId
TxtCount=conn.execute(sql)(0)
If TxtCount>0 Then DelBool=True:ErrMsg="对不起,栏目内还有文章,请清空或转移后再进行删除操作!"
Sql="select count(id) from [NB_Column] where code like (select code from [nb_column] where id="&PostId&")+'%' and id<>"&PostId
Under=conn.execute(sql)(0)
If Under>0 Then DelBool=True:ErrMsg="对不起,栏目尚有下属版块!"
'Response.Write sql
If Not DelBool Then
conn.execute("delete from [NB_Column] where ID="&postID)
conn.execute("UPDATE NB_System SET ColumnNum=ColumnNum-1")
Else
Call Error(1)
End If
End If
CloseDataBase
Response.Redirect Request.ServerVariables("HTTP_REFERER")
End Function
Function Save
If Not ChkPost Then
ErrMsg="对不起,请不要从外部提交数据!"
Call Error(1)
End If
Dim Name,Info,Typer,Url,Style,IsReview,IsPost,IsTop
Dim MatchStr,ParentCode,TypeCode,SelfCode,StepLeng
Dim EditCode,IsOut,IsChange,SourCode
EditCode=False
StepLeng=4
Name=HTMLEncode(Request.Form ("title"))
Info=Request.Form ("info")
Typer=Request.Form ("type")
Url=Request.Form("url")
ParentCode=Request.Form ("code")
Style=Request.Form ("style")
IsReview=Request.Form ("isreview")
IsPost=Request.Form ("ispost")
IsTop=Request.Form ("istop")
MatchStr=String(StepLeng,"_")
If Name="" Or Len(Name)>50 Then
ErrMsg="栏目名称为空或长度超过50个字符!"
Call Error(1)
End If
If Url<>"" Then
IsOut=True
Else
IsOut=False
End If
If IsNumeric(PostId) And PostId<>"" And PostId<>"0" Then
IsChange=True
Else
IsChange=False
End If
If IsChange Then
SourCode=conn.execute("select code from [NB_Column] where id="&PostId)(0)
If Cstr(ParentCode)<>Cstr(conn.execute("select left(code,len(code)-4) from [NB_Column] where id="&PostId)(0)) Then EditCode=True
Else
EditCode=True
End If
If EditCode Then
Sql="Select Top 1 code from [NB_Column] where code like '"&ParentCode&MatchStr&"' order by code desc"
'Response.Write sql
Set rs=conn.execute(sql)
If rs.eof Then
TypeCode=ParentCode&String(StepLeng-1,"0")&"1"
Else
SelfCode=int(right(rs(0),StepLeng))+1
SelfCode=right(String(StepLeng-1,"0")&SelfCode,StepLeng)
TypeCode=ParentCode&SelfCode
End If
Set rs=Nothing
End If
If Not IsChange Then
Sql="insert into [NB_Column] (title,code,info,isout,outurl,StyleId,IsReview,IsPost,IsTop,Type)"
Sql=Sql&" values ('"&Name&"','"&TypeCode&"','"&Info&"',"&IsOut&",'"&Url&"',"&Style&","&IsReview&","&IsPost&","&IsTop&","&Typer&")"
Else
Sql="update [NB_Column] set title='"&Name&"',info='"&Info&"',isout="&IsOut&",outurl='"&Url&"',Type="&Typer&",StyleId="&Style&",IsReview="&IsReview&",IsPost="&IsPost&",IsTop="&IsTop
If EditCode Then Sql=Sql&",code='"&TypeCode&"'"
Sql=Sql&" where id="&PostId
End If
'Response.Write sql
'Response.Flush
conn.execute(sql)
If IsChange Then
If EditCode Then
SQL="update [NB_Column] Set Code='"&TypeCode&"'+Right(Code,Len(Code)-"&Len(SourCode)&") Where Code like '"&SourCode&"%'"
'response.write sql
'response.flush
conn.execute(sql)
End If
'更新文章表中栏目信息
SQL="update [NB_Content] left join [NB_Column] c on [NB_Content].columnid=c.id set columncode=c.code,columnname=c.title where columncode like '"&SourCode&"%'"
conn.execute(sql)
Else
conn.execute("UPDATE NB_System SET ColumnNum=ColumnNum+1")
End If
CloseDataBase
Response.Redirect "Admin_Column.asp"
End Function
%>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?