<%@ LANGUAGE = VBScript.Encode %>
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312" />
<TITLE>邮件列表管理</TITLE>
<link rel="stylesheet" href="Images/Admin.css">
<script language=javascript src=../Include/mouse_on_title.js></script>
</HEAD>
<!--#include file="../Include/conn.asp" -->
<!--#include file="../Include/ConnDatabase.asp" -->
<%
'=====================================
'天天企业网站管理系统  TianTianCMS
'天天网络科技工作室版权所有
'官方客服中心 http://www.ip126.com
'微信公众号 ip126com
'QQ:530051328 mail:bbfhq@163.com
'=====================================
%>
<%if Instr(session("AdminPurview"),"|46,")=0 then
  response.write ("<br><br><div align=""center""><font style=""color:red; font-size:9pt; "")>您没有管理该模块的权限！</font></div>")
  response.end
end If%>
<BODY>
<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>
</head>
<BODY>
<BODY>

<%
dim action,pages,totaluser,allPages,page,CurrentPage,n
action=request("action")
if action="sendmail" then
call sendmail()
else
%>

<table class="tableborder" width="95%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr>
    <th>会员邮件列表</th>
  </tr>
</table>
<br>

<table class="tableborder" width="95%" border="0" align="center" cellpadding="3" cellspacing="1">
<form action=admin_Maillist.asp method=post name=email>
<%  
pages = 20
sql="select * from TianTianCMS_Members where email<>'' and maillist=1 order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if rs.eof and rs.bof then 
response.write "<tr><td colspan=4 align=center height=50>没有订阅邮件列表会员，未生成邮件列表</td></tr>"
response.end 
rs.close
set rs=nothing
end if

totaluser=RS.RecordCount
rs.pageSize = pages
allPages = rs.pageCount
page = Request("page")
If not isNumeric(page) then page=1
if isEmpty(page) or clng(page) < 1 then
page = 1
elseif clng(page) >= allPages then
page = allPages 
end if
				If totaluser Mod pages=0 Then  
					n= totaluser \ pages  
				Else
					n= totaluser \ pages+1  
				End If
rs.AbsolutePage = page

response.write "<tr><td align=center width='5%' class='forumrow'>选择</td><td width=30% align=center class='forumrow'>会员ID</td><td width=30% align=center class='forumrow'>会员姓名</td><td align=center class='forumrow'>会员Email</td></tr>"

Do While Not rs.eof and pages>0 
response.write "<tr><td height=25 bgcolor='#FAFAFA'><input type='checkbox' value='"&rs("eMail")&"' name=email></td><td bgcolor='#FAFAFA'>"&rs("MemName")&"</td><td bgcolor='#FAFAFA'>"&rs("RealName")&"</td><td bgcolor='#FAFAFA'>"&rs("email")&"</td></tr>"

pages = pages - 1
rs.movenext
if rs.eof then exit do
loop
%>

<tr><td colspan=4 bgcolor='#DADAE9'>
<input type='checkbox' name=chkall onclick='CheckAll(this.form)'>全选 
<input type=hidden name=action value=sendmail>
<input type=submit value="群发邮件">
</td></tr>
</form>
</table>

<%
call listPages()
end if

sub listPages() 
'分页
'if allpages<=1 then exit sub
response.write "<table class='tableborder' width='95%' border='0' align='center' cellpadding='3' cellspacing='1'><br>总记录数<font color=red>"&totaluser&"</font> &nbsp; 每页<font color=red>20</font>&nbsp; "
Response.Write "<font class='contents'> 页次：</font><font class='contents'>"&Page&"</font><font class='contents'>/"&n&"页</font> " 
if page = 1 then
response.write "<font color=darkgray>首页 前页</font>"
else
response.write "<a href=admin_Maillist.asp?keywords="&keywords&"&page=1>首页</a> <a href=admin_Maillist.asp?keywords="&keywords&"&page="&page-1&">前页</a>"
end if
if page = allpages then
response.write "<font color=darkgray> 下页 末页</font>"
else
response.write " <a href=admin_Maillist.asp?keywords="&keywords&"&page="&page+1&">下页</a> <a href=admin_Maillist.asp?keywords="&keywords&"&page="&allpages&">末页</a>"
end If
response.write "</table>"
end sub


sub sendmail()

email=request("email")
if email="" or isnull(email) then
response.write "<script language='javascript'>"
response.write "alert('出错了，您什么也没有选择！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if
email=replace(email,", ",";")
response.redirect "admin_Maillist_to.asp?"&email
end sub
%>

</body>
</html>
<%
conn.close
set conn=nothing
%>