<!--#include file="../fy_inc/fy.User.asp"-->
 <% 	Dim UserHS,U_Simple,Max_sEnd,Max_sms,Max_Num
	Set UserHS = New ACT_User
	IF Cbool(UserHS.UserLoginChecked)=false then
	  echo "<script>top.location.href ='login.asp' ;</script>"
	  Response.end
	End If	
	If UserHS.G_Simple="" Then 
		U_Simple="Simple"
	Else
		U_Simple=UserHS.G_Simple
	End If 
 	Max_sEnd=UserHS.G_Max_sEnd''群发限制人数
	Max_sms=UserHS.G_Max_sms	'内容最多字符数
	Max_Num=UserHS.G_Max_Num'最多允许存放条数
	
	
	if request("a")="save" then 
			dim title,message,i,sUname,FID,umodeid,userid,rs1
			FID=ChkNumeric(fycms.s("FID"))
			set rs=fycms.actexe("select * from Friend_fy where id="&fid)'查找该MSG ID的用户
			if not rs.eof then 
				userid=rs("userid")'发送对象的信息
			else
 				call fycms.Alert("没有找到该用户","")
				response.end
 			end if 
			
			set rs1=fycms.actexe("select * from  Friend_fy where    u="&userid&" and  UserID="& UserHS.UserID &"    and flag=2 ")'查找该发送对象的信息
 			if not   rs1.eof then 
 				call fycms.Alert("对不起，你被列为黑名单,不能发送短信给他！","")
				response.end
			end if 
			
			If fycms.s("Title")="" Then
				echo("<script>alert('您还没有填写标题呀。');history.back();</script>")
			ElseIf fycms.strLength(fycms.s("title"))>50 Then
				echo("<script>alert('标题限定最多50个字符。');history.back();</script>")
			Else
				title=fycms.s("title")
			End If
			If fycms.s("content")="" Then
				echo("<script>alert('内容是必须要填写的噢。');history.back();</script>")
			ElseIf fycms.strLength(fycms.s("content"))>Cint(max_sms) Then
				echo("<script>alert('内容限定最多"&max_sms&"个字符。');history.back();</script>")
			Else
				message=fycms.s("content")
			End If
  
			SqlStr="Select UserID from User_fy where UserID="&UserID&""
			Set rs=Conn.Execute(SqlStr)
			If RS.eof and RS.bof Then
				RS.close:Set rs=Nothing
				call fycms.Alert("系统没有这个用户，看看你的发送对象写对了嘛？","")
				response.end
			End If
				
			RS.Close
			Dim SqlsxStr
				Dim sql, rs2
				Set rs2 = Server.CreateObject("Adodb.RecordSet")

			 
			 
 			 If ChkNumeric(fycms.s("savetooutbox"))=1 Then 	 
 
				sql = "Select  * from Message_fy where 1=1"
				rs2.Open sql, Conn, 1, 3
				rs2.AddNew
				rs2("Userid") = Userid
				rs2("title") = title
				rs2("content") = message
				rs2("SendTime") = Now()
				rs2("flag") =2
				rs2("U") =UserHS.Userid
				rs2("Um") =UserHS.umodeid
				
				rs2.Update
				rs2.Close


 			 End If 
				'判断对方信箱是否已满
				If conn.execute("select count(*) from Message_fy where  U="&UserHS.Userid&"")(0)>=Max_Num Then
					echo("<script>alert('由于[" & sUname & "]的信箱已满，发送没有成功！');history.back();</script>")
				Else
				sql = "Select  * from Message_fy where 1=1"
				rs2.Open sql, Conn, 1, 3
				rs2.AddNew
				rs2("Userid") = Userid
				rs2("title") = title
				rs2("content") = message
				rs2("SendTime") = Now()
				rs2("flag") =1
				rs2("U") =UserHS.Userid
				rs2("Um") =UserHS.umodeid
				
				rs2.Update
				rs2.Close:Set rs2 = Nothing
			
				
				
				End If

 		echo("<script>alert('恭喜您，发送短信息成功。发送的消息同时保存在您的发件箱中。');location.href='send.asp';</script>")
	
	end if
 %>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>会员中心</title>
