<!--#include file="const.asp"-->
<%
Admin_header
'=====================================================================
' 软件名称：新云网站管理系统
' 当前版本：NewAsp Content Management System Version 4.0
' 文件名称：admin_setting.asp
' 更新日期：2008-06-16
' 官方网站：新云网络(www.NewAsp.net www.NewAsp.cn) QQ：94022511
'=====================================================================
' Copyright 2003-2008 NewAsp.net - All Rights Reserved.
' newasp is a trademark of NewAsp.net
'=====================================================================
%>
<table class="table1" cellspacing="1" cellpadding="3" align="center" border="0">
	<tr>
		<td class="tableline linetitle" width="80" align="left" noWrap="noWrap"><%=NewAsp.ModuleName%>列表</td>
		<td class="tableline" width="*" align="right"><a href="admin_index.asp?ChannelID=<%=ChannelID%>">管理首页</a>
			 - <a href="admin_post.asp?action=add&ChannelID=<%=ChannelID%>">添加<%=NewAsp.ModuleName%></a>
			 - <a href="../sys/admin_class.asp?ChannelID=<%=ChannelID%>">分类管理</a>
			 - <a href="admin_list.asp?ChannelID=<%=ChannelID%>&order=0">时间排序</a>
			 - <a href="admin_list.asp?ChannelID=<%=ChannelID%>&order=1">ID 排序</a>
			 - <a href="admin_list.asp?ChannelID=<%=ChannelID%>&showmode=1">专题列表</a>
			 - <a href="admin_list.asp?ChannelID=<%=ChannelID%>&isaccept=1">审核列表</a>
		</td>
	</tr>
</table>
<%
If Not ChkAdmin("BatSetting_"&ChannelID) Then
	Call Transfer_error()
End If

Dim Action,ArticleIDlist
Action=LCase(Request("action"))
Select Case Trim(Action)
Case "del"
	ArticleIDlist = NewAsp.CheckIDlist(Request("ArticleID"))
	Call batdel()
Case "audit"
	ArticleIDlist = NewAsp.CheckIDlist(Request("ArticleID"))
	Call BatAccept()
Case "batch"
	Call BatchProcessor()
Case "saveset"
	Call SaveSetting()
Case "savemove"
	Call SaveMove()
Case "move"
	ArticleIDlist = NewAsp.CheckIDlist(Request("ArticleID"))
	Call BatchMove()
Case Else
	ArticleIDlist = NewAsp.CheckIDlist(Request("ArticleID"))
	Call showmain()
End Select
If FoundErr=True Then
	ReturnError(ErrMsg)
End If
Admin_footer
SaveLogInfo(AdminName)
NewAsp.PageEnd

Sub showmain()
	Dim  RsObj,i
%>
<form name="myform" method="post" action="admin_setting.asp">
<input type="hidden" name="ChannelID" value="<%=ChannelID%>">
<input type="hidden" name="action" value="saveset">
<table border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
<tr>
	<th colspan="4"><%=NewAsp.ModuleName%>批量设置</th>
</tr>
<tr>
	<td class="tablerow1" width="20%" rowspan="19" valign="top" id="choosesort" style="display:none"><b>请选择<%=NewAsp.ModuleName%>分类</b><br/>
	<select name="classid" size="2" multiple style="height:420px;width:180px;">
	<%
	Call selectClasslist(ChannelID,-1)
	%><option value="-1">指定所有分类</option>
	</select>
	</td>
	<td class="tablerow1" colspan="2" align="right"><b>设置选择：</b></td>
	<td class="tablerow1">
	<input type="radio" name="choose" value="0" checked onClick="document.getElementById('choosesort').style.display='none';document.getElementById('chooseidlist').disabled=false;"> 按<%=NewAsp.ModuleName%>ID&nbsp;&nbsp;
	<input type="radio" name="choose" value="1" onClick="document.getElementById('choosesort').style.display='';document.getElementById('chooseidlist').disabled=true;"> 按<%=NewAsp.ModuleName%>分类</td>
