
<!--#include file="./Conn_Mail.asp"-->
<!--#include file="inc/Check.asp"-->
<!--#include file="inc/public.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>ELIGHT.CC</title>
</head>
<link href="Images/Admin.css" rel="stylesheet" type="text/css">
<body>
<%
dim makking,lx
Dim objfso,objFile,data
    makking      = request.QueryString("makking")
	LineID		 = Request("LineID")

if makking="save" then
		dim GroupID,Groupname,Picture,Ending
				Filename  = trim(Request("Filename")) 
				GroupID   = int(Request("GroupID"))
				Groupname = trim(Request("Groupname")) 
				Picture   = trim(Request("Picture")) 
				Ending    = Request("Ending")
				T		  = Int(Request("T"))
				IF T = "" or Not IsNumeric(T) Then T = 10
			
						 '------------------------------------------------------
						 '添加新的组
						IF GroupID  =0 then
						
								if Groupname="" then
								
								Save_Title = "·请选择组"
								Call Save_err
								
								end if
						
							sql="insert into Mail_Group (Groupname,Picture,Datetime) values ('"&Groupname&"','"&Picture&"','"&now&"')" 
							conn_m.execute(sql)
						
							sql="select top 1 GroupID from Mail_Group order by GroupID desc" 
							set rs=server.createobject("adodb.recordset") 
							rs.open sql,conn_m,1,1
							GroupID   = rs("GroupID")
							rs.close
							set rs=nothing
						end if
	
	    '--------------------------------------------------------------------------------
		x = 0
			Set objfso=Server.Createobject("scripting.filesystemobject")
			Set objFile=objfso.openTextFile(Server.mappath("./Email/") & "\"&Filename&"")
				
						IF LineID <> "" and IsNumeric(LineID) Then

							For i = 1 to LineID
									objFile.ReadLine
							Next
							
						End IF
						
					do while not objFile.atEndOfStream
						
						data = objFile.ReadLine
												
						Mail=trim(data)
						'--------------------------------------------------------------
							if Mail<>"" then
								'是否存在
								'=====================================================
										MailStr 	= False
									IF Instr(Mail,"@")= False or Instr(Mail,".")= False or Len(Mail)<8 Then
										MailStr = True
									End IF
									
										'============================================
										Set Rs = Conn_m.Execute("Select ID From Leach_Mail where Mail='"& Mail &"'")
											IF Not(Rs.EOF and Rs.BOF) Then
											MailStr = True
											End if 
											Rs.Close
										Set Rs = Nothing
												'================================================
												Comprise_MailStr = False
												Set Rs = Conn_m.Execute("Select Mail From Comprise_Mail")
													IF Not(Rs.EOF and Rs.BOF) Then
														While Not Rs.Eof
														IF InStr(Ucase(Mail),""& Ucase(Trim(Rs("Mail"))) &"")>0 Then
														Comprise_MailStr = True
														End IF
														Rs.MoveNext
														Wend
															IF Comprise_MailStr = True Then
															MailStr = True
															End iF
													End IF
													Rs.Close
												Set Rs = Nothing
					
										IF 	MailStr = False Then
										
											Set Rs = Conn_m.Execute("Select Count(ID) AS MailCount From Mail Where Mail='"& Mail &"'")
											
											IF Rs("MailCount")=0 Then
											
												    Conn_m.Execute("Insert into Mail (Mail,Ending,GroupID) Values ('"& Mail &"',"& Ending &","& GroupID &")")
											
													Mail_OK = Mail_OK &"<br>"& Mail
											
										    End IF
											
												Rs.Close
											Set Rs = Nothing
											
										End IF
									
									x = x + 1					
									IF x = T Then
									LineID = objFile.Line-1
									
										Response.Write("<table width=100%  border=0 align=center cellpadding=10 cellspacing=0>")
										Response.Write("<tr><td>")
										Response.Write("正在读取到第"& LineID &"行<br>")
										Response.Write("读取到以下有效邮件地址：")
										Response.write(Mail_OK)
										Response.Write("<meta http-equiv=""refresh"" content=""2;url=TxtAdd.asp?makking=save&Filetype=1&LineID="& LineID &"&GroupID="& GroupID &"&Filename="& Filename &"&Ending="& Ending &"&T="& T &""">")
										Response.Write("</tr></td>")
										Response.Write("</table>")
										Response.End()
								
									End IF
									
								End IF
					Loop
			Set objFile=nothing
			Set fso=nothing
			
			Save_BackUrl  = "Txtadd.asp"
			Save_BackName = "设置页"
			Save_Title = "·完成"
			Call Save_ok

end if
%>
<table width="98%" height="40"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="100%"  border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#D8D8D8">
      <tr>
        <td height="30" align="left" bgcolor="ffffff"><table width="100%" height="100%"  border="0" cellpadding="3" cellspacing="0">
            <tr bgcolor="eeeeee">
                <td width="5%" align="center"><img src="Images/1.gif" width="13" height="12"></td>
                <td width="85%"><span City="style2">管理中心 &gt;&gt;&gt; 添加邮件地址</span></td>
                <td width="10%" align="right">&nbsp;</td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
<table width="98%" height="90%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#D8D8D8">
  <tr>
    <td valign="top" bgcolor="ffffff"><table width="100%"  border="0" cellpadding="3" cellspacing="1" bgcolor="eeeeee">
        <form name="form1" method="post" action="Txtadd.asp?makking=save">
          <tr bgcolor="ffffff"> 
            <td width="29%" height="25" align="right">来源文件名：</td>
            <td width="71%" height="25"> <select name="Filename" class="all_box1">
                <%
			Dim oFSO, oUploadFolder, oUploadFiles, oUploadFile, sFileName
			Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
			Set oUploadFolder = oFSO.GetFolder(Server.MapPath("Email\"))
			Set oUploadFiles = oUploadFolder.Files
			For Each oUploadFile In oUploadFiles
			sFileName = oUploadFile.Name
%>
                <option value="<%=sFileName%>"><%=sFileName%></option>
                <%
			Next
			Set oUploadFolder = Nothing
			Set oUploadFiles = Nothing
%>
              </select> </td>
          </tr>
          <tr bgcolor="ffffff"> 
            <td height="25" align="right">所属组ID：</td>
            <td height="25"> <select name="GroupID" class="all_box1">
                <option value="0">新建组</option>
                <%

			sql="select * from Mail_Group order by datetime desc" 
			set rs=server.createobject("adodb.recordset") 
			rs.open sql,conn_m,1,1
			if not(rs.bof and rs.eof) then
			do while not rs.eof
%>
                <option value="<%=rs("GroupID")%>"><%=rs("Groupname")%></option>
                <%
			rs.movenext
			loop
			end if
			rs.close
			set rs=nothing
			
Conn_m.Close
Set Conn_m = Nothing
%>
              </select> </td>
          </tr>
          <tr bgcolor="ffffff"> 
            <td height="25" align="right"> 新建组名称：</td>
            <td height="25"> <input name="Groupname" type="text" class="all_box1">	
            </td>
          </tr>
          <tr bgcolor="ffffff"> 
            <td height="25" align="right">新建组描述：</td>
            <td height="25"> <input name="Picture" type="text" class="all_box1" size="45">	
            </td>
          </tr>
          <tr bgcolor="ffffff"> 
            <td height="12" align="right">导入状态：</td>
            <td height="12"> <select name="Ending" class="all_box1">
                <option value="0">未发送</option>
                <option value="1">发送成功</option>
                <option value="2">发送失败</option>
              </select> </td>
          </tr>
          <tr bgcolor="ffffff">
            <td height="12" align="right">每次读取条数：</td>
            <td height="12"><input name="T" type="text" id="T" value="50" size="3" maxlength="2">
              条</td>
          </tr>
          <tr align="center" bgcolor="ffffff"> 
            <td height="40" colspan="2"> <input name="Submit" type="submit" class="all_box" value="提交"> 
              &nbsp; <input name="Submit2" type="reset" class="all_box" value="重置"></td>
          </tr>
        </form>
      </table>      </td>
  </tr>
</table>
<table width="98%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="6"></td>
  </tr>
</table>
</body>
</html>
