<?

require("datafile/superadmin.php");
require("datafile/config.php");
require("datafile/style.php");
require("global.php");

$add_title=" &gt; 邮件发送";
require("header.php");
navi_bar('你现在正在<br>VIB论坛<br>的邮件程式中','发送邮件','','no');
?>
<br>
<table width="600" align=center border="0" cellspacing="0" cellpadding="0" bgcolor="<? echo $bordercolor; ?>">
  <tr> 
    <td> 
<?
if ($login_status==0) print_err();

if ($target && file_exists("$id_unique/$target")) {
	$usertemp=readfromfile("$id_unique/$target");
	$userdetail=explode("|",$usertemp);
	$usermail=$userdetail[3];
	$receiver=$userdetail[0];
}
else {
	$usermail=$admin_email;
	$receiver=$admin_name;
}

if (!empty($action) && $action=="send") {
	if (empty($emailcontent) || strlen($emailcontent)<=20) {
		$action="fail";
		$status="请填写邮件内容并在10个汉字以上";
	}
}

if (empty($action) || $action=="fail") {
?>
            <table width="100%" border="0" cellspacing="1" cellpadding="3">
              <tr> 
                <td background=images/style/catbg.gif>&nbsp;<b>给<?=$receiver?>发信 <font color="red"><? if ($status) echo $status; ?></font></b></td>
              </tr><form action="sendmail.php" method=post>
              <tr bgcolor="#FFFFFF"> 
                <td>标题： 
                  <input value="<? if ($title) echo $title; ?>" type="text" name="title" size="40" maxlength="80" style="background-color:#ffffff; color:#8888AA; border: 1 double #B4B4B4" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''">
                </td>
              </tr>
              <tr bgcolor="#EEEEEE">
                <td>内容：</td>
              </tr>
              <tr align="center" bgcolor="FFFFFF">
                <td>
                  <textarea  name="emailcontent" rows=10 wrap=hard cols=58 style="background-color:#ffffff; border: 1 double #B4B4B4" onMouseOver = "this.style.backgroundColor = '#f3f3f3'" onMouseOut = "this.style.backgroundColor = ''"><? if ($emailcontent) echo $emailcontent; ?></textarea>
                </td>
              </tr>
              <tr>
                <td bgcolor="<?=$subcolor?>">
                  <input type="submit" value="提 交" style="color: #000000; background-color: #EEEEF8; border-style: solid; border-width: 0" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='EEEEF8'">
                  <input type="reset" value="重 写" style="color: #000000; background-color: #EEEEF8; border-style: solid; border-width: 0" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='EEEEF8'">
                  <input type="hidden" value="send" name="action">
                  <input type="hidden" value="<? if (isset($target)) echo $target; ?>" name="target">

          </td>
        </tr></form>
<TABLE style=BORDER-COLLAPSE: collapse borderColor=#111111 cellSpacing=0 cellPadding=0 width=100% align=center border=0><TBODY><tr>
  <td background=images/style/bottombg.gif><P align=left><IMG height=18 src=images/style/bottomleft.gif width=2 border=0></P></td>
  <td background=images/style/bottombg.gif><P align=right><IMG height=18 src=images/style/bottomright.gif width=2 border=0></P></td>
</TBODY></tr>
</TABLE>
      </table>
<?
}
if (!empty($action) && $action=="send") {
	$temp=get_user_info($username);
	$email=$temp[3];
?>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr bgcolor=<?=$titlecolor?>>
<td background=images/style/catbg.gif>发送中</td></tr>
<tr bgcolor=#FFFFFF>
<td>
<br>
正在连接........<br>
<?
if (mail("$usermail","$title","$emailcontent","From: $email\nReply-To:$email\nX-Mailer: VIB 邮件快递")) echo "发送成功";
else echo "发送失败";
?><br></td>
</tr>
<tr bgcolor=<?=$subcolor?>>
<td> 
<div align="center">
<input type="button" onclick="javascript:history.go(-1);" value="返 回" style="color: #000000; background-color: #EEEEF8; border-style: solid; border-width: 0" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='EEEEF8'" name="button2">
</div>
</td>
</tr>
<TABLE style=BORDER-COLLAPSE: collapse borderColor=#111111 cellSpacing=0 cellPadding=0 width=100% align=center border=0><TBODY><tr>
  <td background=images/style/bottombg.gif><P align=left><IMG height=18 src=images/style/bottomleft.gif width=2 border=0></P></td>
  <td background=images/style/bottombg.gif><P align=right><IMG height=18 src=images/style/bottomright.gif width=2 border=0></P></td>
</TBODY></tr>
</TABLE>
</table>
<?
}
?>
</td>
</tr>
</table>
<? include("footer.php");
function print_err() {
global $subcolor,$titlecolor;
?>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr bgcolor=<?=$titlecolor?>>
<td background=images/style/catbg.gif>邮件程式发生错误</td></tr>
<tr bgcolor=#FFFFFF>
<td>
<br>
发生错误，您还没有登录：
<ul>
<li><a href=javascript:history.go(-1);>返回前页</a>
<li><a href=viblogin.php>现在登录</a>
</ul>
</td>
</tr>
<TABLE style=BORDER-COLLAPSE: collapse borderColor=#111111 cellSpacing=0 cellPadding=0 width=100% align=center border=0><TBODY><tr>
  <td background=images/style/bottombg.gif><P align=left><IMG height=18 src=images/style/bottomleft.gif width=2 border=0></P></td>
  <td background=images/style/bottombg.gif><P align=right><IMG height=18 src=images/style/bottomright.gif width=2 border=0></P></td>
</TBODY></tr>
</TABLE>
</table>
</td>
</tr>
</table><br>
<?
include("footer.php");
exit;
}
?>