<?php
include_once("inc/config.php");
include_once("inc/ftbbsdbclass.php");
include_once("inc/publicfun.php");
include_once("inc/pageclass.php");
include_once("inc/ftcode.php");
include_once("conn.php");
include_once("checkuser.php");
include_once("ftbbs_nav.php");
include_once("bbsuser.php");

$query = "SELECT * FROM {$tablepre}ftbbsmb";
$ftbbsmb=makecache('ftbbsmb.html',$query,$expire);
$pagesize=$ftbbsmb[5];
$defaulthome=$ftbbsmb[31];

include_once("homeurl.php");
$postuserid=intval($_GET["postuser"]);

$sql="select clubuser_id,clubuser_name from {$tablepre}clubuser where clubuser_id='".$postuserid."'";
$rs=mysql_query($sql);
$row = mysql_fetch_array($rs);
$postuser=$row["clubuser_name"];

$id=intval($_GET["id"]);
if ($postuser==""){
$postuser=$_POST["postuser"];
$rd="";
}
else{
$rd="readonly";
}
if ($_POST["act"]=="y"){
   $sender=get_cookie('username');
   $accepter=ftbbs_request($_POST["postuser"]);
   $title = ftbbs_request(trim($_POST["title"]));
   $title = nohtml($title);
   $content=$_POST["content"];
   $content=htmlspecialchars($content);
   $title = nojs($title);
   $content = nojs($content);
   
   $sql="select clubuser_id from {$tablepre}clubuser where clubuser_name='".$postuser."'";
   $rs=mysql_query($sql);
   $row = mysql_fetch_array($rs);
   $numrows = mysql_num_rows($rs);
   if ($numrows!=0){
   $str="insert into {$tablepre}sms(title,content,sender,accepter,indate,IsNew) values('".$title."','".$content."','".$sender."','".$accepter."','".$getnow."',1)";
   mysql_query($str);
   echo "<script language='javascript'>alert('发送成功！');history.go(-2);</script>";
   exit;
   }
   else{
   echo "<script language='javascript'>alert('你所发送的用户名不存在，请查对！');history.go(-2);</script>";
   exit;
   }
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language=javascript src="inc/cookies.js"></script>
<script>
var stylecook = getCookie("STYLESHOW");
var style;
var strstyle;
if(stylecook=="")
{
 stylecook=1;
}
else
{
 stylecook++;
}
style="main0"+stylecook+".css";
strstyle="<link href=\"css/"+style+"\"  rel=\"stylesheet\" type=\"text/css\"> ";
document.write(strstyle);
</script>
<script language="javascript">
<!--
	function check(form)
	{
    if (form.postuser.value=="")
    	{
    	alert("请填写好友用户名！");
    	form.postuser.focus();
    	return false;
  	}
    if (form.title.value=="")
    	{
    	alert("请填写标题！");
    	form.title.focus();
    	return false;
  	}
    if (form.content.value=="")
    	{
    	alert("请填写内容！");
    	form.content.focus();
    	return false;
  	}
    return true;
	}
//-->
</script>
<title>论坛短信系统</title>
</head>
<body topmargin="5">
<?
if (get_cookie('ftbbstype')==1){
include_once("pbhead.php");
}
?>
  <TABLE align=center class="maintbbg" border=0 cellPadding=1 cellSpacing=1 width="99%">
    <TR> 
      <TD height=25 class="f12bg"> <div align="left">&nbsp;<?=$userinfo?></div></TD>
    </TR>
  </TABLE>
  <TABLE align="center" border=0 cellPadding=1 cellSpacing=1 width="99%" class="maintbbg">
    <TBODY>
      <TR> 
        
      <TD height="28" vAlign=middle class="maintbtr1"><div align="left">&nbsp;
        <a href="<?=$homepage?>">论坛首页</a> >>发送短信</div></TD>
      </TR>
    </TBODY>
  </TABLE>
<table cellspacing=0 cellpadding=0 width="99%" align=center border=0>
  <tr> 
    <td height=5></td>
  </tr>
</table>
<div align="center">
 <div id="postflag">
	<ul class="tabs">
		<li><a href="mysms.php?flag=1">收件箱</a></li>
		<li><a href="mysms.php?t=my&flag=2">发件箱</a></li>
		<li class="current"><a href="smsbbs.php">发短信</a></li>
	</ul>
 </div>
</div>
<TABLE width="99%" border=0 align="center" cellPadding=0 cellSpacing=0 class="listborder">
    <TBODY>
      <TR> 
      <TD height=50 class="loopborder3"> <div align="center"> 
          <form name="form1" method="post" action="mysms.php" style="MARGIN-BOTTOM: 0px">
            短信搜索: 
            <input name="searchstr" type="text" id="searchstr" size="35">
            <select name="smtype" id="smtype">
              <option value="title" selected>短信标题</option>
              <option value="content">短信内容</option>
            </select>
            <input type="submit" name="Submit" value="查找短信">
          </form>
          </div></TD>
    </TR>
      <TR> 
        <TD vAlign=middle class="maintbtr3"><div align="center">
            <form name="form2" method="post" action="" style="MARGIN-BOTTOM: 0px" onsubmit="return check(this)">
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>  
                <td width="20%" height="35" class="maintbtr3"> 
                  <div align="right">收 信 人:</div></td>
                  <td width="76%" height="25">
                  <input name="postuser" type="text" id="postuser" value="<?=$postuser?>" <?=$rd?> >
                  </td>
                </tr>
                <tr>
                <td width="20%" height="35" class="maintbtr3"> 
                  <div align="right">短信标题:</div></td>
                  <td><input name="title" type="text" id="title" size="50"></td>
                </tr>
                <tr> 
                <td height="277" class="maintbtr3">
<div align="right">短信内容:</div></td>
                  <td><textarea name="content" cols="70" rows="20" id="content"></textarea></td>
                </tr>
                <tr> 
                  <td height="30"><div align="right"></div></td>
                  <td><input type="submit" name="Submit" value="发送短信">
                  <input name="act" type="hidden" id="act" value="y"> <input name="id" type="hidden" id="id" value="<?=$id?>">
                    </td>
                </tr>
              </table>
            </form><br><br><br>
          </div></TD>
      </TR>
    </TBODY>
  </TABLE>
<?
include_once("inc/bbstail.php");
?>
</body>
</html>