<!--#include file="setup.asp"-->
<!--#include file="check.asp"-->
<%
Admin_header
'=====================================================================
' 软件名称：新云网站管理系统(华西网域风格）(华西网域风格）
' 当前版本：NewCloud Site Management System Version 2.1.0
' 文件名称：admin_classad.asp
' 更新日期：2006-5-20
' 官方网站：(www.newasp.net www.newasp.cn)   QQ：94022511
'=====================================================================
' Copyright 2002-2005 newasp.net - All Rights Reserved.
' newasp is a trademark of newasp.net
'=====================================================================
Dim Action
ChannelID = Newasp.ChkNumeric(Request("ChannelID"))
If ChannelID < 1 Then ChannelID = 1

Action = LCase(Request("action"))
If Not Newasp.CheckAdmin("Classad") Then
	Server.Transfer ("showerr.asp")
	Response.End
End If

Select Case Trim(Action)
Case "save"
	Call saveClassad
Case Else
	Call showmain
End Select
If FoundErr = True Then
	ReturnError (ErrMsg)
End If
Admin_footer
'SaveLogInfo(AdminName)
CloseConn

Sub showmain()
	Dim ArrarAdsCode,AdsCode,stopad,sortid
	sortid = Newasp.ChkNumeric(Request("sortid"))
	stopad = 0
	AdsCode = ""
	If sortid > 0 Then
		Set Rs = Newasp.Execute("SELECT classid,AdsCode,stopad FROM NC_Classify WHERE ChannelID=" & ChannelID & " And classid=" & sortid)
		If Not(Rs.BOF And Rs.EOF) Then
			stopad = Rs("stopad")
			AdsCode = Rs("AdsCode")
		End If
		Set Rs = Nothing
	Else
		Set Rs = Newasp.Execute("SELECT classid,AdsCode,stopad FROM NC_Classify WHERE ChannelID=" & ChannelID & " ORDER BY classid")
		If Not(Rs.BOF And Rs.EOF) Then
			stopad = Rs("stopad")
			AdsCode = Rs("AdsCode")
		End If
		Set Rs = Nothing
	End If
	ArrarAdsCode = Split(AdsCode & "|||||||||||||||", "|||")
	'Newasp.Execute ("UPDATE NC_SoftList SET PauseDown = 0")
%>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="TableBorder">
<tr>
	<th>分类广告管理</th>
</tr>
<tr>
	<td class="TableRow1"><b>说明：</b><br>①本广告管理只能用于分类列表和信息页面，其它页面此广告代码无效；<br>②请将广告标签复制到模板中相应的位置，在此你可以为不同的分类投放不同的广告</td>
</tr>
<form name="myform" method="post" action="">
<tr>
	<td class="TableRow2">查看分类广告设置，请选择左边下拉框相应分类 
<%
	Dim srtClassMenu
	Response.Write "<input type=hidden name=ChannelID value='" & ChannelID & "'>"
	Response.Write "<select onchange=""if(this.options[this.selectedIndex].value!=''){location=this.options[this.selectedIndex].value;}"">" & vbCrLf
	Response.Write "<option value='admin_classad.asp?ChannelID=" & ChannelID & "'>≡全部" & sModuleName & "列表≡</option>" & vbCrLf
	srtClassMenu = Newasp.ClassJumpMenu(ChannelID)
	srtClassMenu = Replace(srtClassMenu, "{ClassID=" & Request("sortid") & "}", "selected")
	Response.Write srtClassMenu
	Response.Write "</select>"
%>
	</td>
</tr>
</form>
</table>
<br>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="TableBorder">
<tr>
<form name="myform" method="post" action="?action=save">
<input type="hidden" name="ChannelID" value="<%=ChannelID%>">
	<td class="TableRow2" valign="top" width="20%" rowspan="11"><font color="blue">保存广告选项，请按 CTRL 键多选</font><br>
