www.gusucode.com > 艺术签名文章资讯网源代码 > 艺术签名文章资讯网源代码/624/adminhtry/admin_custom.asp
<!--#include file="setup.asp"--> <!--#include file="check.asp"--> <% Admin_header '===================================================================== ' 软件名称:新云网站管理系统 ' 当前版本:NewAsp Site Management System Version 3.0.0 ' 文件名称:admin_custom.asp ' 更新日期:2006-5-20 ' 官方网站:(www.newasp.net www.newasp.cn) QQ:94022511 '===================================================================== ' Copyright 2003-2007 newasp.net - All Rights Reserved. ' newasp is a trademark of newasp.net '===================================================================== Dim Action,isEdit,RsObj Dim mdbname, myConn Response.Write "<script language=JavaScript>" & vbCrLf Response.Write "function Juge(form1)" & vbCrLf Response.Write "{" & vbCrLf Response.Write " if (form1.LabelName.value == """")" & vbCrLf Response.Write " {" & vbCrLf Response.Write " alert(""标签名称不能为空!"");" & vbCrLf Response.Write " form1.LabelName.focus();" & vbCrLf Response.Write " return (false);" & vbCrLf Response.Write " }" & vbCrLf Response.Write " if (form1.Content.value == """")" & vbCrLf Response.Write " {" & vbCrLf Response.Write " alert(""标签内容不能为空!"");" & vbCrLf Response.Write " form1.Content.focus();" & vbCrLf Response.Write " return (false);" & vbCrLf Response.Write " }" & vbCrLf Response.Write "}" & vbCrLf Response.Write "</script>" & vbCrLf Response.Write "<table border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1"" class=""TableBorder"">" Response.Write " <tr>" Response.Write " <th colspan=""2"">自定义标签管理</th>" Response.Write " </tr>" Response.Write " <tr>" Response.Write " <td colspan=""2"" class=""TableRow1""><strong>注意:</strong><br>" Response.Write " ①在这里,您可以新建和修改自定义模板标签;<br>" Response.Write " ②添加标签时注意不能有相同的标签名称;标签名称不能包含特殊字符;<br>" Response.Write " ③注意标签格式:<span class=style2>{$NewaspLabel_标签名称}</span>。</td>" Response.Write " </tr>" Response.Write " <tr>" Response.Write " <td width=""10%"" nowrap class=""TableRow2"">管理选项:</td>" Response.Write " <td width=""90%"" class=""TableRow2"">" Response.Write "<a href='admin_custom.asp'>管理首页</a> | " Response.Write "<a href='?action=add' class='showlink'>添加自定义标签</a> | " Response.Write "<a href='admin_template.asp' class='showmenu'>模板样式总管理</a> | " Response.Write "<a href=admin_loadskin.asp>模板导出</a> | " Response.Write "<a href=admin_loadskin.asp?action=load>模板导入</a>" Response.Write "</td>" Response.Write " </tr>" Response.Write "</table>" Response.Write "<br>" Action = LCase(Request("action")) mdbname = Newasp.CheckStr(Request("mdbname")) If Not Newasp.CheckAdmin("CustomLabel") Then Server.Transfer ("showerr.asp") Response.End End If Select Case Trim(Action) Case "del" Call DelCustomLabel Case "save" Call SaveLabel Case "modify" Call ModifyLabel Case "add" isEdit = False Call EditCustomLabel Case "edit" isEdit = True Call EditCustomLabel Case "load" Call LoadCustomLabel Case "export" Call ExportCustomLabel Case Else Call showmain End Select If FoundErr = True Then ReturnError (ErrMsg) End If Admin_footer SaveLogInfo(AdminName) CloseConn Sub showmain() Dim i,tablestyle Dim maxperpage,CurrentPage,Pcount,totalrec,totalnumber maxperpage = 30 totalrec = 0 Pcount = 1 CurrentPage = Newasp.ChkNumeric(Request("page")) If CurrentPage = 0 Then CurrentPage = 1 %> <script src="include/showpage.js" type="text/javascript"></script> <table border="0" align="center" cellpadding="3" cellspacing="1" class="TableBorder"> <tr> <th width="5%" nowrap>频道ID</th> <th width="30%">自定义标签名称</th> <th width="45%">标签说明</th> <th width="20%">管理操作</th> </tr> <% SQL = "SELECT customid,ChannelID,LabelName,readme,estop,NotAllow FROM [NC_CustomLabel] ORDER BY customid DESC" Set Rs = Server.CreateObject("ADODB.Recordset") Rs.Open SQL,Conn,1,1 If Not (Rs.BOF And Rs.EOF) Then totalrec = Rs.RecordCount Pcount = CLng(totalrec / maxperpage) '得到总页数 If Pcount < totalrec / maxperpage Then Pcount = Pcount + 1 If CurrentPage < 1 Then CurrentPage = 1 If CurrentPage > Pcount Then CurrentPage = Pcount Rs.PageSize = maxperpage Rs.AbsolutePage = CurrentPage i = 0 Do While Not Rs.EOF And i < maxperpage If Not Response.IsClientConnected Then ResponseEnd If (i mod 2) = 0 Then tablestyle = "class='TableRow1'" Else tablestyle = "class='TableRow2'" End If %> <tr> <td <%=tablestyle%> align="center" nowrap><%=Rs("ChannelID")%></td> <td <%=tablestyle%>><input type="text" name="label" size="45" value="{$NewaspLabel_<%=Server.HTMLEncode(Trim(Rs("LabelName") & ""))%>}"></td> <td <%=tablestyle%>><%=Server.HTMLEncode(Rs("readme") & "")%></td> <td <%=tablestyle%> align="center" nowrap><a href="?action=edit&customid=<%=Rs("customid")%>">修改标签</a> | <% If Rs("NotAllow") > 0 Then %> <a href="?action=edit&customid=<%=Rs("customid")%>" onclick="{if(confirm('此标签不允许删除!但您可以对此标签进行修改。')){return true;}return false;}">删除标签</a> <% Else %> <a href="?action=del&customid=<%=Rs("customid")%>" onclick="{if(confirm('标签删除后将不能恢复,您确定要删除该标签吗?')){return true;}return false;}">删除标签</a> <% End If %> </td> </tr> <% Rs.movenext i = i + 1 If i >= maxperpage Then Exit Do Loop End If Rs.Close:Set Rs = Nothing %> <tr> <td colspan="4" align="right" class="TableRow2"><%ShowListPage CurrentPage,Pcount,totalrec,maxperpage,"","自定标签" %></td> </tr> <tr><form name="myform" method="post" action="?action=load"> <td colspan="4" align="center" class="TableRow1">自定义标签数据库路径:<input type="text" name="mdbname" size="40" value="<%=Newasp.InstallDir%>skin/NC_Skins.Mdb"> <input type="radio" name="stype" value="0" checked> 导出标签 <input type="radio" name="stype" value="1"> 导入标签 <input class="Button" type="submit" name="B2" value="执行下一步"> </td></form> </tr> </table> <% End Sub Sub EditCustomLabel() Dim EditTitle,customid If isEdit Then SQL = "SELECT * FROM NC_CustomLabel WHERE customid=" & CLng(Request("customid")) Set Rs = Newasp.Execute(SQL) customid = Rs("customid") EditTitle = "编辑自定义标签" Else EditTitle = "添加自定义标签" customid = 0 End If %> <div onkeydown="CtrlEnter()"> <table border="0" align="center" cellpadding="3" cellspacing="1" class="TableBorder"> <tr> <th colspan="4"><%=EditTitle%></th> </tr><form method="Post" name="myform" action="admin_custom.asp" onSubmit="return Juge(this)"> <% If isEdit Then Response.Write "<input type=""Hidden"" name=""action"" value=""modify"">" Response.Write "<input type=""Hidden"" name=""customid"" value="""& customid &""">" Else Response.Write "<input type=""Hidden"" name=""action"" value=""save"">" End If %> <tr> <td width="15%" align="right" nowrap class="TableRow1"><b>标签名称:</b></td> <td width="85%" class="TableRow1"><input name="LabelName" type="text" id="LabelName" size="55" value="<%If isEdit Then Response.Write Server.HTMLEncode(Rs("LabelName") & "")%>"></td> </tr> <tr> <td align="right" nowrap class="TableRow2"><b>标签说明:</b></td> <td class="TableRow2"><input name="readme" type="text" id="readme" size="70" value="<%If isEdit Then Response.Write Server.HTMLEncode(Rs("readme") & "")%>"></td> </tr> <tr> <td width="15%" align="right" nowrap class="TableRow1"><b>所属频道:</b></td> <td width="85%" class="TableRow1"><% Response.Write "<select name=""chanid"" id=""chanid"">" & vbNewLine Response.Write "<option value=""0"">不指定频道</option>" & vbNewLine Set RsObj = Newasp.Execute("SELECT ChannelID,ChannelName FROM NC_Channel WHERE ChannelType<2 ORDER BY orders") Do While Not RsObj.EOF Response.Write Chr(9) & Chr(9) & "<option value=""" & RsObj("ChannelID") & """" If isEdit Then If Rs("ChannelID") = RsObj("ChannelID") Then Response.Write " selected" End If Response.Write ">" Response.Write RsObj("ChannelName") Response.Write "</option>" & vbCrLf RsObj.movenext Loop Set RsObj = Nothing %></td> </tr> <tr> <td align="right" nowrap class="TableRow2"><b>标签内容:</b></td> <td class="TableRow2"><textarea name="Content" id="Content" wrap="OFF" rows="25" style="width:100%;"><%If isEdit Then Response.Write Server.HTMLEncode(Rs("Content") & "")%></textarea> <div align=right><a href="javascript:admin_Size(-10,'Content')"><img src="images/minus.gif" unselectable=on border=0></a> <a href="javascript:admin_Size(10,'Content')"><img src="images/plus.gif" unselectable=on border=0></div></td> </tr> <tr> <td align="right" nowrap class="TableRow1"><b>取消标签:</b></td> <td class="TableRow1"><input name="estop" type="checkbox" id="estop" value="1"<%If isEdit Then:If Rs("estop") <> 0 Then Response.Write (" checked")%>> </td> </tr> <tr> <td align="right" nowrap class="TableRow2"></td> <td class="TableRow2" align="center"><input type="button" name="Submit4" onclick="javascript:history.go(-1)" value="返回上一页" class="Button"> <input type="submit" name="btnSubmit" value="保存设置" class="Button"></td> </tr></form> </table> </div> <% End Sub Sub SaveLabel() Dim LabelName,chanid If Trim(Request.Form("LabelName")) = "" Then FoundErr = True ErrMsg = ErrMsg + "<li>请填写自定标签名称!</li>" Else LabelName = Trim(Request.Form("LabelName")) LabelName = Replace(Replace(LabelName, "'", ""), """", "") LabelName = Replace(Replace(LabelName, "{", ""), "}", "") LabelName = Replace(Replace(LabelName, "$", ""), "^", "") LabelName = Replace(Replace(LabelName, "<", ""), ">", "") End If If Trim(Request.Form("Content")) = "" Then FoundErr = True ErrMsg = ErrMsg + "<li>请填写自定标签内容!</li>" End If chanid = Newasp.ChkNumeric(Request.Form("chanid")) Set Rs = Newasp.Execute("SELECT LabelName FROM NC_CustomLabel WHERE ChannelID=" & chanid & " And LabelName='" & Trim(LabelName) & "'") If Not (Rs.BOF And Rs.EOF) Then FoundErr = True ErrMsg = ErrMsg + "<li>Sorry!此标签已经存在,请换一个标签名称再试!</li>" Set Rs = Nothing Exit Sub End If Set Rs = Nothing If Founderr = True Then Exit Sub Set Rs = Server.CreateObject("ADODB.Recordset") SQL = "SELECT * FROM NC_CustomLabel WHERE (customid is null)" Rs.Open SQL,Conn,1,3 Rs.Addnew Rs("ChannelID").Value = chanid Rs("LabelName").Value = Trim(LabelName) If Trim(Request.Form("LabelName")) = "" Then Rs("readme").Value = "自定义标签" Else Rs("readme").Value = Trim(Replace(Replace(Request.Form("readme"), "'", ""), """", "")) End If Rs("Content").Value = Request.Form("Content") Rs("estop").Value = Newasp.ChkNumeric(Request.Form("estop")) Rs("NotAllow").Value = 0 Rs.Update Rs.Close Set Rs = Nothing Succeed("<li>恭喜您!添加新的标签成功。</li>") End Sub Sub ModifyLabel() Dim customid,LabelName,chanid customid = Newasp.ChkNumeric(Request("customid")) If Trim(Request.Form("LabelName")) = "" Then FoundErr = True ErrMsg = ErrMsg + "<li>请填写自定标签名称!</li>" Else LabelName = Trim(Request.Form("LabelName")) LabelName = Replace(Replace(LabelName, "'", ""), """", "") LabelName = Replace(Replace(LabelName, "{", ""), "}", "") LabelName = Replace(Replace(LabelName, "$", ""), "^", "") LabelName = Replace(Replace(LabelName, "<", ""), ">", "") End If If Trim(Request.Form("Content")) = "" Then FoundErr = True ErrMsg = ErrMsg + "<li>请填写自定标签内容!</li>" End If If customid = 0 Then FoundErr = True ErrMsg = ErrMsg + "<li>错误的系统参数!</li>" End If chanid = Newasp.ChkNumeric(Request.Form("chanid")) Set Rs = Newasp.Execute("SELECT LabelName FROM NC_CustomLabel WHERE ChannelID=" & chanid & " And customid<>" & customid & " And LabelName='" & Trim(LabelName) & "'") If Not (Rs.BOF And Rs.EOF) Then FoundErr = True ErrMsg = ErrMsg + "<li>Sorry!此标签已经存在,请换一个标签名称再试!</li>" Set Rs = Nothing Exit Sub End If Set Rs = Nothing If Founderr = True Then Exit Sub Set Rs = Server.CreateObject("ADODB.Recordset") SQL = "SELECT * FROM NC_CustomLabel WHERE customid=" & CLng(customid) Rs.Open SQL,Conn,1,3 Rs("ChannelID").Value = chanid Rs("LabelName").Value = Trim(LabelName) If Trim(Request.Form("LabelName")) = "" Then Rs("readme").Value = "自定义标签" Else Rs("readme").Value = Trim(Replace(Replace(Request.Form("readme"), "'", ""), """", "")) End If Rs("Content").Value = Request.Form("Content") Rs("estop").Value = Newasp.ChkNumeric(Request.Form("estop")) Rs.Update Rs.Close Set Rs = Nothing Succeed("<li>恭喜您!修改标签成功。</li>") End Sub Sub DelCustomLabel() Dim cmd,customid customid = Newasp.ChkNumeric(Request("customid")) If Not IsObject(Conn) Then ConnectionDatabase Set cmd = Server.CreateObject("adodb.command") cmd.ActiveConnection = Conn cmd.CommandText = "DELETE FROM NC_CustomLabel WHERE NotAllow=0 And customid=" & CLng(customid) cmd.Execute Set cmd = Nothing Response.Redirect Request.ServerVariables("HTTP_REFERER") End Sub Sub LabelConnection() On Error Resume Next Set myConn = Server.CreateObject("ADODB.Connection") myConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(mdbname) If Err Then Err.Clear Set myConn = Nothing ErrMsg = ErrMsg + "<li>" & mdbname & "数据库不存在。" Founderr = True Exit Sub End If End Sub Sub LoadCustomLabel() Dim stype,tablestyle,i stype = Newasp.ChkNumeric(Request("stype")) LabelConnection If Founderr = True Then Exit Sub %> <table border="0" align="center" cellpadding="3" cellspacing="1" class="TableBorder"> <tr> <th width="5%" nowrap>选择</th> <th width="30%">自定义标签名称</th> <th width="65%">标签说明</th> </tr><form name="selform" method="post" action="?action=export"> <% SQL = "SELECT customid,ChannelID,LabelName,readme,estop,NotAllow FROM [NC_CustomLabel] ORDER BY customid DESC" Set Rs = Server.CreateObject("ADODB.Recordset") If stype = 0 Then Rs.Open SQL,Conn,1,1 Else Rs.Open SQL,myConn,1,1 End If If Not (Rs.BOF And Rs.EOF) Then i = 0 Do While Not Rs.EOF If Not Response.IsClientConnected Then ResponseEnd If (i mod 2) = 0 Then tablestyle = "class='TableRow1'" Else tablestyle = "class='TableRow2'" End If %> <tr> <td <%=tablestyle%> align="center" nowrap><input type="checkbox" name="customid" value="<%=Rs("customid")%>"></td> <td <%=tablestyle%>><input type="text" name="label" size="45" value="{$NewaspLabel_<%=Server.HTMLEncode(Trim(Rs("LabelName") & ""))%>}"></td> <td <%=tablestyle%>><%=Server.HTMLEncode(Rs("readme") & "")%></td> </tr> <% Rs.movenext i = i + 1 Loop End If Rs.Close:Set Rs = Nothing myConn.Close Set myConn = Nothing %> <tr> <td colspan="4" class="TableRow1"><input class="Button" type="button" name="chkall" value="全选" onClick="CheckAll(this.form)"><input class="Button" type="button" name="chksel" value="反选" onClick="ContraSel(this.form)"> <input type="hidden" name="mdbname" value="<%=mdbname%>"> <input type="hidden" name="stype" value="<%=stype%>"> <input type="radio" name="bestrow" value="1"> 覆盖同名标签 <input type="radio" name="bestrow" value="0" checked> 不覆盖(如果有同名标签,程序将跳过此标签) <input class="Button" type="submit" name="B2" value="开始执行-标签导入/导出" onclick="return confirm('您确定执行标签导入/导出操作吗?');"> </td></form> </tr> </table> <% End Sub Sub ExportCustomLabel() Dim stype,bestrow,i Dim CustomLabelField,CustomLabelValue Dim oRs,strSQL stype = Newasp.ChkNumeric(Request("stype")) bestrow = Newasp.ChkNumeric(Request("bestrow")) If Trim(Request("customid")) = "" Then ErrMsg = ErrMsg + "<li>请选择自定义标签名称。" Founderr = True End IF LabelConnection If Founderr = True Then Exit Sub SQL = "SELECT customid,ChannelID,LabelName,readme,content,estop,NotAllow FROM [NC_CustomLabel] WHERE customid in (" & Replace(Request("customid"), "'", "") & ")" Set Rs = Server.CreateObject("ADODB.Recordset") If stype = 0 Then Rs.Open SQL,Conn,1,1 Else Rs.Open SQL,myConn,1,1 End If If Not (Rs.BOF And Rs.EOF) Then i = 0 CustomLabelField = "ChannelID,LabelName,readme,content,estop,NotAllow" Do While Not Rs.EOF strSQL = "SELECT customid FROM [NC_CustomLabel] WHERE ChannelID="& Rs("ChannelID") &" And LabelName='"& Newasp.CheckStr(Rs("LabelName")) &"'" If stype = 0 Then Set oRs = myConn.Execute(strSQL) Else Set oRs = Conn.Execute(strSQL) End If If oRs.BOF And oRs.EOF Then CustomLabelValue = "" & Rs("ChannelID") & ",'"& Newasp.CheckStr(Rs("LabelName")) &"','"& Newasp.CheckStr(Rs("readme")) &"','"& Newasp.CheckStr(Rs("content")) &"',0,0" SQL = "INSERT INTO [NC_CustomLabel](" & CustomLabelField & ")VALUES(" & CustomLabelValue & ")" If stype = 0 Then myConn.Execute(SQL) Else Conn.Execute(SQL) End If Else If bestrow = 1 Then SQL = "UPDATE [NC_CustomLabel] SET readme='"& Newasp.CheckStr(Rs("readme")) &"',content='"& Newasp.CheckStr(Rs("content")) &"' WHERE customid=" & oRs("customid") If stype = 0 Then myConn.Execute(SQL) Else Conn.Execute(SQL) End If End If End If Set oRs = Nothing Rs.movenext i = i + 1 Loop End If Rs.Close:Set Rs = Nothing myConn.Close Set myConn = Nothing Response.Write "<script language=JavaScript>" & vbCrLf If stype = 0 Then Response.Write "alert('恭喜您 ^_^ 导出自定义标签成功!');" Else Response.Write "alert('恭喜您 ^_^ 导入自定义标签成功!');" End If Response.Write "location.replace('admin_custom.asp')" & vbCrLf Response.Write "</script>" & vbCrLf End Sub %>