<%
'=======================================================
' 欢迎使用《阿赛大型门户网站系统V3.0》，简称“AsaiMHV3”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================

Class AsaiMHMail
  public sort,closes,chk,mhei,h_sel,h_accept,h_topic,h_word,h_send
  public m_tit,m_frm,m_accept,m_topic,m_word,Ok_var

  private sub class_initialize()
    sort="mail"
    closes=false
    chk=false
    mhei=200
    m_tit="发送站内短信"
    h_sel="请选择收信人"
    h_accept="收 件 人"
    h_topic="短信主题"
    h_word="短信内容"
    h_send="发送短信"
    Ok_var="已成功发送一条站内短信！"
  End Sub

  sub mail_chk()
    if login_mode="" then
      if closes then
        Response.Write "<script language=javascript>alert(""您现在还没有登陆本站！\n\n请先注册并登陆本站。"");window.close();</script>"
      else
        Response.Write "<tr class=tr><td  height="&mhei&" colspan=2>&nbsp;"&web_nologin&"</td></tr>"
      End If
    else
      if Cls.chk() then
        call mail_send()
      else
	      Response.Write vbcrlf&"<table cellspacing=1 cellpadding=4 class=table>" & _
		   vbcrlf&"<tr><td class=td colspan=2>&nbsp;"&img_skin("h_")&m_tit&"</td></tr>"
        call mail_body()
		 Response.Write vbcrlf&"</table>"
      End If
    End If
  End Sub

  sub mail_send()
    dim found_err,accept_u,topic,word,types,isread
    types=1
    isread=0
    accept_u=trim(request.form("accept_u"))
    topic=Cls.Code_Var(request.form("topic"))
    word=Cls.Code_Var(request.form("word"))
    found_err=""
    if Not Cls.CodeIsTrue() then
      found_err=found_err&"+您提交的 <font color=red>验证码</font> 有错误，请勿非法提交！<br />"
    End If
    if true_accept(accept_u)=false then
      found_err=found_err&"+您输入的 <font color=red>"&h_accept&"</font> 为空或不存在！<br />"
    End If
    if topic="" or len(topic)>20 then
      found_err=found_err&"+您输入的 <font color=red>"&h_topic&"</font> 为空或长度超过20！<br />"
    End If
    if word="" or len(word)>250 then
      found_err=found_err&"+您输入的 <font color=red>"&h_word&"</font> 为空或长度超过250！<br />"
    End If
    if found_err<>"" then
      Response.Write  "<table align=center valign=middle height=270><tr><td align=left>"&found_err&"<p align=center><a href=""javascript:history.back(1)"">返回修改</a></p></td></tr></table>"
      exit sub
    End If
    sql="insert into AsaiMHUserMail(send_u,accept_u,topic,word,tim,types,isread) " & _
	"values ('"&login_username&"','"&accept_u&"','"&topic&"','"&word&"','"&Cls.now_time&"',"&types&","&isread&")"
    call Cls.exec(sql,0)
    if closes then Call Cls.Out_Msg(Ok_var,"javascript:window.close()")
    chk=true
  End Sub

  sub mail_body()
    dim ai,adim,afir,atmp
    afir=""
    adim=split(m_accept,"|")
    for ai=0 to ubound(adim)
      if afir="" then afir=adim(ai)
      atmp=atmp&vbcrlf&"<option value='"&adim(ai)&"'>"&adim(ai)&"</option>"
    next
    erase adim
%>
<form name=write_frm action='<%Response.Write m_frm%>' method=post onsubmit="javascript:frm_submitonce(this);">
<input type=hidden name=chk value='yes'>
<tr class=tr>
<td width='20%'><%Response.Write h_accept%>：</td>
<td width='80%'>
  <table border=0 cellspacing=0 cellpadding=0>
  <tr>
  <td><input type=text class=txt name=accept_u value='<%Response.Write afir%>' readonly size=30 maxlength=20><%Response.Write redx%><=20</td>
  <td>&nbsp;<select name=friend_select size=1 onchange="javascript:do_accept(this.options[this.selectedIndex].value);">
<option value='' ><%Response.Write h_sel%></option>
<%Response.Write atmp%>
</select></td>
  </tr>
  </table>
</td>
</tr>
<tr  class=tr>
<td><%Response.Write h_topic%>：</td>
<td><input type=text class=txt name=topic value='<%Response.Write m_topic%>' size=50 maxlength=20></td>
</tr>
<tr class=tr >
<td>验 证 码：</td>
<td ><%Response.Write Cls.GetCode()%></td>
</tr>
<tr class=tr>
<td class=htd><%Response.Write h_word%>：<br />UBB不支持<br />HTML不支持<br />长度<=250字节</td>
<td><textarea class=txtarea name=word rows=7 cols=55><%Response.Write Cls.code_word(m_word)%></textarea></td>
</tr>
<tr  class=tre><td height=30 colspan=2 align=center><input type=submit class=btn value=' <%Response.Write h_send%> '>　　　<input type=reset class=btn value=' 重新填写 '></td></tr>
</form>
<script language=javascript>
function do_accept(addaccept)
{
  if (addaccept!="")
  { document.write_frm.accept_u.value=addaccept; }
}
</script>
<%
  End Sub
end class

Function true_accept(auser)
	true_accept=false
	if ChkName(auser)=true then
		dim rsf
		set rsf=Cls.exec("select top 1 username from AsaiMHUserData where username='"&auser&"'",1)
		if not rsf.eof then
			auser=rsf(0)
      			true_accept=true
    		End If
    		rsf.close
    		set rsf=nothing
	End If
End Function
%>
