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

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

$username=get_cookie('username');
include_once("homeurl.php");
mysql_query("update {$tablepre}sms set IsNew=0 where accepter='".$username."'");
?>
<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>
<title><?=$username?>的收件箱</title>
</head>
<script language="JavaScript" src="inc/Main.js"></script>
<script src="js/publicfun.js" type="text/javascript"></script>
<body topmargin="5">
<?
if (get_cookie('ftbbstype')==1){
include_once("pbhead.php");
}
?>
<TABLE align=center border=0 cellPadding=0 cellSpacing=1 width="99%" class="maintbbg">
    <TR> 
      <TD height=25 class="f12bg"> &nbsp;<?=$userinfo?></TD>
    </TR>
    <tr> 
      <td height="25" colspan="3" class="maintbtr3">&nbsp;<a href="<?=$homepage?>">论坛首页</a> >> 我的短信：</td>
    </tr>
</TABLE>
<table cellspacing=0 cellpadding=0 width="99%" align=center border=0>
  <tr> 
    <td height=5></td>
  </tr>
</table>
<?
$flag=$_GET["flag"];
if ($flag=="2"){
$flagcss2='class="current"';
}else{
$allcss='class="current"';
}
?>
<div align="center">
 <div id="postflag">
	<ul class="tabs">
		<li <?=$allcss?>><a href="mysms.php?flag=1">收件箱</a></li>
		<li <?=$flagcss2?>><a href="mysms.php?t=my&flag=2">发件箱</a></li>
		<li><a href="smsbbs.php">发短信</a></li>
	</ul>
 </div>
</div>
<table width="99%" border="0" cellspacing="0" cellpadding="1" align="center" class="maintbbg">
    <tr> 
    <td>
    <TABLE align=center border=0 cellPadding=0 cellSpacing=0 width="100%">
    <TR> 
      <TD height=35 class="loopborder3"> 
        <div align="center"> 
          <form name="form1" method="post" action="" 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>
  </TABLE> 
<form name="selectform" method="post" action="userpldelsms.php" style="MARGIN-TOP: 0px;margin-bottom:0px">
    <input type="hidden" name="op" value="选择删除">
<input type="hidden" name="returnURL" value="mysms.php">
 <script language="JavaScript">
  <!--
  function select_pl_submit(optype){
	var f=document.forms["selectform"]
	f.op.value=optype
	f.submit()
  }
  //-->
  </script>
<?
$searchstr=ftbbs_request($_POST["searchstr"]);
$smtype=ftbbs_request($_POST["smtype"]);
$t=$_GET["t"];
if ($searchstr!="" || $smtype!=""){
   $searchstr="and ".$smtype." like '%".$searchstr."%'";
}
if ($t=="my"){
   $sql="select * from {$tablepre}sms where sender='".$username."' ".$searchstr." and bbssystem=0 order by indate desc";
}
else{
   $sql="select * from {$tablepre}sms where (((bbssystem=2 or bbssystem=0) and accepter='".$username."') or bbssystem=1) ".$searchstr." order by indate desc";
}

$p = new ft_page;
$rs=mysql_query($sql);
$myrow = mysql_fetch_array($rs);
$numrows = mysql_num_rows($rs); 