<link href="images/css.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript" src="../editor/ckeditor/ckeditor.js"></script>
</head>
<body style="background-color:#fff">
<div id="head">
  <div id="logo"><a href="index.asp" alt=""><img src="images/logo_member.gif" alt="fycms"></a></div><div id="banner"></div>
</div>
<div id="membermenu">
<!--#include file="menu.asp"-->
</div>
<div id="main">
  <div id="left">
    <div id="treemenu">
      <h5>短消息</h5>
      <ul>   	
		<li><a href="send.asp">发送短消息</a></li>
        <li><a href="inbox.asp">收件箱</a></li>
        <li><a href="outbox.asp">发件箱</a></li>
      </ul>
    </div>
    <ol>
    <li class="local"><a href="<%= fycms.Domain%>">返回网站首页</a></li>
    <li class="exit"><a href="Checklogin.asp?Action=LoginOut">退出登录</a></li>
    </ol>
  </div>
  <div id="right">
    	<p id="position"><strong>当前位置：</strong><a href="inbox.asp">短消息</a>发送短消息</p>
        <div class="clear"></div>
        <form action="send.asp?a=save" name="form" method="post">
        <table cellpadding="0" cellspacing="1" class="table_form">
        <caption>
      	发送短消息
      	</caption> 
        <tr>
        	<th width="15%">收件人：</th>
            <td width="80%">
            
            
            <input class="textbox" type=text name="Touser" value="<%=fycms.s("Touser")%>" size=60>
					  <Select class="textbox" name="FID" onchange=DoTitle(this.options[this.selectedIndex].value)> 
                       <OPTION selected value="">选择</OPTION>
						<%dim rs,sqlstr
						Set rs=server.createobject("adodb.recordSet")
						SqlStr="Select [ID],  [Userid] from Friend_fy where  U="&UserHS.UserID&"  and flag=1 order by Adddate desc"
						RS.open SqlStr,Conn,1,1
						Do While not RS.eof
						%>
						<OPTION value="<%=rs("ID")%>"<% 
							if   ChkNumeric(request("U"))=rs("Userid") then  echo " selected "
 						  %>>
                        
                        
						<%	dim rs4
							set rs4=fycms.actexe("select top 1 [username] from User_fy where userid="&rs(1)) 
							if not rs4.eof then echo rs4("username") 
 						%></OPTION>
						<%
						RS.movenext
						loop
						RS.close:Set rs=Nothing
						%>
					  </Select></td>
        </tr>
        <tr>
        	<th>标题：</th>
            <td>
        <input class="textbox" type=text name="title" size=60 maxlength=90 value="">            </td>
        </tr>
        <tr>
        	<th>内容：</th>
            <td> 
<textarea rows="10" cols="80" name="content" id="content" ></textarea>
 </td>
        </tr>
        <tr>
        	<th>保存到发件箱：</th>
            <td><input type="checkbox" name="savetooutbox" value="1"  /></td>
        </tr>
        <tr>
        <th></th>
        <td colspan="2"><label>
          <input type="submit" class="button_style" name="dosubmit" id="button" value="确 定" />&nbsp;<input class="button_style"  type="reset" name="button2" id="button2" value="取 消" />
          </label></td>
      	</tr>        
        </table></form>
    </div>
</div>
<div class="clear"></div>
<!--#include file="foot.asp"-->


<script type="text/javascript">
		function DoTitle(addTitle) {  
		 var revisedTitle; 
		 var obj = document.getElementById('FID');
		 var n = obj.options[obj.selectedIndex].text;
  		 document.form.Touser.value=n;  
		 document.form.Touser.focus(); 
		 return; 
		} 
</script>

</body>
</html> 
 