<%
'***********************************************************************
'** Copyright (C) 2001 - 2004 Max Yuan All Rights Reserved
'**
'** By using this program, you are agreeing to the terms of the
'** GNU General Public License.
'**
'** This program is free software; you can redistribute it and/or
'** modify it under the terms of the GNU General Public License
'** as published by the Free Software Foundation; either version 2
'** of the License, or any later version.
'**
'** All copyright notices regarding MaxWebPortal must remain intact
'** in the scripts and in the outputted HTML.
'** The "powered by" text/logo with a link back to 
'** http://www.maxwebportal.com in the footer of the pages MUST
'** remain visible when the pages are viewed on the internet or intranet.
'**
'** Support can be obtained from support forums at:
'** http://www.maxwebportal.com
'**
'** Email: maxwebportal@hotmail.com
'** ICQ: 148111300
'***********************************************************************
'** This Page Contains source code of Snitz Forums 2000
'***********************************************************************
'#################################################################################
'## Copyright (C) 2000  Michael Anderson and Pierre Gorissen
'## 
'## This program is free software; you can redistribute it and/or
'## modify it under the terms of the GNU General Public License
'## as published by the Free Software Foundation; either version 2
'## of the License, or any later version.
'##
'## All copyright notices regarding Snitz Forums 2000
'## must remain intact in the scripts and in the outputted HTML
'## The "powered by" text/logo with a link back to 
'## http://forum.snitz.com in the footer of the pages MUST
'## remain visible when the pages are viewed on the internet or intranet.
'## 
'## This program is distributed in the hope that it will be useful,
'## but WITHOUT ANY WARRANTY; without even the implied warranty of
'## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'## GNU General Public License for more details.
'## 
'## You should have received a copy of the GNU General Public License
'## along with this program; if not, write to the Free Software
'## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
'## 
'## Support can be obtained from support forums at:
'## http://forum.snitz.com 
'##
'## Correspondence and Marketing Questions can be sent to:
'## reinhold@bigfoot.com
'## 
'## or
'## 
'## Snitz Communications 
'## C/O: Michael Anderson
'## PO Box 200
'## Harpswell, ME 04079
'#################################################################################
%>
<% server.scripttimeout = 6000 %>
<!--#INCLUDE FILE="config.asp" -->
<!--#INCLUDE FILE="inc_adminvar.asp" --><%If Session(strCookieURL & "Approval") = "256697926329" and instr(strWebMaster,lcase(strAdmin1UserName)&",") <> 0 and not lcase(strAdmin1UserName) = "" and not lcase(strAdmin1UserName) = " " Then %>
<!--#INCLUDE FILE="inc_functions.asp" -->
<!--#INCLUDE file="inc_top.asp" -->
<% 
My_ID = request.querystring("id")
My_Mode = request.querystring("mode")
if My_Mode = "" then
%>
<table border="0" width="100%">
  <tr>
 <td width="33%" align="left" nowrap><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>">
 <img src="icon_folder_open.gif" height=15 width=15 border="0">&nbsp;<a href="default.asp">Home</a><br>
 <img src="icon_blank.gif" height=15 width=15 border="0"><img src="icon_folder_open.gif" height=15 width=15 border="0">&nbsp;<a href="admin_home.asp">Admin Section</a><br>
 <img src="icon_blank.gif" height=15 width=15 border="0"><img src="icon_blank.gif" height=15 width=15 border="0"><img src="icon_folder_open.gif" height=15 width=15 border="0">&nbsp;<a href="admin_emaillist.asp">User Email List</a><br>
  <img src="icon_blank.gif" height=15 width=15 border="0"><img src="icon_blank.gif" height=15 width=15 border="0"><img src="icon_blank.gif" height=15 width=15 border="0"><img src="icon_folder_open_topic.gif" height=15 width=15 border="0">&nbsp;User Email Manager<br>
 </font></td>
  </tr>
