<?php
#------------------------------------------------------#
#               本程序为zChain.net提供                 #
#                zChain论坛(ZBB)v2.00                  #
#------------------------------------------------------#
# INPUT[FORM] : $action,$bid,$tid,$sender;
# INPUT[FORM] : $f_title,$f_comment,$f_name,$f_email,$f_sendername,$f_senderemail;

require_once('bin/config.php');
require_once('bin/common.php');

require_once('core/class_forum_base.php');
CForumBase::setFileBase("$filepath");
require_once('core/base_memo_file.php');
require_once('core/class_user.php');
require_once('core/class_topic.php');

#--- Control switch ---
if($action == "sendcommit"){
 $copybar="免费论坛服务由 $hpname($hpurl) 提供　程序制作 zChain.net(http://www.zchain.net)";
 send_commit();
}else{
 send_form($bid,$tid,$sender);
}

exit;

##########
function send_form($bid,$tid,$sender)
{
 global $imgurl;

 $oTpc=new CTopic;
 if(!$oTpc->load($bid,$tid)){errorview("error topic!");}
 if($sender){
  $oUsr=new CUser; $oUsr->load($sender);
 }

 page_header('Send to a friend');

 print <<<EOT
<center>
<form ACTION="$cgiurl" METHOD="POST" align=center>
<input type="hidden" name="action" value="sendcommit">
<input type="hidden" name="bid" value="$bid">
<input type="hidden" name="tid" value="$tid">
<input type="hidden" name="f_title" value="$oTpc->title">
<TABLE width=458 class=forumLine cellSpacing=1 cellPadding=0 border=0>
<TR><TD vAlign=top width=458 colSpan=4>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TR><TD vAlign=top width=12 background="$imgurl/bckgrnd_tile.gif">&nbsp;&nbsp;</TD>
<TD vAlign=top width="100%" background="$imgurl/bckgrnd_tile.gif" colSpan=3 height=30><BR>
<FONT style="COLOR: #ffffff; LETTER-SPACING: 1mm"><B>将此页发给您的朋友</B></FONT></TD>
<TD vAlign=bottom width=71><IMG height=30 src="$imgurl/email_icon01.gif" width=70></TD>
<TD vAlign=top width=18 background="$imgurl/bckgrnd_tile.gif">&nbsp;&nbsp;&nbsp;</TD></TR>
<TR><TD vAlign=top width=12>&nbsp;&nbsp;</TD>
<TD vAlign=bottom noWrap width=370 colSpan=3>如果您认为您的朋友同样对这篇文章感兴趣的话，您只需填写几个简单的信息后点“发送”即可将此文的地址发送给您的朋友</TD>
<TD vAlign=top width=71><IMG height=31 src="$imgurl/email_icon02.gif" width=70></TD>
<TD vAlign=top width=18>&nbsp;&nbsp;</TD></TR>
</TABLE></TD></TR>
<TR><TD width=12 rowSpan=3>&nbsp;&nbsp;</TD></TR>
<TR><TD vAlign=top width=270><FONT color=#FFFFFF>注释（可选项）</FONT>
<TEXTAREA name=f_comment rows=8 wrap=hard cols=35></TEXTAREA><BR clear=all>
请您填写姓名及E-mail只是为了您的朋友方便的了解此条信息的来源！</TD>
<TD width=12>&nbsp;&nbsp;</TD>
<TD vAlign=top width=185><FONT color=#FFFFFF>您朋友的姓名</FONT>
<INPUT name=f_name><BR>
<FONT color=#FFFFFF>您朋友的E-mail地址</FONT>
<INPUT name=f_email><BR>
<FONT color=#FFFFFF>您的姓名</FONT><BR>
<INPUT name=f_sendername value="$oUsr->name"><BR>
<FONT color=#FFFFFF>您的E-mail地址</FONT>
<INPUT name=f_senderemail value="$oUsr->email"><BR>
&nbsp;&nbsp;<INPUT title=Send style="FONT-SIZE: 9pt" type=submit value=" 发送 " name=CheckSubmit>
&nbsp;<INPUT title=Cancel style="FONT-SIZE: 9pt" type=reset value=' 取消 '>
</TD></TR>
<tr><TD bgColor=3366cc colSpan=4 height=7></TD></TR></TABLE>
</form>
</center>
EOT;

 page_footer();
}

