<!--#include file="inc/conn.asp"-->
<!--#include file="inc/set.asp"-->
<!--#include file="inc/dll.asp"-->
<!--#include file="inc/inc.asp"-->
<% 
if userlogin<>sys then
response.write"<SCRIPT>alert('请登陆后操作,请返回！');javascript:history.go(-1)</SCRIPT>"
response.end
end if
Select case request("action")
case "sms"
title="收件箱"
case "send"
title="发送短信"
case "box"
title="发件箱"
case "showsms"
title="查看短信"
case else
title="收件箱"
End Select
call top()%>
<table border="0"  cellspacing="0" cellpadding="0" align=center class=bgcolor>
<tr><td class=left></td>
<td class=width>
<table width=100% border=0  cellspacing="0" cellpadding="0">
<tr><td valign=top>
<%call br()%>
<table border="0"   cellspacing="0" cellpadding="0">
<td  class=lefttopcenter>&emsp;※&nbsp;会员登陆</td><td  class=lefttopright></td></tr></table>
<table border="0" cellspacing="0" cellpadding="0"><tr>
<td valign=top class=leftcentercenter  height=150 >
<%call login()%>
</td><td class=leftcenterright></td></tr></table>
<table border="0"  cellspacing="0" cellpadding="0"><tr><td class=leftfootcenter></td><td class=leftfootright></td></tr></table>
<%call br()%>
<table border="0"   cellspacing="0" cellpadding="0">
<td  class=lefttopcenter>&emsp;※&nbsp;站内搜索</td><td  class=lefttopright></td></tr></table>
<table border="0" cellspacing="0" cellpadding="0"><tr>
<td valign=top class=leftcentercenter align=center>
<%call search()%>
</td><td class=leftcenterright></td></tr></table>
<table border="0"  cellspacing="0" cellpadding="0"><tr><td class=leftfootcenter></td><td class=leftfootright></td></tr></table>
<%call br()%>
<table border="0"   cellspacing="0" cellpadding="0">
<td  class=lefttopcenter>&emsp;※&nbsp;会员排行</td>
<td class=lefttopright></td></tr></table>
<table border="0" cellspacing="0" cellpadding="0"><tr>
<td valign=top class=leftcentercenter align=center><%call br%>
<%call YC_user()%><%call br%>
</td><td class=leftcenterright></td></tr></table>
<table border="0"  cellspacing="0" cellpadding="0"><tr><td class=leftfootcenter></td><td class=leftfootright></td></tr></table>
<%call br%>
</td>
<td  width="5"></td>
<td valign=top align=right><%call br%>
<table border="0" cellspacing="0" cellpadding="0">
<tr><td class=righttopleft></td>
<td class=righttopcenter>&emsp;※&nbsp;<%=title%>
</td></tr></table>
<table border="0"   cellspacing="0" cellpadding="0"><tr>
<td class=rightcenterleft></td>
<td  class=rightcentercenter valign=top>
<%
select case request("action")
case "sms"            
         call sms()   
case "box"    
         call box()
case "send"  %>
<SCRIPT language="javascript">
<!--
function del_space(s){
for(i=0;i<s.length;++i)
{if(s.charAt(i)!=" ")
break;}
for(j=s.length-1;j>=0;--j)
{if(s.charAt(j)!=" ")
break;}
return s.substring(i,++j);}
function VerifySubmit()
{to_user = del_space(document.all("to_user").value);
if (to_user.length == 0)
{alert("你忘了填写接收人姓名");return false;}
from_user = del_space(document.all("from_user").value);
if (from_user==to_user)
{alert("不允许自己给自己发信件");return false;}
title = del_space(document.all("title").value);
if (title.length == 0)
{alert("您忘了填写信件标题");return false;}
content = del_space(document.all("content").value);
if (content.length == 0)
{alert("您忘了填写信件内容");return false;}
content = del_space(document.all("content").value);
if (content.length > 300)
{alert("内容不能大于300字");return false;}return true;}
//-->
</SCRIPT>
<form name="regform" onSubmit="return VerifySubmit()" method="post" action="?action=sendok">
<table border="0" cellspacing="0" cellpadding="0"><tr><td height=25 colspan=2>
&nbsp;接 收 人：<input name="to_user" type="text" id="to_user"class=yecao  <%if request.querystring("user")<>"" then%>value="<%=request.querystring("user")%>" <%end if%>></td></tr>
<td height=25 colspan=2>&nbsp;信件主题：<input name="title" type="text" id="title2" class=yecao></td></tr>
<td height=25 valign=top>&nbsp;短信内容：</td>
<td align=left><textarea name="content" style="width:400;height:100;" class=yecao id="textarea" onkeydown="bookcount(this.form.content,this.form.total,this.form.used,this.form.remain);" 
onkeyup="bookcount(this.form.content,this.form.total,this.form.used,this.form.remain);"></textarea></td></tr>
<td height=25 colspan=2>&nbsp;字数限制：最多字数：<input disabled maxLength="4" size="3" value="250" name="total" class=yecao>&nbsp;&nbsp;已用字数：<input disabled maxLength="4" size="3" value="0" name="used" class=yecao>&nbsp;&nbsp;剩余字数：<input disabled maxLength="4" size="3" value="250" name="remain" class=yecao></td></tr>
<td height=25 colspan=2>&nbsp;验&nbsp;证&nbsp;码：<input name="code" type="text" size="7" maxlength="4" class="yecao">&nbsp;<img src="inc/code.asp" style="width:40;height=15" border=0 align=absmiddle></td></tr>
<td height=30 colspan=2><center><input type="submit" name="Submit" value="发 送" class=put onmouseover=this.className='overput' onmouseout=this.className='put'>&nbsp;&nbsp;<input type="reset" name="reset" value="清 空" class="put" onmouseover=this.className='overput' onmouseout=this.className='put'>
<input name="from_user" type="hidden" id="from_user" value="<%=username%>"></form>
</td></tr></table>
<%
case "sendok" 
if int(request("code"))<>int(Session("code")) then
 Response.Write("<script language=javascript>alert('请输入正确的认证码！');history.go(-1);</script>") 