</table>
<BR>
<% 
strSql = "SELECT * FROM " & strTablePrefix & "SPAM ORDER BY ARCHIVE ASC"
set rs = Server.CreateObject("ADODB.Recordset")
rs.open  strSql, My_Conn, 3
%>
<TABLE width="90%" BORDER=1 bordercolor="<% =strTableBorderColor %>" CELLSPACING=0 align="center" width="100%">
<TR ALIGN="CENTER">
<TD BGCOLOR=<% =strHeadCellColor %>><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>"><B>Status</B></FONT></TD>
<TD BGCOLOR=<% =strHeadCellColor %>><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>"><B>Message Title</B></FONT></TD>
<TD BGCOLOR=<% =strHeadCellColor %>><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>"><B>Composed</B></FONT></TD>
<TD BGCOLOR=<% =strHeadCellColor %>><a href="admin_emailmanager.asp?mode=compose"><img src="icon_folder_new_topic.gif" alt="Add New Message" border="0" hspace="0"></a></TD>
</TR>
<%
On Error Resume Next
RS.MoveFirst
do while Not RS.eof                       
ARCHIVED = rs("ARCHIVE")
if ARCHIVED = "1" then
ARCHIVED = "ARCHIVED"
else
ARCHIVED = "LIVE"
end if
if rs("F_SENT") <> "" then
F_SENT = ChkDate(rs("F_SENT"))
else
F_SENT = "-" 
end if
 %>
<TR VALIGN=TOP>
<td bgcolor="<% =strForumCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><%= ARCHIVED %></FONT>&nbsp;</TD>
<td bgcolor="<% =strForumCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><input type="hidden" name="ID" value="<%=RS("ID")%>"><a href="admin_emailmanager.asp?mode=edit&id=<%=RS("id")%>"><%=RS("SUBJECT")%></a></FONT>&nbsp;</TD>
<td ALIGN="CENTER" bgcolor="<% =strForumCellColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><% =F_SENT %></FONT>&nbsp;</TD>
<td bgcolor="<% =strForumCellColor %>" align="right"> <a href="admin_emailmanager.asp?mode=edit&ID=<% =rs("ID") %>"><img src="icon_pencil.gif" alt="Edit Message" border="0" hspace="0"></a>
  <a href="admin_emailmanager.asp?mode=update&ID=<% =rs("ID") %>&ARCHIVE=2"><img src="icon_trashcan.gif" alt="Delete Message" border="0" hspace="0"></a></td>
</TR>
<%
RS.MoveNext
loop%>
</table>
<%
set rs = nothing
%>
<BR><BR><!--#INCLUDE file="inc_footer.asp" -->

<% elseif My_Mode = "update" then%>
<%
if request.querystring("mode") = "update" then
%>
<%
if request.querystring("ARCHIVE")= "2" then
 
		set conn = server.createobject("adodb.connection")
	      	conn.Open My_Conn
		For each record in request("ID")
    		sqlstmt = "DELETE * from " & strTablePrefix & "SPAM WHERE ID=" & My_ID
			Set kRS = conn.execute(sqlstmt)
		Next
 
	set kRS = nothing
%>
<BR><BR>

<font face="<% =strDefaultFontFace %>"><h1>Message Deleted</h1><BR><BR>
Message has been deleted. Return to <a href="admin_emailmanager.asp">message list</a>.</font>

<BR><BR>
<!--#INCLUDE file="inc_footer.asp" -->
	<%
	response.end
end if
%>
<% 
My_ID = request.querystring("ID") 
	strSQL3="select * from " & strTablePrefix & "SPAM where id=" & My_ID
	set kRS=Server.CreateObject("ADODB.Recordset")
	kRS.Open strSQL3, My_Conn, 1, 3
kRS("SUBJECT") = request.querystring("SUBJECT")
kRS("MESSAGE") = request.querystring("MESSAGE")	
kRS("ARCHIVE") = request.querystring("ARCHIVE")

	kRS.Update
%>
<BR><BR><font face="<% =strDefaultFontFace %>"><h1>Message Updated</h1><BR><BR>
Your message has been update. Return to <a href="admin_emailmanager.asp">message list</a>.</font>
<%
set kRS = nothing
%>

