<!--#include file=down_conn.asp-->
<!-- #include file="inc/const.asp" -->
<!-- #include file="down_function.asp" -->
<head>
<title>--管理页面</title>
<meta NAME=GENERATOR Content="Microsoft FrontPage 4.0" CHARSET=GB2312>
<base target="footer">
</head>
<BODY leftmargin="0" bottommargin="0" rightmargin="0" topmargin="0" marginheight="0" marginwidth="0">
<%
Dvbbs.LoadTemplates("")
Dvbbs.Head()
	dim admin_flag,MaxPerPage,title,currentPage,totalPut,idlist,isInteger
	admin_flag="22"
	if not Dvbbs.master or instr(session("flag"),admin_flag)=0 then
		response.write "<BR><li>本页面为管理员专用，请<a href=admin_login.asp target=_top>登陆</a>后进入。<br><li>您没有管理本页面的权限。"
		response.end
	else
   	MaxPerPage=eventnum
   	title=request("txtitle")
   	if not isempty(request("page")) then
      		currentPage=cint(request("page"))
   	else
      		currentPage=1
   	end if
    	if not isempty(request("delAnnounce")) then
     		idlist=request("delAnnounce")
     		if instr(idlist,",")>0 then
			dim idarr
			idArr=split(idlist)
			dim id
		for i = 0 to ubound(idarr)
	       		id=clng(idarr(i))
	       		if request("agree")="批准" then
	       		call agreeannounce(id)
	       		end if
	       		if request("noagree")="不批准" then
	       		call noagreeannounce(id)
	       		end if
		next
     		else
     		if request("agree")="批准" then
	       		call agreeannounce(clng(idlist))
	       		end if
				if request("noagree")="不批准" then
	       		call noagreeannounce(clng(idlist))
	       		end if
     		end if
  	end if 
   

%>

<div align="center"><center>

<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%">                                               
<form method=Post action="admin_down_payapplyuser.asp">
    <div align="center">
<%
	
	sql="select * from [user] where apply=2 order by id desc"
	Set rs= Server.CreateObject("ADODB.Recordset")
	rs.open sql,conndown,1,1

  	if rs.eof and rs.bof then
       		response.write "<p align='center'> 还 没 有 任 何 申 请 </p>"
   	else
      		totalPut=rs.recordcount
      		if currentpage<1 then
          		currentpage=1
      		end if
      		if (currentpage-1)*MaxPerPage>totalput then
	   		if (totalPut mod MaxPerPage)=0 then
	     			currentpage= totalPut \ MaxPerPage
	  		else
	      			currentpage= totalPut \ MaxPerPage + 1
	   		end if

      		end if
       		if currentPage=1 then
           		showpage totalput,MaxPerPage,"admin_down_payapplyuser.asp"
            		showContent
            		showpage totalput,MaxPerPage,"admin_down_payapplyuser.asp"
       		else
          		if (currentPage-1)*MaxPerPage<totalPut then
            			rs.move  (currentPage-1)*MaxPerPage
            			dim bookmark
            			bookmark=rs.bookmark
           			showpage totalput,MaxPerPage,"admin_down_payapplyuser.asp"
            			showContent
             			showpage totalput,MaxPerPage,"admin_down_payapplyuser.asp"
        		else
	        		currentPage=1
           			showpage totalput,MaxPerPage,"admin_down_payapplyuser.asp"
           			showContent
           			showpage totalput,MaxPerPage,"admin_down_payapplyuser.asp"
	      		end if
	   	end if
   	rs.close
   	end if
	        
   	sub showContent
   	dim i
       	   i=0
%>
      <div align="center"><center><table border="1" cellspacing="0" width="95%" bordercolorlight="#000000" bordercolordark="#FFFFFF" cellpadding="0">
        <tr>
          <th width="30%" align="center" height="20"><strong>用户名</strong></th>
          <th width="30%" align="center" height="20"><b>申请时间</b></th>
          <th width="40%" align="center" ><input type='submit' name="agree" class=buttonface value='批准'>&nbsp;                 
            <input type='submit' name="noagree" class=buttonface value='不批准'>全选：<input type=checkbox value="on" name="chkall" onclick="CheckAll(this.form)"></th> 
        </tr>
<%do while not rs.eof%>
        <tr>
          <td height="23" width="198" ><p align="center"><a href=DISPUSER.ASP?name=<%=rs("username")%> target=_blank><%=rs("username")%></a></td>
          <td height="23" width="159" >
            <p align="center"><%=rs("regtime")%></td>
          <td width="362" ><p align="center"><input type='checkbox' name='delAnnounce' value='<%=cstr(rs("ID"))%>'></td>
        </tr>
        