</tr>
<tr>
	<td class="tablerow2" colspan="2" align="right"><b><%=NewAsp.ModuleName%>ID：</b>多个ID请用“,”分开</td>
	<td class="tablerow2"><input type="text" id="chooseidlist" name="ArticleID" size="70" value="<%=ArticleIDlist%>"></td>
</tr>
<tr>
	<td class="tablerow1" width="15%" align="right"><b>相关<%=NewAsp.ModuleName%>：</b></td>
	<td class="tablerow1" width="5%" align="center"><input type="checkbox" name="selRelated" value="1"></td>
	<td class="tablerow1" width="60%"><input name="Related" type="text" size="60"></td>
</tr>
<tr>
	<td class="tablerow2" align="right"><b><%=NewAsp.ModuleName%>作者：</b></td>
	<td class="tablerow2" align="center"><input type="checkbox" name="selAuthor" value="1"></td>
	<td class="tablerow2"><input name="Author" id="Author" type="text" size="20">
	<select name="font2" onChange="Author.value=this.value;">
		<option selected value="">选择作者</option>
	<%
	Dim m_arrAuthor
	m_arrAuthor = Split(Channel_Setting(0), ",")
	For i = 0 To UBound(m_arrAuthor)
		Response.Write " <option value=""" & m_arrAuthor(i) & """>" & m_arrAuthor(i) & "</option>"
	Next
	%>
	</select></td>
</tr>
<tr>
	<td class="tablerow1" align="right"><b><%=NewAsp.ModuleName%>来源：</b></td>
	<td class="tablerow1" align="center"><input type="checkbox" name="selComeFrom" value="1"></td>
	<td class="tablerow1"><input name="ComeFrom" id="ComeFrom" type="text" size="20">
	<select name="font2" onChange="ComeFrom.value=this.value;">
		<option selected value="">选择作者</option>
	<%
	Dim m_arrComeFrom
	m_arrComeFrom = Split(Channel_Setting(1), ",")
	For i = 0 To UBound(m_arrComeFrom)
		Response.Write " <option value=""" & m_arrComeFrom(i) & """>" & m_arrComeFrom(i) & "</option>"
	Next
	%>
	</select></td>
</tr>
<tr>
	<td class="tablerow2" align="right"><b>所需点数：</b></td>
	<td class="tablerow2" align="center"><input type="checkbox" name="selPointNum" value="1"></td>
	<td class="tablerow2"><input name="PointNum" type="text" size="10" value="0"/></td>
</tr>
<tr>
	<td class="tablerow1" align="right"><b>点 击 数：</b></td>
	<td class="tablerow1" align="center"><input type="checkbox" name="selAllHits" value="1"></td>
	<td class="tablerow1"><input name="AllHits" type="text" size="10" value="0"/></td>
</tr>
<tr>
	<td class="tablerow2" align="right"><b>用 户 组：</b></td>
	<td class="tablerow2" align="center"><input type="checkbox" name="selUserGroup" value="1"></td>
	<td class="tablerow2"><select name="UserGroup" size='1'>
	<%
	Set RsObj = NewAsp.Execute("SELECT GroupName,Grades FROM NC_UserGroup ORDER BY Groupid")
	Do While Not RsObj.EOF
		Response.Write "	<option value=""" & RsObj("Grades") & """"
		If RsObj("Grades") = 0 Then Response.Write " selected"
		Response.Write ">"
		Response.Write RsObj("GroupName")
		Response.Write "</option>" & vbCrLf
		RsObj.movenext
	Loop
	Set RsObj = Nothing
	%></select></td>
</tr>
<tr>
	<td class="tablerow1" align="right"><b>推荐星级：</b></td>
	<td class="tablerow1" align="center"><input type="checkbox" name="selstar" value="1"></td>
	<td class="tablerow1"><select name="star">
		<option value="5">★★★★★</option>
		<option value="4">★★★★</option>
		<option value="3" selected="selected">★★★</option>
		<option value="2">★★</option>
		<option value="1">★</option>
	</select></td>
</tr>
<tr>
	<td class="tablerow2" align="right"><b><%=NewAsp.ModuleName%>置顶：</b></td>
	<td class="tablerow2" align="center"><input type="checkbox" name="selTop" value="1"></td>
	<td class="tablerow2"><input type="radio" name="istop" value="0" checked> 否&nbsp;&nbsp;<input type="radio" name="istop" value="1"> 是</td>
</tr>
<tr>
	<td class="tablerow1" align="right"><b><%=NewAsp.ModuleName%>推荐：</b></td>
	<td class="tablerow1" align="center"><input type="checkbox" name="selBest" value="1"></td>
	<td class="tablerow1"><input type="radio" name="isbest" value="0" checked> 否&nbsp;&nbsp;<input type="radio" name="isbest" value="1"> 是</td>
</tr>
<tr>
	<td class="tablerow2" align="right"><b>禁止评论：</b></td>
	<td class="tablerow2" align="center"><input type="checkbox" name="selForbidEssay" value="1"></td>
	<td class="tablerow2"><input type="radio" name="ForbidEssay" value="0" checked> 否&nbsp;&nbsp;<input type="radio" name="ForbidEssay" value="1"> 是</td>
</tr>
<tr>
	<td class="tablerow1" align="right"><b>专题设置：</b></td>
	<td class="tablerow1" align="center"><input type="checkbox" name="selSpecial" value="1"></td>
	<td class="tablerow1"><select name="SpecialID"><option value="0">不指定<%=NewAsp.ModuleName%>专题</option>
	<%
	Set RsObj = NewAsp.Execute("SELECT SpecialID,SpecialName FROM NC_Special WHERE ChannelID="& ChannelID &" And ChangeLink=0 ORDER BY orders")
	Do While Not RsObj.EOF
		Response.Write Chr(9) & Chr(9) & "<option value=""" & RsObj("SpecialID") & """>"
		Response.Write RsObj("SpecialName")
		Response.Write "</option>" & vbCrLf
		RsObj.movenext
	Loop
	Set RsObj = Nothing
	%></select></td>
</tr>
<tr>
	<td class="tablerow2" colspan="4"><b>说明</b>：若要批量修改某个属性的值，请先选中其左侧的复选框，然后再设定属性值。</td>
</tr>
<tr>
	<td class="tablerow1" colspan="4" align="center"><input type="submit" name="submit_button" value="保存设置" class="button" onclick="return confirm('您确定执行批量设置吗?')"></td>
</tr>
</table>
</form>
<%
End Sub

Sub BatchMove()
	Dim Rs,channid
	channid=NewAsp.ChkNumeric(Request("channid"))
	If channid=0 Then channid=ChannelID
%>
<form name="myform" method="post" action="admin_setting.asp">
<input type="hidden" name="ChannelID" value="<%=ChannelID%>">
<input type="hidden" name="action" value="savemove">
<table border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
<tr>
	<th colspan="3"><%=NewAsp.ModuleName%>批量转移</th>
</tr>
<tr>
	<td class="tablerow1" colspan="3"><input type="radio" name="Appointed" value="0" checked> <b>指定<%=NewAsp.ModuleName%>ID：</b>
	<input type="text" id="chooseidlist" name="ArticleID" size="70" value="<%=ArticleIDlist%>">
	</td>
</tr>
<tr>
	<td class="tablerow2" width="45%"><input type="radio" name="Appointed" value="1"> <b>指定<%=NewAsp.ModuleName%>分类</b></td>
	<td class="tablerow2" width="10%"><b>选择频道</b></td>
	<td class="tablerow2" width="45%"><select name="channid" onchange="if(this.options[this.selectedIndex].value!=''){location='admin_setting.asp?action=move&channelid=<%=ChannelID%>&ArticleID=<%=ArticleIDlist%>&channid='+this.options[this.selectedIndex].value;}">
	<%
	Set Rs = NewAsp.Execute("SELECT ChannelID,ChannelName,ModuleName FROM NC_Channel WHERE ChannelType<2 And modules=1 And StopChannel=0 ORDER BY orders ASC")
	Do While Not Rs.EOF
		Response.Write Chr(9) & Chr(9) & "<option value=""" & Rs("ChannelID") & """"
		If Rs("ChannelID") = channid Then Response.Write " selected"
		Response.Write ">"
		Response.Write Rs("ChannelName")
		Response.Write "</option>" & vbCrLf
		Rs.movenext
	Loop
	Rs.Close
	Set Rs = Nothing
	%></select>
	</td>
</tr>
<tr>
	<td class="tablerow1"><select name="classid" size="2" multiple style="height:350px;width:260px;">
	<%
	Call selectClasslist(ChannelID,-1)
	%>
	</select></td>
	<td class="tablerow1" noWrap="noWrap">移动到→</td>
	<td class="tablerow1"><select name="tclassid" size="2" style="height:350px;width:260px;">
	<%
	Call selectClasslist(channid,-1)
	%>
	</select></td>
</tr>
<tr>
	<td class="tablerow2" colspan="3" align="center"><input type="submit" name="submit_button" value="保存设置" class="button"></td>
</tr>
</table>
</form>
<%
End Sub

Sub SaveMove()
	Dim Rs,SQL,channid
	channid=NewAsp.ChkNumeric(Request("channid"))
	If channid=0 Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>请选择正确的频道。</li>"
		Exit Sub
	End If
	If Trim(Request.Form("tclassid")) = "" Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>请选择目标分类。</li>"
		Exit Sub
	End If
	If Trim(Request.Form("tclassid")) = 0 Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>不能移动到外部分类。</li>"
		Exit Sub
	End If
	Set Rs = NewAsp.Execute("SELECT child FROM NC_Classify WHERE TurnLink=0 And classid="& NewAsp.ChkNumeric(Request.Form("tclassid")))
	If Rs.BOF And Rs.EOF Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>错误的系统参数！不能移动到外部分类。</li>"
		Set Rs = Nothing
		Exit Sub
	Else
		If Rs("child") > 0 Then
			FoundErr = True
			ErrMsg = ErrMsg + "<li>此分类还有子分类，请选择子分类再移动。</li>"
			Set Rs = Nothing
			Exit Sub
		End If
	End If
	Set Rs = Nothing
	If CInt(Request.Form("Appointed")) = 0 Then
		If Trim(Request.Form("ArticleID")) = "" Then
			FoundErr = True
			ErrMsg = ErrMsg + "<li>请选择ID。</li>"
			Exit Sub
		Else
			SQL = "UPDATE NC_Article SET ChannelID="&channid&",classid="& NewAsp.ChkNumeric(Request.Form("tClassID")) &" WHERE ArticleID in ("& Request("ArticleID") &")"
		End If
	Else
		If Trim(Request.Form("classid")) = "" Then
			FoundErr = True
			ErrMsg = ErrMsg + "<li>请选择分类。</li>"
			Exit Sub
		Else
			SQL = "UPDATE NC_Article SET ChannelID="&channid&",classid="& NewAsp.ChkNumeric(Request.Form("tClassID")) &" WHERE classid in ("& Request("classid") &")"
		End If
	End If
	NewAsp.Execute(SQL)
	Succeed("<li>恭喜您！批量移动完成。</li>")
End Sub

Sub SaveSetting()
	If Founderr = True Then Exit Sub
	Dim Rs,SQL
	Dim strTempValue
	strTempValue = ""
	If Trim(Request.Form("selSpecial")) <> "" Then strTempValue = strTempValue & "SpecialID="& CLng(Request.Form("SpecialID")) &","
	If Trim(Request.Form("selRelated")) <> "" Then strTempValue = strTempValue & "Related='"& NewAsp.Checkstr(Request.Form("Related")) &"',"
	If Trim(Request.Form("selAuthor")) <> "" Then strTempValue = strTempValue & "Author='"& NewAsp.Checkstr(Request.Form("Author")) &"',"
	If Trim(Request.Form("selComeFrom")) <> "" Then strTempValue = strTempValue & "ComeFrom='"& NewAsp.Checkstr(Request.Form("ComeFrom")) &"',"
	If Trim(Request.Form("selPointNum")) <> "" Then strTempValue = strTempValue & "PointNum="& CLng(Request.Form("PointNum")) &","
	If Trim(Request.Form("selAllHits")) <> "" Then strTempValue = strTempValue & "AllHits="& CLng(Request.Form("AllHits")) &","
	If Trim(Request.Form("selUserGroup")) <> "" Then strTempValue = strTempValue & "UserGroup="& CInt(Request.Form("UserGroup")) &","
	If Trim(Request.Form("selstar")) <> "" Then strTempValue = strTempValue & "star="& CInt(Request.Form("star")) &","
	If Trim(Request.Form("selTop")) <> "" Then strTempValue = strTempValue & "istop="& CInt(Request.Form("istop")) &","
	If Trim(Request.Form("selBest")) <> "" Then strTempValue = strTempValue & "isbest="& CInt(Request.Form("isbest")) &","
	If Trim(Request.Form("selForbidEssay")) <> "" Then strTempValue = strTempValue & "ForbidEssay="& CInt(Request.Form("ForbidEssay")) &","
	If Trim(strTempValue) = "" Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>请选择要设置的参数。</li>"
		Exit Sub
	Else
		strTempValue = Replace(Left(strTempValue,Len(strTempValue)-1), " ", "")
	End If
	If CInt(Request.Form("choose")) = 0 Then
		If Trim(Request.Form("ArticleID")) = "" Then
			FoundErr = True
			ErrMsg = ErrMsg + "<li>请选择" & NewAsp.ModuleName & "ID。</li>"
			Exit Sub
		Else
			SQL = "UPDATE NC_Article SET "& strTempValue &" WHERE isAccept>0 And ChannelID = "& ChannelID &" And ArticleID in ("& Request("ArticleID") &")"
		End If
	Else
		If Trim(Request.Form("ClassID")) = "" Then
			FoundErr = True
			ErrMsg = ErrMsg + "<li>请选择分类。</li>"
			Exit Sub
		ElseIf Trim(Request.Form("ClassID")) = "-1" Then
			SQL = "UPDATE NC_Article SET "& strTempValue &" WHERE isAccept>0 And ChannelID = "& ChannelID
		Else
			SQL = "UPDATE NC_Article SET "& strTempValue &" WHERE isAccept>0 And ChannelID = "& ChannelID &" And ClassID in ("& Request("ClassID") &")"
		End If
	End If
	NewAsp.Execute(SQL)
	Succeed("<li>恭喜您！批量设置完成。</li>")
End Sub

Sub BatchProcessor()
	ArticleIDlist = NewAsp.CheckIDlist(Request("ArticleID"))
	If Len(ArticleIDlist)>0 Then
		Select Case NewAsp.CheckStr(Trim(Request("act")))
			Case "批量删除":Call batdel
			Case "批量推荐":Call isCommend
			Case "取消推荐":Call noCommend
			Case "批量置顶":Call isTop
			Case "取消置顶":Call noTop
			Case "批量审核":Call BatAccept
			Case "取消审核":Call NotAccept
			Case "更新时间":Call upindate
			Case "生成HTML":Call BatCreateHtml
		End Select
	End If
End Sub

Sub batdel()
	Dim Rs
	Set Rs = NewAsp.Execute("SELECT ArticleID,classid,username,HtmlFileDate FROM NC_Article WHERE ChannelID="& ChannelID &" And ArticleID in (" & ArticleIDlist & ")")
	Do While Not Rs.EOF
		ClassUpdateCount Rs("classid"),0
		DeleteHtmlFile Rs("classid"),Rs("ArticleID"),Rs("HtmlFileDate")
		Rs.movenext
	Loop
	Rs.Close:Set Rs = Nothing
	NewAsp.Execute ("DELETE FROM NC_Article WHERE ArticleID in (" & ArticleIDlist & ")")
	NewAsp.Execute ("DELETE FROM NC_Comment WHERE ChannelID="& ChannelID &" And PostID in (" & ArticleIDlist & ")")
	Response.redirect (Request.ServerVariables("HTTP_REFERER"))
End Sub

Sub isCommend()
	NewAsp.Execute ("UPDATE NC_Article SET isBest=1 WHERE ArticleID in (" & ArticleIDlist & ")")
	Response.redirect (Request.ServerVariables("HTTP_REFERER"))
End Sub

Sub noCommend()
	NewAsp.Execute ("uPDATE NC_Article SET isBest=0 WHERE ArticleID in (" & ArticleIDlist & ")")
	Response.redirect (Request.ServerVariables("HTTP_REFERER"))
End Sub

Sub isTop()
	NewAsp.Execute ("UPDATE NC_Article SET isTop=1 WHERE ArticleID in (" & ArticleIDlist & ")")
	Response.redirect (Request.ServerVariables("HTTP_REFERER"))
End Sub

Sub noTop()
	NewAsp.Execute ("UPDATE NC_Article SET isTop=0 WHERE ArticleID in (" & ArticleIDlist & ")")
	Response.redirect (Request.ServerVariables("HTTP_REFERER"))
End Sub

Sub upindate()
	NewAsp.Execute ("UPDATE NC_Article SET WriteTime=" & NowString & " WHERE ArticleID in (" & ArticleIDlist & ")")
	Response.redirect (Request.ServerVariables("HTTP_REFERER"))
End Sub

Sub BatAccept()
	NewAsp.Execute ("UPDATE NC_Article SET isAccept=1 WHERE ArticleID in (" & ArticleIDlist & ")")
	Response.redirect (Request.ServerVariables("HTTP_REFERER"))
End Sub

Sub NotAccept()
	NewAsp.Execute ("UPDATE NC_Article SET isAccept=0 WHERE ArticleID in (" & ArticleIDlist & ")")
	Response.redirect (Request.ServerVariables("HTTP_REFERER"))
End Sub

Sub BatCreateHtml()
	Response.redirect ("admin_makehtml.asp?ChannelID="&ChannelID&"&ArticleID="&ArticleIDlist)
End Sub

Function ClassUpdateCount(sortid,stype)
	Dim rscount,Parentstr
	On Error Resume Next
	Set rscount = NewAsp.Execute("SELECT ClassID,Parentstr FROM [NC_Classify] WHERE ChannelID=" & ChannelID & " And ClassID=" & CLng(sortid))
	If Not (rscount.BOF And rscount.EOF) Then
		Parentstr = rscount("Parentstr") &","& rscount("ClassID")
		If CInt(stype) = 1 Then
			NewAsp.Execute ("UPDATE [NC_Classify] SET ShowCount=ShowCount+1,isUpdate=1 WHERE ChannelID="& ChannelID &" And ClassID in (" & Parentstr & ")")
		ElseIf stype = 2 Then
			NewAsp.Execute ("UPDATE [NC_Classify] SET isUpdate=1 WHERE ChannelID="& ChannelID &" And ClassID in (" & Parentstr & ")")
		Else
			NewAsp.Execute ("UPDATE [NC_Classify] SET ShowCount=ShowCount-1,isUpdate=1 WHERE ChannelID="& ChannelID &" And ClassID in (" & Parentstr & ")")
		End If
	End If
	Set rscount = Nothing
End Function
%>