<!--#include file="const.asp"-->
<%
Admin_header
'=====================================================================
' 软件名称：新云网站管理系统
' 当前版本：NewAsp Content Management System Version 4.0
' 文件名称：admin_ranked.asp
' 更新日期：2008-05-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="200" align="left">用户积分等级管理</td>
		<td class="tableline" width="*" align="right"><a href="admin_index.asp">管理首页</a>
			 - <a href="admin_ranked.asp?ChannelID=<%=ChannelID%>">等级管理</a>
			 - <a href="admin_setting.asp?ChannelID=<%=ChannelID%>">问吧设置</a>
			 - <a href="admin_list.asp?ChannelID=<%=ChannelID%>">问答列表</a>
			 - <a href="admin_lockip.asp?ChannelID=<%=ChannelID%>">IP限制管理</a>
			 - <a href="admin_badword.asp?ChannelID=<%=ChannelID%>">过滤字符管理</a>
		</td>
	</tr>
</table>
<%
Dim Action,DataArry
Action = LCase(Request("action"))
Select Case Trim(Action)
Case "save"
	Call saveRanked()
Case Else
	Call showmain()
End Select
If FoundErr=True Then
	ReturnError(ErrMsg)
End If
Admin_footer
SaveLogInfo(AdminName)
NewAsp.PageEnd
Ask_CloseConn

Sub showmain()
	Dim i,iCount,lCount
	iCount=2:lCount=1
%>
<form name="selform" id="selform" method="post" action="?ChannelID=<%=ChannelID%>">
<input type="hidden" name="action" value="save">
<table id="tablehovered" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
<tr>
	<th width="10%" noWrap="noWrap">等级ID</th>
	<th width="40%">用户等级头衔</th>
	<th width="15%" noWrap="noWrap">最少帖子数</th>
	<th width="15%" noWrap="noWrap">最多帖子数</th>
	<th width="20%" noWrap="noWrap">管理操作</th>
</tr>
<%
	Call showRankedList()
	iCount=1:lCount=2
	If IsArray(DataArry) Then
		For i=0 To Ubound(DataArry,2)
			If Not Response.IsClientConnected Then Response.End
			If (i mod 2) = 0 Then
				iCount=2:lCount=1
			Else
				iCount=1:lCount=2
			End If
%>
<tr align="center">
	<td class="tablerow<%=iCount%> hovered"><input type="hidden" name="RankID" value="<%=DataArry(0,i)%>"><%=DataArry(3,i)%></td>
	<td class="tablerow<%=iCount%> hovered"><input type="text" size="25" name="UserTitle" value="<%=Server.HTMLEncode(DataArry(2,i))%>" /></td>
	<td class="tablerow<%=iCount%> hovered"><input type="text" size="15" name="MinPoint" value="<%=Server.HTMLEncode(DataArry(5,i))%>" /></td>
	<td class="tablerow<%=iCount%> hovered"><input type="text" size="15" name="MaxPoint" value="<%=Server.HTMLEncode(DataArry(6,i))%>" /></td>
	<td class="tablerow<%=iCount%> hovered">管理</td>
</tr>
<%
		Next
	End If
	DataArry=Null
%>
<tr align="center">
	<td class="tablerow<%=lCount%>" colspan="5">
		<input class="button" type="submit" name="submit_button" value="保存设置"/>
	</td>
</tr>
</table>
</form>
<%
End Sub

Sub showRankedList()
	Dim Rs,SQL
	SQL="SELECT RankID,title,UserTitle,Ranked,Groups,MinPoint,MaxPoint,RankSetting FROM [NC_Ask_Ranked] WHERE Groups=0"
	Set Rs=NewAsp.Ask_Execute(SQL)
	If Not (Rs.BOF And Rs.EOF) Then
		DataArry=Rs.GetRows(-1)
	Else
		DataArry=Null
	End If
	Rs.close()
	Set Rs=Nothing
End Sub

Sub saveRanked()
	Server.ScriptTimeout=99999999
	Dim Rs,SQL,i
	Dim RankID,UserTitle,MinPoint,MaxPoint
	For i=1 To Request.Form("UserTitle").Count
		UserTitle=Replace(Request.Form("UserTitle")(i),"'","")
		MinPoint=NewAsp.CheckNumeric(Request.Form("MinPoint")(i))
		MaxPoint=NewAsp.CheckNumeric(Request.Form("MaxPoint")(i))
		RankID=NewAsp.CheckNumeric(Request.Form("RankID")(i))
		If RankID>0 Then
			NewAsp.Ask_Execute ("UPDATE NC_Ask_Ranked SET UserTitle='"&UserTitle&"',MinPoint="&MinPoint&",MaxPoint="&MaxPoint&" WHERE RankID="&RankID)
		End If
	Next
	Succeed("<li>恭喜您！保存用户积分等级成功。</li>")
End Sub
%>