<%
	i=i+1
	      if i>=MaxPerPage then exit do
	      rs.movenext
	loop
%>
      </table>
      </center></div>
<%
   end sub 

function showpage(totalnumber,maxperpage,filename)
  dim n
  if totalnumber mod maxperpage=0 then
     n= totalnumber \ maxperpage
  else
     n= totalnumber \ maxperpage+1
  end if
  response.write "<p align='center'>&nbsp;"
  if CurrentPage<2 then
    response.write "<font color='#000080'>首页 上一页</font>&nbsp;"
  else
    response.write "<a href="&filename&"?page=1>首页</a>&nbsp;"
    response.write "<a href="&filename&"?page="&CurrentPage-1&">上一页</a>&nbsp;"
  end if
  if n-currentpage<1 then
    response.write "<font color='#000080'>下一页 尾页</font>"
  else
    response.write "<a href="&filename&"?page="&(CurrentPage+1)&">"
    response.write "下一页</a> <a href="&filename&"?page="&n&">尾页</a>"
  end if
   response.write "<font color='#000080'>&nbsp;页次：</font><strong><font color=red>"&CurrentPage&"</font><font color='#000080'>/"&n&"</strong>页</font> "
    response.write "<font color='#000080'>&nbsp;共<b>"&totalnumber&"</b>个事件 <b>"&maxperpage&"</b>个事件/页</font> "
       
end function

  sub noagreeannounce(id)
  dim rss,rs2,sql2,sql
  set rss=conndown.execute("select * from [user] where id="&cstr(id)&"")
   set rs2=server.createobject("adodb.recordset")      
sql2="select * from [dv_message]"      
rs2.open sql2,conn,1,3      
rs2.addnew      
rs2("sender")=forum_info(0)&"下载中心"      
rs2("incept")=rss("username")     
rs2("title")="您的付费下载用户申请没有得到批准！"      
rs2("content")="您的付费下载用户申请没有得到批准！请与管理员联系！"      
rs2("flag")=0      
rs2("issend")=1      
rs2.update      
rs2.close   
rss.close
    set rs=server.createobject("adodb.recordset")
    sql="delete from [user] where id="&cstr(id)
    conndown.execute sql
    if err.Number<>0 then
	err.clear
	response.write "拒 绝 失 败 !<br>"
    else
        response.write " 拒 绝 成 功！<br>"
    end if
  End sub
  
  
  sub agreeannounce(id)
      dim rsl,user,uid,sql,rs1,rs2,rs3,sql1,sql2 
      set rsl=conndown.execute("select * from [user] where id="&cstr(id)&"")
      user=rsl("username")
	uid=rsl("id")
	
      set rs=server.createobject("adodb.recordset")
    sql="update [user] set apply=1,regtime=date() where id="&cstr(id)
    conndown.execute sql
    if err.Number<>0 then
	err.clear
	response.write "批 准 失 败 !<br>"
    else
        response.write "批 准 成 功！<br>"
    end if
set rs1=server.createobject("adodb.recordset")
sql1="select * from events"
rs1.open sql1,conndown,1,3
mess=""&membername&"批准添加了付费用户“"&user&"”"	
rs1.addnew
rs1("event")=mess
rs1("addtime")=date()
rs1.update
rs1.close
set rs2=server.createobject("adodb.recordset")      
sql2="select * from [dv_message]"      
rs2.open sql2,conn,1,3      
rs2.addnew      
rs2("sender")=forum_info(0)&"下载中心"      
rs2("incept")=user     
rs2("title")="您的付费下载用户申请已经得到批准！"      
rs2("content")="您的付费下载用户申请已经得到批准！您现在已经是正式的付费用户了！"      
rs2("flag")=0      
rs2("issend")=1      
rs2.update      
rs2.close
set rs3=server.createobject("adodb.recordset")
sql1="select * from [userevent]"
rs3.open sql1,conndown,1,3
rs3.addnew
rs3("userid")=uid
rs3("userevent")="您的付费下载用户申请已经得到批准！"
rs3("addtime")=date()
rs3("conuser")=membername
rs3.update
rs3.close  	
	
  End sub
  

%>
    </div></td>
  </tr>
</table></form>
</center></div>
</body>
<%end if%>

<script language="javascript">
<!--
function CheckAll(form)  {
  for (var i=0;i<form.elements.length;i++)    {
    var e = form.elements[i];
    if (e.name != 'chkall')       e.checked = form.chkall.checked; 
   }
  }
//-->
</script>
