<%' THIS FILE ALLOWS ACCESS TO ALL SPAM EMAILS IN THE DATABASE TO ANY USER WHO IS AUTHENTICATED. USE ONLY IF YOU REQUIRE THIS FUNCTIONALITY %>
<%Response.Buffer=false%>
<!--#include file="authenticate.asp"-->
<%
'****** Revision  6-11-03 ******
    if Request.QueryString("Quit") = 1 then Session("EmailTo") = ""
    if Request.QueryString("SelAll") <> "" then SelAll = true
	EmailTo = Session("EmailTo")

	'Theoretically, this should never happen.
	If Len(EmailTo) < 1 Then
		Session("EmailTo") = Null
		Session.Abandon
		Response.Redirect Request.ServerVariables("SCRIPT_NAME")
	End If
%>
<html>
<head>
	<title>Spam Filter - Suspected Spam List</title>
</head>
<body>
<%
	if Request.QueryString("NewEmail") = "1" then Session("EmailFilter") = ""
	if Request.QueryString("EmailFilter") <> "" then Session("EmailFilter") = Request.QueryString("EmailFilter")
	if Session("EmailFilter") <> "" then
		ShowSpamList
	else
		ShowFilterForm
	end if
	
Sub ShowFilterForm
%>
    <form method="GET" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
	<table align="lef" border="1" cellpadding="1" cellspacing="0">
		<tr><td align="center" colspan="2"><h2>Enter recipient email address to search</h2></td></tr>
		<tr>
			<td align="right">Email Address:</td>
			<td><input type="text" size="25" name="EmailFilter"></td>
		</tr>
		<tr>
			<td align="left" colspan="2">Tip - enter a trailing <b>%</b> for a wildcard search, ex <b>john%</b></td>
		</tr>
		<tr>
			<td align="center" colspan="2">
				<input type="submit" value="Search">&nbsp;&nbsp;
			</td>
		</tr>
		<tr><td align="center" colspan="2"><a href="Register.asp">Register</a> -
          <a href="register.asp?Forgot=1">Forgot my password</a></td></tr>
	</table>
<%	
End Sub
'ShowFilterForm

Sub ShowSpamList
	'Determine if a sort order was chosen.
	order_by = Trim(Request.QueryString("SortBy"))

	Select Case order_by
		Case "Subject"
			order_by = "Subject, MsgDate, EmailFrom"
		Case "EmailFrom"
			order_by = "EmailFrom, MsgDate, Subject"
		Case Else
			order_by = "MsgDate, EmailFrom, Subject"
	End Select

	'Generate query.
	SQL = "SELECT QuarID, EmailFrom, Subject, MsgDate, MsgID, RejectDesc, RejectDetails "
	SQL = SQL & "FROM tblQuarantine, tblRejectCodes "
	SQL = SQL & "WHERE "
	if Right(Session("EmailFilter"), 1) = "%" then
	 	SQL = SQL & "EmailTo LIKE '" & Session("EmailFilter") & "' AND "
	else
		SQL = SQL & "EmailTo = '" & Session("EmailFilter") & "' AND "
	end if
	SQL = SQL & "(Deliver = 0) "
	SQL = SQL & "AND (Expire = 0) "
	SQL = SQL & "AND (tblQuarantine.RejectID = tblRejectCodes.RejectID) "
	SQL = SQL & "ORDER BY " & order_by
	Set rs = con.Execute(SQL)
%>
	<table border="0" style="border-collapse: collapse" width="100%" id="table1">
      <tr>
        <td>
        <form method="GET" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
          <p><input type="submit" value="Refresh List" name="RefreshList"></p>
          <input type="hidden" name="EmailAddress" value="<%=RequestCollection("EmailAddress")%>">
          <input type="hidden" name="Password" value="<%=RequestCollection("Password")%>">
        </form>
        </td>
        <td width="100%">
	<h2 align="center">Spam List for <%=Server.HTMLEncode(Session("EmailFilter"))%></h2></td>
      </tr>
</table>
	<form action="ResolveSpam.asp" method="post">
	<table border="1" cellpadding="2" cellspacing="0" width="100%">
	<thead align="center" valign="bottom">
		<tr>
			<th scope="col" bgcolor="silver">&nbsp;</th>
			<th scope="col" bgcolor="silver"><a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?SortBy=EmailFrom">From</a></th>
			<th scope="col" bgcolor="silver"><a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?SortBy=Subject">Subject</a></th>
			<th scope="col" bgcolor="silver"><a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?SortBy=MsgDate">Date</a></th>
			<th scope="col" bgcolor="silver">Rejection</th>
		</tr>
	</thead>
	<tbody>
<%
	If rs.EOF Then
%>
		<tr><td align="center" colspan="5"><h2>No potential spam found!</h2></td></tr>
	</tbody>
	</table>
<%
	Else

		While Not rs.EOF
			QuarID = rs("QuarID")
			MsgID = rs("MsgID")
%>
		<tr>
			<td align="center"><input type="checkbox" name="<%="chk_" & QuarID%>"<%if SelAll then Response.write " checked"%>></td>
			<td><font size="1">
				&nbsp;<a href="ResolveSpam.asp?QuarID=<%=QuarID%>&MsgID=<%=MsgID%>">text</a>&nbsp;<a href="ResolveSpam.asp?QuarID=<%=QuarID%>&MsgID=<%=MsgID%>&ShowHTML=1">html</a>&nbsp;&nbsp;</font><%=Server.HTMLEncode(rs("EmailFrom"))%>
			</td>
			<td><%=Server.HTMLEncode(rs("Subject"))%></td>
			<td><%=rs("MsgDate")%></td>
			<td><%=rs("RejectDesc")%></td>
		</tr>
<%
			rs.MoveNext
		Wend
%>
	</tbody>
	</table>
	<input type="submit" name="cmdDelete" value="Delete">&nbsp;
	<input type="submit" name="cmdSend" value="Send">
	</form>
	<form action="<%=request.servervariables("SCRIPT_NAME")%>" method="get">
	<input type="submit" name="SelAll" value="Check All">&nbsp;
	</form>
<%
	End If

	rs.Close
	Set rs = Nothing
End Sub 
'ShowSpamList

	con.Close
	Set con = Nothing
%>
	<p>Change your <a href="PasswordChange.asp">password</a><br>

<%'****** Revision  6-11-03 ******%>
	   Search for a <a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?NewEmail=1">different email</a>.</p>
</body>
</html>


