📄 admin_custom.asp
字号:
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.Number = "-2147467259" Then
ErrMsg = ErrMsg + "<li>" & mdbname & "数据库不存在。"
Founderr = True
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
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -