<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!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>
<TITLE>网站栏目添加</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<LINK href="images/style.css" type=text/css rel=stylesheet>
<style type="text/css">
<!--
.style1 {
color: #FF0000;
font-weight: bold;
}
-->
</style>
</head>
<!--#include file="conn.asp"-->
<%
'系统页面加载初始化参数设定
ChannelID=trim(request("ChannelID"))
ParentID=trim(request("ParentID"))
if ChannelID="" or not isnumeric(ChannelID) then ChannelID=Session("ChannelID")
if ChannelID="" then ChannelID=0
if ParentID="" or not isnumeric(ParentID) then ParentID=0
Function ShowClassFormOption(sChannelID,CurrentID,sClassDepth,ShowType)
dim rsClass,sqlClass,sTemp,tmpClassDepth,i,n
dim arrShowLine(10)
for i=0 to ubound(arrShowLine)
arrShowLine(i)=False
next
if ShowType=0 then
sTemp="<option value=""0"""
if CurrentID=0 then sTemp=sTemp & " selected"
sTemp=sTemp & ">无(作为一级栏目)</option>"
end if
sqlClass="Select ClassID,ClassName,ClassDepth,IDPath,ChannelID From SystemClass where ChannelID="&sChannelID&" "
if sClassDepth>0 then
sqlClass=sqlClass & " and ClassDepth<"&sClassDepth&" order by RootID,ClassDepth,IDPath,OrderID"
else
sqlClass=sqlClass & " order by RootID,IDPath,OrderID"
end if
'response.Write(sqlClass)
'response.End()
set rsClass=conn.Execute(sqlClass)
if rsClass.bof and rsClass.bof then
ShowClassFormOption = sTemp & "<option value="""">请先添加栏目</option>"
rsClass.close
set rsClass=Nothing
Exit Function
else
sqlClass=rsClass.GetRows(-1)
rsClass.close
set rsClass=Nothing
End if
Dim sChecked, sTClassName
For i=0 to Ubound(sqlClass,2)
tmpClassDepth=sqlClass(2,i)
if sqlClass(3,i)>0 then
arrShowLine(tmpClassDepth)=True
else
arrShowLine(tmpClassDepth)=False
end if
sChecked = "" : sTClassName = ""
if sqlClass(0,i)=CurrentID then sChecked = " selected"
if tmpClassDepth>0 then
for n=1 to tmpClassDepth
sTClassName = sTClassName & " "
if n=tmpClassDepth then
if sqlClass(3,i)>0 then
sTClassName = sTClassName & "├ "
else
sTClassName = sTClassName & "└ "
end if
else
if arrShowLine(n)=True then
sTClassName = sTClassName & "│"
else
sTClassName = sTClassName & " "
end if
end if
next
end if
sTClassName = sTClassName & sqlClass(1,i)
Select Case ShowType
Case 0
sTemp=sTemp & "<option value=""" & sqlClass(0,i) & """ "&sChecked&">" & sTClassName
if sqlClass(4,i)=1 then sTemp=sTemp & "(外)"
sTemp=sTemp & "</option>"
Case 1
if sqlClass(4,i)=1 then
sTemp=sTemp & "<option value=""0"" "&sChecked&">" & sTClassName & "(外)"
else
sTemp=sTemp & "<option value=""" & sqlClass(0,i) & """ "&sChecked&">" & sTClassName
end if
sTemp=sTemp & "</option>"
Case 2
if sqlClass(4,i)=1 then
sTemp=sTemp & "<option value=""0"" "&sChecked&">" & sTClassName & "(外)"
elseif Not Cl.ChkUserLevel(sqlClass(5,i),Cl.UserLevel) then
sTemp=sTemp & "<option value=""0"" "&sChecked&">" & sTClassName & "(*)"
else
sTemp=sTemp & "<option value=""" & sqlClass(0,i) & """ "&sChecked&">" & sTClassName
end if
sTemp=sTemp & "</option>"
Case 3
if sqlClass(4,i)=0 then
sTemp=sTemp & "<option value=""" & sqlClass(0,i) & """ "&sChecked&">" & sTClassName
sTemp=sTemp & "</option>"
end if
Case 4
if Cl.ChkUserLevel(sqlClass(5,i),Cl.UserLevel) then
sTemp=sTemp & "<option value=""" & sqlClass(0,i) & """ "&sChecked&">" & sTClassName
sTemp=sTemp & "</option>"
end if
Case else
sTemp=sTemp & "<option value=""" & sqlClass(0,i) & """ "&sChecked&">" & sTClassName
sTemp=sTemp & "</option>"
End Select
Next
ShowClassFormOption=sTemp
sqlClass=Empty
End Function
if request("action")="add" then
ParentID=trim(request("ParentID"))
ClassName=trim(request("ClassName"))
ClassDir=trim(request("ClassDir"))
ClassMemo=trim(request("ClassMemo"))
ClassLinkUrl=trim(request("ClassLinkUrl"))
OrderID=trim(request("OrderID"))
CssID=trim(request("CssID"))
StyleID=trim(request("StyleID"))
IsCreateHtml=trim(request("IsCreateHtml"))
IsCreateList=trim(request("IsCreateList"))
ClassLogo=trim(request("ClassLogo"))
ClassBanner=trim(request("ClassBanner"))
if ClassName="" Then
response.write("<script>alert('系统出错!请返回填写网站栏目名称');history.go(-1);</script>")
response.End()
end if
if ClassDir="" Then
response.write("<script>alert('系统出错!请返回填写网站栏目目录文件夹');history.go(-1);</script>")
response.End()
end if
if ClassLinkUrl="" Then
response.write("<script>alert('系统出错!请返回填写收购网站栏目');history.go(-1);</script>")
response.End()
end if
if ClassMemo="" Then
response.write("<script>alert('系统出错!请返回填写网站栏目说明');history.go(-1);</script>")
response.End()
end if
if ParentID=0 then
AddTopParentClass
Function AddTopParentClass()
'添加栏目名称并记录添加人IP等信息
UserIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If UserIP = "" Then UserIP = Request.ServerVariables("REMOTE_ADDR")
UserFrom=Cstr(Request.ServerVariables("HTTP_REFERER"))
set rs=server.CreateObject("Adodb.recordset")
sql="select * from SystemClass where ClassDir='"&CorrectSqlClassDir&"' and ClassName='"&CorrectSqlClassName&"'"
rs.open sql,conn,3,3
if rs.eof and rs.bof then
rs.addnew
rs("RootID")=rs("ClassID")
rs("ClassDepth")=0
rs("ClassName")=ClassName
rs("ClassDir")=ClassDir
rs("ClassMemo")=ClassMemo
rs("ClassLinkUrl")=ClassLinkUrl
rs("ParentName")=ClassName
rs("IDPath")=rs("ClassID")
rs("TitlePath")=ClassName
rs("OrderID")=OrderID
rs("CssID")=CssID
rs("StyleID")=StyleID
rs("ClassLogo")=ClassLogo
rs("ClassBanner")=ClassBanner
rs("IsCreateHtml")=IsCreateHtml
rs("IsCreateList")=IsCreateList
rs("AddUser")=Session("UserName")
rs("AddTime")=now()
rs("AddIP")=UserIP
rs("AddFrom")=UserFrom
rs.update
response.write("<script>alert('网站栏目添加成功!确定返回栏目添加页面');location.href='SystemClassAdd.asp';</script>")
else
response.write("<script>alert('网站栏目已经存在!系统即将返回上一页');history.go(-1);</script>")
end if
rs.close
set rs=nothing
'写入读取后一个ID
End Function
else
response.Write(ParentID)
'response.End()
'response.Write(GetLastParentPath(ParentID))
GetLastParentPath ParentID,sParentClassName,sParentClassDir,sParentClassDepth,sParentClassRootID,sParentIDPath,sParentTitlePath
response.Write("<br>ParentClassName:"&sParentClassName)
response.Write("<br>ParentClassDir:"&sParentClassDir)
response.Write("<br>ParentClassDepth:"&sParentClassDepth)
response.Write("<br>ParentClassRootID:"&sParentClassRootID)
Function GetLastParentPath(sParentID,sParentClassName,sParentClassDir,sParentClassDepth,sParentClassRootID,sParentIDPath,sParentTitlePath)
set rs=server.CreateObject("Adodb.recordset")
sql="select * from SystemClass where ClassID="&sParentID
response.Write(sql)
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write("<script>alert('为能查询到父类ID对应的栏目!系统即将返回上一页');history.go(-1);</script>")
response.End()
else
sParentClassDepth=rs("ClassDepth")
'深度递减
sParentClassRootID=rs("RootID")
'大类ID不变
sParentClassName=rs("ClassName")
'类名循环
sParentClassDir=rs("ClassDir")
'路径循环
sParentIDPath=rs("IDPath")
'ID循环
sParentTitlePath=rs("TitlePath")
'标题循环
end if
rs.close
set rs=nothing
end Function
AddCurrentClassName ParentID,sParentClassName,sParentClassDir,sParentClassDepth,sParentClassRootID,sParentIDPath,sParentTitlePath
Function AddCurrentClassName(ParentID,sParentClassName,sParentClassDir,sParentClassDepth,sParentClassRootID,sParentIDPath,sParentTitlePath)
'添加栏目名称并记录添加人IP等信息
UserIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If UserIP = "" Then UserIP = Request.ServerVariables("REMOTE_ADDR")
UserFrom=Cstr(Request.ServerVariables("HTTP_REFERER"))
set rs=server.CreateObject("Adodb.recordset")
sql="select * from SystemClass where ClassDir='"&CorrectSqlClassDir&"' and ClassName='"&CorrectSqlClassName&"'"
rs.open sql,conn,3,3
if rs.eof and rs.bof then
rs.addnew
rs("RootID")=sParentClassRootID
rs("ParentID")=ParentID
rs("ParentName")=sParentClassName
rs("ClassDepth")=sParentClassDepth+1
rs("ClassDir")=sParentClassDir&"/"&ClassDir
rs("IDPath")=sParentIDPath&","&rs("ClassID")
rs("TitlePath")=sParentTitlePath&","&ClassName
rs("ClassName")=ClassName
rs("ClassMemo")=ClassMemo
rs("ClassLinkUrl")=ClassLinkUrl
rs("OrderID")=OrderID
rs("CssID")=CssID
rs("StyleID")=StyleID
rs("ClassLogo")=ClassLogo
rs("ClassBanner")=ClassBanner
rs("IsCreateHtml")=IsCreateHtml
rs("IsCreateList")=IsCreateList
conn.execute("Update SystemClass Set NextID="&rs("ClassID")&" where ClassID="&ParentID)
rs("AddUser")=Session("UserName")
rs("AddTime")=now()
rs("AddIP")=UserIP
rs("AddFrom")=UserFrom
rs.update
response.write("<script>alert('网站栏目添加成功!确定返回栏目添加页面');location.href='SystemClassAdd.asp';</script>")
else
response.write("<script>alert('网站栏目已经存在!系统即将返回上一页');history.go(-1);</script>")
response.End()
end if
rs.close
set rs=nothing
End Function
end if
conn.close
set conn=nothing
response.End()
end if
%>
<script language="javascript">
function checkform()
{
if (document.form1.ClassName.value=="")
{
alert("栏目名称忘记填写");
document.form1.ClassName.value="新闻文章";
document.form1.ClassName.focus;
return false;
}
if (document.form1.ClassDir.value=="")
{
alert("栏目目录忘记填写");
document.form1.ClassDir.value="www";
document.form1.ClassDir.focus;
return false;
}
if (document.form1.ClassLinkUrl.value=="")
{
alert("栏目链接地址忘记填写");
document.form1.ClassLinkUrl.value="http://www.";
document.form1.ClassLinkUrl.focus;
return false;
}
if (document.form1.ClassMemo.value=="")
{
alert("栏目说明忘记填写");
document.form1.ClassMemo.value="在这里填写栏目说明";
document.form1.ClassMemo.focus;
return false;
}
if (document.form1.OrderID.value=="")
{
alert("排列顺序忘记填写");
document.form1.OrderID.value=1;
document.form1.OrderID.focus;
return false;
}
if (document.form1.StyleID.value=="")
{
alert("栏目模扳ID忘记填写");
document.form1.StyleID.value=1;
document.form1.StyleID.focus;
return false;
}
if (document.form1.CssID.value=="")
{
alert("CSS样式ID忘记填写");
document.form1.CssID.value=1;
document.form1.CssID.focus;
return false;
}
}
</script>
</head>
<body>
<!--#include file="top.asp"-->
<table width="870" height="350" border="0" align="center" cellpadding="0" cellspacing="0">
<form id="form1" name="form1" method="post" onsubmit="return checkform()" action="SystemClassAdd.asp?action=add">
<tr>
<td height="25" colspan="2" align="center"><strong>网站栏目添加</strong></td>
</tr>
<tr class="tdbg">
<td width="150" align="right"><strong>所属栏目:</strong></td>
<td><% response.Write(ChannelID)
response.Write(ParentID)
'response.End()%>
<select name="ParentID" id="ParentID">
<%=ShowClassFormOption(ChannelID,ParentID,0,0)%>
</select>
<span class="style1">*</span><font color="#ff0033">注意:不能指定为外部栏目</font></td>
</tr>
<tr>
<td height="25" align="right">栏目名称:</td>
<td width="548" height="25"><input name="ClassName" type="text" id="ClassName" size="30" maxlength="30" value="<%=Session("ClassName")%>" />
<span class="style1">*</span></td>
</tr>
<tr>
<td height="25" align="right">栏目文件夹:</td>
<td height="25"><input name="ClassDir" type="text" id="ClassDir" size="30" maxlength="255" value="<%=Session("ClassDir")%>" />
<span class="style1">*</span></td>
</tr>
<tr>
<td height="25" align="right">链接地址:</td>
<td height="25"><input name="ClassLinkUrl" type="text" id="ClassLinkUrl" size="40" maxlength="255" value="<%=Session("ClassLinkUrl")%>" />
<span class="style1">*</span></td>
</tr>
<tr>
<td height="25" align="right">栏目说明:</td>
<td height="25"><textarea name="ClassMemo" cols="40" rows="6" id="ClassMemo"><%=Session("ClassMemo")%></textarea>
<span class="style1">*</span></td>
</tr>
<tr>
<td height="25" align="right">生成列表:</td>
<td height="25">
<select name="IsCreateList" id="IsCreateList" >
<option value="1" <%if Session("IsCreateList")=1 then response.Write("selected")%>>是</option>
<option value="0" <%if Session("IsCreateList")=0 then response.Write("selected")%> >否</option>
</select></td>
</tr>
<tr>
<td height="25" align="right">生成HTML:</td>
<td height="25">
<select name="IsCreateHtml" id="IsCreateHtml" >
<option value="1" <%if Session("IsCreateHtml")=1 then response.Write("selected")%> >是</option>
<option value="0" <%if Session("IsCreateHtml")=0 then response.Write("selected")%>>否</option>
</select></td>
</tr>
<tr>
<td height="25" align="right"><p>栏目Logo:</p> </td>
<td height="25"><input name="ClassLogo" type="text" id="ClassLogo" value="<%=Session("ClassLogo")%>" size="40" maxlength="255"/></td>
</tr>
<tr>
<td height="25" align="right">栏目Banner:</td>
<td height="25"><input name="ClassBanner" type="text" id="ClassBanner" size="40" maxlength="255" value="<%=Session("ClassBanner")%>" /> </td>
</tr>
<tr>
<td height="25" align="right">排列顺序:</td>
<td height="25">
<input name="OrderID" type="text" id="OrderID" size="10" maxlength="4" value="<%=Session("OrderID")%>" />
(数字)
<span class="style1">*</span></td>
</tr>
<tr>
<td height="25" align="right">模板样式:</td>
<td height="25">
<input name="StyleID" type="text" id="StyleID" size="10" maxlength="4" value="<%=Session("StyleID")%>" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"/>
(数字)
<span class="style1">*</span></td>
</tr>
<tr>
<td height="25" align="right">CSS样式:</td>
<td height="25">
<input name="CssID" type="text" id="CssID" size="10" maxlength="4" value="<%=Session("CssID")%>" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"/>
(数字)
<span class="style1">*</span></td>
</tr>
<tr>
<td height="25" colspan="2" align="center">
<input type="submit" name="Submit" value="确认添加" />
<input name="Button" type="button" id="Button" value="返回列表" onclick="window.open('SystemClassList.asp','_self')"/></td>
</tr>
</form>
</table>
<!--#include file="bom.asp"-->
</body>
</html>
更多的网站栏目无限分类的代码请到论坛查看: http://BBS.TC711.COM
【 双击滚屏 】 【 评论 】 【 收藏 】 【 打印 】 【 关闭 】
来源:
互联网
日期:2008-7-5