<%
	Response.Write "<select name=""ClassID"" size='2' multiple style='height:620px;width:180px;'>"
	Dim strSelectClass,re
	strSelectClass = Newasp.LoadSelectClass(ChannelID)
	Set re = New RegExp
        re.IgnoreCase = True
        re.Global = True
	Re.Pattern="(value=)(.*)("" )"
	strSelectClass = Re.Replace(strSelectClass,"")
	Re.Pattern="({ClassID=)(.*)(}>)"
	strSelectClass = Re.Replace(strSelectClass,"value=""$2"">")
	strSelectClass = Replace(strSelectClass, "value=""" & Request("sortid") & """", "value=""" & Request("sortid") & """ selected")
	Response.Write strSelectClass
	Set Re = Nothing
	'Response.Write "<option value=""-1"">指定所有分类</option>"
	Response.Write "</select>"
%>
	</td>
	<td height="20" class="TableRow2" width="80%"><input type="checkbox" name="allbox" value="yes"> &nbsp;保存到所有分类&nbsp;&nbsp;
	<input type="radio" name="stopad" value="0"<%
	If stopad = 0 Then Response.Write " checked"
%>> 打开广告
	<input type="radio" name="stopad" value="1"<%
	If stopad > 0 Then Response.Write " checked"
%>> 关闭广告</td>
</tr>
<tr>
	<td class="TableRow2"><b>广告代码一、</b> 广告标签一： {$AdsCode1}</td>
</tr>
<tr>
	<td class="TableRow1"><textarea name="AdsCode1" rows="5" cols="70"><%=Server.HTMLEncode(ArrarAdsCode(0))%></textarea>
	  <a href="javascript:admin_Size(-10,'AdsCode1')"><img src="images/minus.gif" unselectable=on border=0></a> 
	  <a href="javascript:admin_Size(10,'AdsCode1')"><img src="images/plus.gif" unselectable="on" border="0"></td>
</tr>
<tr>
	<td class="TableRow2"><b>广告代码二、</b> 广告标签二： {$AdsCode2}</td>
</tr>
<tr>
	<td class="TableRow1"><textarea name="AdsCode2" rows="5" cols="70"><%=Server.HTMLEncode(ArrarAdsCode(1))%></textarea>
	  <a href="javascript:admin_Size(-10,'AdsCode2')"><img src="images/minus.gif" unselectable="on" border="0"></a> 
	  <a href="javascript:admin_Size(10,'AdsCode2')"><img src="images/plus.gif" unselectable="on" border="0"></td>
</tr>
<tr>
	<td class="TableRow2"><b>广告代码三、</b> 广告标签三： {$AdsCode3}</td>
</tr>
<tr>
	<td class="TableRow1"><textarea name="AdsCode3" rows="5" cols="70"><%=Server.HTMLEncode(ArrarAdsCode(2))%></textarea>
	  <a href="javascript:admin_Size(-10,'AdsCode3')"><img src="images/minus.gif" unselectable="on" border="0"></a> 
	  <a href="javascript:admin_Size(10,'AdsCode3')"><img src="images/plus.gif" unselectable="on" border="0"></td>
</tr>
<tr>
	<td class="TableRow2"><b>广告代码四、</b> 广告标签四： {$AdsCode4}</td>
</tr>
<tr>
	<td class="TableRow1"><textarea name="AdsCode4" rows="5" cols="70"><%=Server.HTMLEncode(ArrarAdsCode(3))%></textarea>
	  <a href="javascript:admin_Size(-10,'AdsCode4')"><img src="images/minus.gif" unselectable="on" border="0"></a> 
	  <a href="javascript:admin_Size(10,'AdsCode4')"><img src="images/plus.gif" unselectable="on" border="0"></td>
</tr>
<tr>
	<td class="TableRow2"><b>广告代码五、</b> 广告标签五： {$AdsCode5}</td>
</tr>
<tr>
	<td class="TableRow1"><textarea name="AdsCode5" rows="5" cols="70"><%=Server.HTMLEncode(ArrarAdsCode(4))%></textarea>
	  <a href="javascript:admin_Size(-10,'AdsCode5')"><img src="images/minus.gif" unselectable="on" border="0"></a> 
	  <a href="javascript:admin_Size(10,'AdsCode5')"><img src="images/plus.gif" unselectable="on" border="0"></td>
</tr>
<tr>
	<td class="TableRow1" align="center" colspan="2"><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>

<%
End Sub

Sub saveClassad()
	Dim strAdsCode
	strAdsCode = Replace(Request.Form("AdsCode1"), "|||", "") & "|||"
	strAdsCode = strAdsCode & Replace(Request.Form("AdsCode2"), "|||", "") & "|||"
	strAdsCode = strAdsCode & Replace(Request.Form("AdsCode3"), "|||", "") & "|||"
	strAdsCode = strAdsCode & Replace(Request.Form("AdsCode4"), "|||", "") & "|||"
	strAdsCode = strAdsCode & Replace(Request.Form("AdsCode5"), "|||", "") & "|||"
	strAdsCode = Newasp.CheckStr(strAdsCode)
	'Response.Write strAdsCode
	If Request("allbox") = "yes" Then
		Newasp.Execute ("UPDATE NC_Classify SET AdsCode='" & strAdsCode & "',stopad=" & CInt(Newasp.ChkNumeric(Request.Form("stopad"))) & " WHERE ChannelID= " & ChannelID)
	Else
		If Request.Form("classid") = "" Then
			FoundErr = True
			ErrMsg = ErrMsg + "<li>请选择要保存的分类</li>"
			Exit Sub
		Else
			Newasp.Execute ("UPDATE NC_Classify SET AdsCode='" & strAdsCode & "',stopad=" & CInt(Newasp.ChkNumeric(Request.Form("stopad"))) & " WHERE classid in (" & Request.Form("classid") & ") And ChannelID= " & ChannelID)
		End If
	End If
	Succeed("<li>恭喜您！保存广告代码成功。</li>")
End Sub

%>