function send_commit()
{
 global $bid,$tid,$prgurl;
 global $f_title,$f_comment,$f_name,$f_email,$f_sendername,$f_senderemail;

 if(!preg_match("/.*\@.*\..*/",$f_email)){errorview("您朋友的Email输入错误！");}

 $comment=stripslashes($f_comment);
 $sendto="$f_email";
 $subject="$f_title";
 $sendfrom="$f_senderemail";
 $message="\n{$f_name}，您好！\n\n"
   ."我想您可能会喜欢看这内容的，所以我发给您这网页的链接\n\n"
   ."$prgurl/viewtopic.php?bid=$bid&tid=$tid\n\n"
   ."============================================================\n"
   ."$comment\n"
   ."============================================================\n"
   ."　　　　　　　　　　　　　　　　　　　　您的朋友：$f_sendername\n\n"
   ."$copybar\n\n\n";

 mail($sendto,$subject,$message,$sendfrom);

 page_header();

 print <<<EOT
<title>Send to a friend</title>
<body><center>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="458">
<TR><TD VALIGN="TOP" COLSPAN="4" WIDTH="458">
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">
<TR><TD VALIGN="TOP" WIDTH="12" BACKGROUND="$imgurl/bckgrnd_tile.gif">&nbsp;&nbsp;</TD>
<TD VALIGN="TOP" WIDTH="100%" BACKGROUND="$imgurl/bckgrnd_tile.gif" HEIGHT="30" COLSPAN="3"><br>
<FONT class="90v" STYLE="letter-spacing:1mm;color:#FFFFFF;"><b>谢谢使用</b></FONT></TD>
<TD VALIGN="BOTTOM" WIDTH="71"><IMG SRC="$imgurl/email_icon01.gif" HEIGHT="30" WIDTH="70"></TD>
<TD VALIGN="TOP" WIDTH="18" BACKGROUND="$imgurl/bckgrnd_tile.gif">&nbsp;&nbsp;&nbsp;</TD></TR>
<TR><TD VALIGN="TOP" WIDTH="12">&nbsp;&nbsp;</TD>
<TD NOWRAP VALIGN="BOTTOM" WIDTH="370" COLSPAN="3"></TD>
<TD VALIGN="TOP" WIDTH="71"><IMG SRC="$imgurl/email_icon02.gif" HEIGHT="31" WIDTH="70"></TD>
<TD VALIGN="TOP" WIDTH="18">&nbsp;&nbsp;</TD></TR>
</TABLE></TD></TR>
<TR><TD COLSPAN="2"><IMG SRC="$imgurl/Trans.gif" HEIGHT="80" WIDTH="1" BORDER="0"></TD></TR>
<TR><TD VALIGN="BOTTOM" ALIGN="LEFT"><IMG SRC="$imgurl/Trans.gif" HEIGHT="1" WIDTH="140" BORDER="0"><FONT class="90v"><b>您的信息已经被发送致</b><BR>
<IMG SRC="$imgurl/Trans.gif" HEIGHT="1" WIDTH="140" BORDER="0">$f_email</FONT></TD></TR>
<TR><TD><IMG SRC="$imgurl/Trans.gif" HEIGHT="77" WIDTH="280" BORDER="0"></TD>
<TD VALIGN="BOTTOM">
<INPUT TYPE="BUTTON" STYLE="font-family:宋体;font-size:9pt" VALUE=" 关闭 " OnClick="window.close();" ID="button1" NAME="button1" TITLE="Close"></TD></TR>
<TR><TD><IMG SRC="$imgurl/Trans.gif" HEIGHT="7" WIDTH="1" BORDER="0"></TD></TR>
<TR><TD HEIGHT="7" BGCOLOR="#3366CC" COLSPAN="3"></TD></TR>
</TABLE>
EOT;

 page_footer();
}

?>