$p->pvar="page"; 
$p->setvar(array("smtype" => $smtype, "searchstr" => $searchstr));
$p->set($pagesize,$numrows,$psize); 
$rsx=mysql_query($sql." limit ".$p->limit());
if ($numrows!=0){
   while ($myrow = mysql_fetch_array($rsx)){
	$i++;
	$id=$myrow["id"];
	$title=$myrow["title"];
	$content=$myrow["content"];
	$content=ubb($content);
	$dbsender=$myrow["sender"];
	$accepter=$myrow["accepter"];
	$bbssystem=$myrow["bbssystem"];
	$indate=$myrow["indate"];
	$replysign=$myrow["replysign"];
    $htmlinfo="";
 if ($bbssystem==0){
   $sender="<div align=center>第".$i."条</div>";
   if ($t=="my"){
      $str="select * from {$tablepre}clubuser where clubuser_name='".$username."'";
	  }
   else{
      $str="select * from {$tablepre}clubuser where clubuser_name='".$dbsender."'";
   }
   //echo $str;
   //exit;
   $rsa=mysql_query($str);
   $myrowa = mysql_fetch_array($rsa);
   $numrowsa = mysql_num_rows($rsa); 
   if ($numrowsa!=0){
      $jingyuan=$myrowa["jingyuan"];
      $tili=$myrowa["tili"];
      $userimg=$myrowa["userimg"];
	  $clubuser_name=$myrowa["clubuser_name"];
      if ($jingyuan==""){
	     $jingyuan==0;
	  }
      if ($tili==""){
	     $tili==100;
	  }
      if ($userimg==""){
	     $userimg="cache5.gif";
	  }
      $clubuser_reg_date=dateFormat($myrowa["clubuser_reg_date"],'Y-m-d');
      $touxian=touxianvalue($jingyuan);
      $jibie=jibievalue($jingyuan);
      $htmlinfo="<TABLE border=0 cellPadding=0 cellSpacing=0 width=100%>";
      $htmlinfo=$htmlinfo."<TBODY><TR>";
      $htmlinfo=$htmlinfo."<TD><div align=center><IMG height=84 src=userheadimg/".$userimg." width=84></div></TD>";
      $htmlinfo=$htmlinfo."</TR><TR>"; 
      $htmlinfo=$htmlinfo."<TD height=20 class=f12>·网名：".$clubuser_name."</TD>";
      $htmlinfo=$htmlinfo."</TR><TR>";
      $htmlinfo=$htmlinfo."<TD height=20 class=f12>·头衔：".$touxian."</TD>";
      $htmlinfo=$htmlinfo."</TR><TR>"; 
      $htmlinfo=$htmlinfo."<TD height=20 class=f12>·级别：".$jibie."</TD>";
      $htmlinfo=$htmlinfo."</TR><TR>" ;
      $htmlinfo=$htmlinfo."<TD height=20 class=f12>·体力：".$tili."</TD>";
      $htmlinfo=$htmlinfo."</TR><TR>"; 
      $htmlinfo=$htmlinfo."<TD height=20 class=f12>·积分：".$jingyuan."</TD>";
      $htmlinfo=$htmlinfo."</TR><TR>"; 
      $htmlinfo=$htmlinfo."<TD height=20 class=f12>·注册：".$clubuser_reg_date."</TD>";
      $htmlinfo=$htmlinfo."</TR></TBODY>";
      $htmlinfo=$htmlinfo."</TABLE>";
      }
   }
 else{
      $htmlinfo="<table width=100% border=0 cellspacing=0 cellpadding=0>";
      $htmlinfo=$htmlinfo."<tr>"; 
      $htmlinfo=$htmlinfo."<td><div align=center> <IMG height=84 src=userheadimg/cache5.gif width=84></div></td>";
      $htmlinfo=$htmlinfo."</tr><tr>"; 
      $htmlinfo=$htmlinfo."<td height=20 class=f12><div align=center>系统管理员</div></td>";
      $htmlinfo=$htmlinfo."</tr><tr><td height=12>&nbsp;</td></tr>";
      $htmlinfo=$htmlinfo."</table>";
      $sender="<div align=center>第".$i."条</div>";			     
  }
  //echo $htmlinfo;
  //exit; 
?>
  <TABLE align="center" class="maintbbg" border=0 cellPadding=0 cellSpacing=0 width="100%">
    <TBODY>
      <TR> 
        <TD width="20%" height="26" vAlign=middle class="maintbtr1"> 
          <?=$sender?>
        </TD>
        <TD class="maintbtr1"><B> 标 题：<?=$title?></B> </TD>
      </TR>
    </TBODY>
  </TABLE>
  <TABLE width="100%" border=0 align="center" cellPadding=0 cellSpacing=0 bgColor="#FFFFFF">
    <TBODY>
      <TR>
        <TD class="maintbtr3" rowSpan=2 vAlign=top width="20%"><DIV align=center>
            <?=$htmlinfo?>
          </DIV></TD>
      </TR>
      <TR>
        <TD class="td004" vAlign=top><TABLE border=0 cellPadding=3 cellSpacing=3 width="100%">
            <TBODY>
              <TR>
                <TD height="158" vAlign=top class=f14>内 容：<?=$content?></TD>
              </TR>
            </TBODY>
          </TABLE>
          <TABLE border=0 cellPadding=0 cellSpacing=5 width="100%">
            <TBODY>
              <TR>
                <TD background="images/bg_text1.gif" height="1"></TD>
              </TR>
			  <? if ($bbssystem==0){?>
              <TR>
                <TD align=left class=f12><table width="100%" border=0 cellspacing=0 cellpadding=0>
                    <tr>
                        <td width="52%" class=f12>&nbsp;<font color="#000000">操作选项：<input type="checkbox" name="checkbox1[]" value="<?=$id?>">[<a class=a03 href=delsms.php?id=<?=$id?>>删除</a>][<a class=a03 href=editsms.php?id=<?=$id?>>编辑</a>]<? if ($t!="my"){?>[<? if ($replysign==0){?><a class=a03 href=replysms.php?id=<?=$id?>>回复</a><? }else{?><font color="#FF0000">已回复</font><? }?>]<? }?>
                          </font></td>
                      <td width="48%" class=f12><div align="right">发信时间:&nbsp;<?=$indate?>&nbsp;</div></td>
                    </tr>
                  </table></TD>
              </TR>
			  <? }elseif ($bbssystem==2){?>
                <tr>
                  <td width="52%" class=f12><font color="#000000"> 
                    <?if (get_cookie('bbsadmin')==1){?>
                    操作选项：[<a class=a03 href=delsms.php?id=<?=$id?>>删除</a>][<a class=a03 href=editsms.php?id=<?=$id?>>编辑</a>]<? }?><? if ($dbsender!=""){?>[<a class=a03 href="agree.php?id=<?=$id?>&postuser=<?=$dbsender?>&accepter=<?=$accepter?>&agree=Y">同意</a>][<a class=a03 href="agree.php?id=<?=$id?>&postuser=<?=$dbsender?>&accepter=<?=$accepter?>&agree=N">不同意</a>]<? }?></font></td>
                  <td width="48%" class=f12><div align="right">发信时间:<?=$indate?>&nbsp;</div></td>
                </tr>
			  <? }?>
            </TBODY>
          </TABLE></TD>
      </TR>
    </TBODY>
  </TABLE>
<?
}
?>
  <TABLE align=center border=0 cellPadding=0 cellSpacing=0 width="100%">
    <TR class="maintbtr1"> 
    <TD width="83%" height=25>
             <table width="100%" border="0" cellspacing="0" cellpadding="0" align="left">
              <tr>
                
          <td width="79%" height="25" align="left" class="f12"> 
            <?
                $p->output(0);
                $db->close(); 
                ?>
          </td>
                <td width="21%" align="right" class="f12"><input type="checkbox" name="chkall" onclick="checkall(this.form)">
				&nbsp;<input name="button" type="button" onclick="select_pl_submit('选择删除')" value="将所选删除"> 
                </td>
              </tr>
            </table>
	</TD>
    </TR>
<? }
else{
?>    
        <tr class="maintbtr3"> 
          <td align=center height=25> 你目前没有短信!</td>
        </tr>
<?
}
?>
  </TABLE>
  </form>
</td>
  </tr>
</table>
<?
include_once("inc/bbstail.php");
?>
</body>
</html>