<BR><BR><!--#INCLUDE file="inc_footer.asp" -->
<% end if  %>
<%
elseif My_Mode = "compose" then 

%>
<h2>Compose New Message</h2>
<form action="admin_emailmanager.asp">
<input type="hidden" name="mode" value="save">
<table bordercolor="<% =strTableBorderColor %>" border="1" cellspacing="0" cellpadding="5">
<tr>
<td><font face="<% =strDefaultFontFace %>">Subject:</font></td><td><input type="text" name="SUBJECT" size="50"></td>
</tr>
<tr>
<td colspan="2"><font face="<% =strDefaultFontFace %>">Message:</font></td>
</tr>
<tr>
<td colspan="2" align="center"><textarea name="MESSAGE" cols="50" rows="10" wrap="PHYSICAL"></textarea></td>
</tr>
</table>

<font face="<% =strDefaultFontFace %>">Save this message in: </font>&nbsp; 
<font face="Verdana, Arial, Helvetica" size="2"> 
 <select name="ARCHIVE" size="1">
  <option value="0" SELECTED>&nbsp;Live List</option>
  <option value="1">&nbsp;Archive</option>
</select>
 </font>

 &nbsp;<input type="Submit" value="Save">&nbsp;<input type="reset">
 
<%
elseif My_Mode = "save" then

strSubject = replace(request.querystring("SUBJECT"),"'","''")
strMessage = replace(request.querystring("MESSAGE"),"'","''")
strArchive = request.querystring("ARCHIVE")

	set conn = server.createobject ("adodb.connection")
	conn.open My_Conn
	conn.Execute "insert into " & strTablePrefix & "SPAM (SUBJECT, MESSAGE, F_SENT, ARCHIVE) values (" _
		& "'" & strSubject & "', " _
		& "'" & strMessage & "', " _ 
		& "'" & DateToStr(now()) & "', " _		
		& "'" & strArchive & "')"
%>
<BR><BR><font face="<% =strDefaultFontFace %>"><h2>Message Saved</h2><BR><BR>
Your message has been saved. Return to <a href="admin_emailmanager.asp">message list</a>.</font>		
<BR><BR><!--#INCLUDE file="inc_footer.asp" -->

<%
elseif My_Mode = "edit" then

strSql2 = "SELECT * FROM " & strTablePrefix & "SPAM WHERE ID =" & My_ID
set rsSP = Server.CreateObject("ADODB.Recordset")
rsSP.open  strSql2, My_Conn, 3
mySUBJECT = Server.HTMLEncode(rsSP("SUBJECT"))
myMESSAGE = rsSP("MESSAGE")
%>
<h2>Modify Message</h2>
<form action="admin_emailmanager.asp"><input type="hidden" name="mode" value="update"><input type="hidden" name="ID" value="<%= rsSP("ID") %>">
<table bordercolor="<% =strTableBorderColor %>" border="1" cellspacing="0" cellpadding="5">
<tr>
<td><font face="arial">Subject:</font></td><td><input type="text" name="SUBJECT" size="50" value="<%= mySUBJECT%>"></td>
</tr>
<tr>
<td colspan="2"><font face="arial">Message:</font></td>
</tr>
<tr>
<td colspan="2" align="center"><textarea name="MESSAGE" cols="50" rows="10" wrap="PHYSICAL"><%= myMESSAGE %></textarea></td>
</tr>
</table>
<font face="arial">Message Status:</font>&nbsp; 
<font face="Verdana, Arial, Helvetica" size="2"> 
 <select name="ARCHIVE" size="1">
  <option value="0" SELECTED>&nbsp;Live List</option>
  <option value="1">&nbsp;Archive</option>
  <option value="2">&nbsp;Delete</option>
</select>
 </font>
 &nbsp;<input type="Submit" value="Modify">&nbsp;<input type="reset">
<%
set rsSP = nothing
%>
<BR><BR>
</form>
<!--#INCLUDE file="inc_footer.asp" -->
<% end if%><% else %>
<%Response.Redirect "admin_login.asp" %>
<% end iF %>