Response.End 
end if  
Session("code")=""
if request("to_user")<>"" and request("content")<>"" then 
to_user=trim(request("to_user"))
sql="select * from YC_user where user_name='"&to_user&"'"
set rs=conn.execute (sql)
if rs.eof and rs.bof then
Response.Write("<script>alert('数据库中没有该用户！');history.go(-1);</script>")
Response.End
else
set rs=server.createobject("adodb.recordset")
sql="select * from YC_sms"
rs.open sql,conn,1,3
rs.addnew
rs("from_user")=trim(request("from_user"))
rs("to_user")=trim(request("to_user"))
rs("title")=trim(request("title"))
rs("content")=request("content")
rs.update
conn.execute("update [YC_user] set user_money=user_money-2 where user_name="""&username&"""")
Response.Write"<script>alert(""短信发送成功！并收了您的2个点数！"");window.location='index.asp';</script>"
end if
end if
case "showsms"
set rs=server.createobject("adodb.recordset")
sql="select * from [YC_sms] where id="&request.querystring("id")
rs.open sql,conn,1,3
rs("ok")=1
rs.update
%>	 
<TABLE width="100%" border=1 cellPadding=0 cellSpacing=0 borderColor=<%=border%> frame=void rules=rows>
<tr><td height=25 align=center class=bg>短信主题：<%=rs("title")%></td></tr>
<tr><td height=120 colspan=2 valign=top style="padding:2px">
<%=rs("content")%>
</td></tr><tr><td height=25 align=center class=bg>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;发信人：<a 
href="sms.asp?action=send&user=<%=rs("from_user")%>" title="回复短信给[<%=rs("from_user")%>]"><%=rs("from_user")%></a></td></tr></table>
<%rs.close
set rs=nothing
case "delsms"   
Conn.Execute("Delete * From [YC_sms] Where id="&Request.QueryString("id"))
conn.execute("update YC_user set user_money=user_money+5 where user_name="""&username&"""")
Response.Write("<script>alert('短信删除成功！并奖励您5个点数！');this.location.href='sms.asp';</script>")	
case else
     call sms()       '收件箱
end select%>
</TR></table>
<table border="0" cellspacing="0" cellpadding="0" align=center><tr>
<td  class=rightfootleft></td><td class=rightfootcenter></td></tr></table>
</td></tr></table><%call br%>
</td><td class=right></td></tr></table>
<%
call foot()
sub sms()
%>
<TABLE width="100%" border=1 cellPadding=0 cellSpacing=0 borderColor=<%=border%> frame=void rules=rows>
<TR class=bg height=24>
<TD width="8%" align=center>状态</TD>
<TD width="15%" align=center>发送会员</TD>
<TD width="40%">短信标题</TD>
<TD width="20%" align=center>发送日期</TD>
<TD width="15%" align=center>短信操作</TD></TR>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from [YC_sms] where to_user='"&username&"' order by id desc"
rs.open sql,conn,1,1
if not rs.eof then
rs.movefirst
do while not rs.eof%>
<TR height=24><TD align=center><%if rs("ok")=1 then%>已读<%else%>未读<%end if%></TD>
<TD align=center><%=rs("from_user")%></TD>
<TD><a href="sms.asp?action=showsms&id=<%=rs("id")%>"><%=rs("title")%></a></TD>
<TD align=center title="<%=rs("date")%>"><%=left(rs("date"),9)%></TD>
<TD align=center><a href="?action=delsms&id=<%=rs("id")%>">删除</a></TD>
</TR>
<%
rs.movenext
loop
elseif rs.eof and rs.bof then
response.write"<tr><td colspan=5 height=100 align=center><font color=red><b>您的收件箱为空，暂时没有短信！</</b></font></td></tr>"
end if%>
</table>
<%
rs.close
set rs=nothing
end sub
sub box()%>
<TABLE width="100%" border=1 cellPadding=0 cellSpacing=0 borderColor=<%=border%> frame=void rules=rows>
<TR class=bg height=24>
<TD width="8%" align=center>状态</TD>
<TD width="15%" align=center>接收会员</TD>
<TD width="40%">短信标题</TD>
<TD width="20%" align=center>发送日期</TD>
<TD width="15%" align=center>短信操作</TD></TR>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from [YC_sms] where from_user='"&username&"' order by id desc"
rs.open sql,conn,1,1
if not rs.eof then
rs.movefirst
do while not rs.eof%>
<TR height=24><TD align=center><%if rs("ok")=1 then%>已读<%else%>未读<%end if%></TD>
<TD align=center><%=rs("to_user")%></TD>
<TD><a href="sms.asp?action=showsms&id=<%=rs("id")%>"><%=rs("title")%></a></TD>
<TD align=center title="<%=rs("date")%>"><%=left(rs("date"),8)%></TD>
<TD align=center><a href="?action=delsms&id=<%=rs("id")%>">删除</a></TD>
</TR>
<%
rs.movenext
loop
elseif rs.eof and rs.bof then
response.write"<tr><td colspan=5 height=100 align=center><font color=red><b>您还没有给任何人发送短信！</</b></font></td></tr>"
end if%>
</table>
<%
rs.close
set rs=nothing
end sub%>