<?

if (!$forumid || !file_exists("forum$forumid")) exit;
get_forum_info();

if (file_exists('datafile/admin.php')) {
	$adminlist=file('datafile/admin.php');
	$count=count($adminlist);
	for ($i=0; $i<$count; $i++) {
		$detail=explode('|', trim($adminlist[$i]));
		if ($detail[0]==$forumid) $forum_admin[]=$detail[1];
	}
}

$add_title=" &gt; $forum_name &gt; POST";
$navi_bar_des="您现在正处在<br>VIB论坛 <br>的POST程式中";
$navi_bar_l2="<a href='viblist.php?forumid=$forumid'>$forum_name</a>";

if ($login_status==0 && $step==2) {
//--------if the user is not logged in and
//--------he is trying to log in while giving the first post

	if (!($HTTP_POST_VARS["username"]) || !($HTTP_POST_VARS["password"])) {
		include("header.php");
		navi_bar($navi_bar_des,$navi_bar_l2,"发生错误");
		$status='用户名/密码 空缺，请修正';
		print_err();
		include("footer.php");
		exit;
	}	
	//$username=$HTTP_POST_VARS["username"];//$password=$HTTP_POST_VARS["password"];

	if (!checkpass($username,$password)) {
		include("header.php");
		navi_bar($navi_bar_des,$navi_bar_l2,"发生错误");
		$status="用户名/密码 错误，请修正";
		print_err();
		include("footer.php");
		exit;
	}	

	$vibid=$username;
	session_register("vibid");
	//$vibpwd=$password; session_register("vibpwd");

	$login_status=1;
	getUserInfo();
}

if ($login_status==1 && !check_permission($username,$forum_type)) {
//---to check if the user have got the permission to post-------
	include("header.php");
	navi_bar($navi_bar_des,$navi_bar_l2,"发生错误");
	$status="你没有权利在此版块发贴，如果有问题请向管理员咨询";
	print_err();
	include("footer.php");
	exit;
}

$panelbar="
<!-- Panel bar -->
<table cellspacing=0 width=500 cellpadding=0 bgcolor=$bordercolor>
  <tr><td>
   <table cellspacing=1 cellpadding=3 width=100%>
    <tr><td bgcolor=EEEEEE>
     <b>辅助面板</b>： [ <a href='editor/panel1.htm' target=fontpanel><font color=333366>字体属性面板</font></a> -
     <a href='editor/panel2.htm' target=fontpanel><font color=333366>字体特效面板</font></a> -
     <a href='editor/panel3.htm' target=fontpanel><font color=333366>ASCII图案生成面板</font></a> ] - 点击切换<br>
     <hr size=1>
     <iframe name='fontpanel' frameborder=0 src='editor/panel1.htm' width=100% height=30></iframe>
    </td></tr>
  </table>
 </td></tr>
</table>
<img src='' height=5><br>
<!-- Panel bar end -->
";

$vibemote='
<tr align=left> 
  <td><img src="images/icons/vib1.gif" height=20 onClick="javascript:AddText(\'[vib1]\');">
  <img src="images/icons/vib2.gif" height=20 onClick="javascript:AddText(\'[vib2]\');">
  <img src="images/icons/vib3.gif" height=20 onClick="javascript:AddText(\'[vib3]\');">
  <img src="images/icons/vib4.gif" height=20 onClick="javascript:AddText(\'[vib4]\');">
  <img src="images/icons/vib5.gif" height=20 onClick="javascript:AddText(\'[vib5]\');">
  <img src="images/icons/vib6.gif" height=20 onClick="javascript:AddText(\'[vib6]\');">
  <img src="images/icons/vib7.gif" height=20 onClick="javascript:AddText(\'[vib7]\');">
  <img src="images/icons/vib8.gif" height=20 onClick="javascript:AddText(\'[vib8]\');">
  <img src="images/icons/vib9.gif" height=20 onClick="javascript:AddText(\'[vib9]\');">
  <img src="images/icons/vib10.gif" height=20 onClick="javascript:AddText(\'[vib10]\');">
  <img src="images/icons/vib11.gif" height=20 onClick="javascript:AddText(\'[vib11]\');">
  <img src="images/icons/vib12.gif" height=20 onClick="javascript:AddText(\'[vib12]\');">
  <img src="images/icons/vib13.gif" height=20 onClick="javascript:AddText(\'[vib13]\');">
  <img src="images/icons/vib14.gif" height=20 onClick="javascript:AddText(\'[vib14]\');">
  <img src="images/icons/vib15.gif" height=20 onClick="javascript:AddText(\'[vib15]\');">
  <img src="images/icons/vib16.gif" height=20 onClick="javascript:AddText(\'[vib16]\');">
  <img src="images/icons/vib17.gif" height=20 onClick="javascript:AddText(\'[vib17]\');">
  <img src="images/icons/vib18.gif" height=20 onClick="javascript:AddText(\'[vib18]\');">
  <img src="images/icons/vib19.gif" height=20 onClick="javascript:AddText(\'[vib19]\');">
  <img src="images/icons/vib20.gif" height=20 onClick="javascript:AddText(\'[vib20]\');">
  <img src="images/icons/vib21.gif" height=20 onClick="javascript:AddText(\'[vib21]\');">
  </td>
</tr>';

/*$postjs=<<<EOT
<script language="JavaScript1.2">
<!--
helpstat = false;
stprompt = true;
basic = false;
clckcnt = 0;
var postmaxchars = $max_post_length;

function clckcntr() {
clckcnt++;
if(clckcnt > 1) {
	if(clckcnt > 2) { return false; }
	alert('贴子已经发出了......\n\n' + '请等待片刻......\n\n' + '不要重复按提交键，谢谢！');
	return false;
}
return true;
}

function thelp(swtch){
if (swtch == 1){
	basic = false;
	stprompt = false;
	helpstat = true;
	} else if (swtch == 0) {
		helpstat = false;
		stprompt = false;
		basic = true;
	} else if (swtch == 2) {
		helpstat = false;
		basic = false;
		stprompt = true;
	}
}

function AddText(NewCode) {
document.FORM.articlecontent.value+=NewCode
}
function validate(theform) {
	if (theform.articletitle.value=="" || theform.articlecontent.value=="") {
		alert("请完成标题和内容栏目.");
		return false; }
	if (postmaxchars != 0) {
		if (theform.articlecontent.value.length > $max_post_length) {
			alert("你的信息太长了.\n\n请限制在 $max_post_length 字节以内.\n当前已有 "+theform.articlecontent.value.length+" 字节.");
			return false; }
		else { return true; }
	} else { return true; }
}
function checklength(theform) {
	if (postmaxchars != 0) { message = "\n最大的字符为 $max_post_length 字节."; }
	else { message = ""; }
	alert("你的信息已经有 "+theform.articlecontent.value.length+" 字节."+message);
}

//-->
</script>
EOT;
*/

$loginform=<<<EOT
<tr bgcolor=FFFFFF>
<td><b>你的用户名</b>：</td>
<td colspan=2>
<input maxlength=25 size=25 name=username style="background-color:#ffffff; border: 1 double #B4B4B4" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''">
</td>
</tr>
<tr bgcolor=EEEEEE> 
<td><b>你的密码：</b><br>
<a href="sendpwd.php" target=_blank>忘了密码?</a></td>
<td colspan=2> 
<input maxlength=25 size=25 name=password type=password style="background-color:#ffffff; border: 1 double #B4B4B4" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''">
</td>
</tr>
EOT;

//+------------------------------------------------------------------------------------------------------
//---------Flood Control-------------------
function flood_limit($name,$limit) {
global $admin_name,$forum_admin,$timestamp;
  if ($name==$admin_name) return 1;
  if ($forum_admin && in_array($name,$forum_admin)) return 1;
  $userdata=get_user_info($name);
  if ($timestamp-$userdata[11]>=$limit) return 1;
  return 0;
}
//+------------------------------------------------------------------------------------------------------
//---------Display the Error Message Table-------------------
function print_err() {
global $status;
msg_box("发生错误","POST程式发生了错误，情况：<br><br>$status<br><ul><li><a href='javascript:history.back(1)'>返回前一页</a></li></ul>");
}

//+------------------------------------------------------------------------------------------------------
//---------Change certain information-------------------
function send_suc(){
global $timestamp,$username,$forumid,$articletitle,$filename,$id_unique;

	// change the information in last_mo.php
	if (file_exists("forum$forumid/last_mo.php")) {
		$filecc=readfromfile("forum$forumid/last_mo.php");
		$temp=explode('|',$filecc);
		$art_count=$temp[1];
	}
  	else $art_count=0;
	$art_count++;
	$use_date=get_date($timestamp).' '.get_time($timestamp);
	$new_line="$articletitle,$username,$use_date,$filename|$art_count";
	writetofile("forum$forumid/last_mo.php",$new_line);

	// change user's data
	$useri=get_user_info($username);
	$useri[11]=$timestamp;
	$useri[12]++;
	$uu=implode('|',$useri);
	writetofile("$id_unique/$username",$uu);

	// change the information in newuser.php
	$newuser=readfromfile('datafile/newuser.php');
	$newuser_detail=explode('|',$newuser);
	$newuser_detail[2]++;
	writetofile('datafile/newuser.php',"$newuser_detail[0]|$newuser_detail[1]|$newuser_detail[2]");
}

//+------------------------------------------------------------------------------------------------------
//---------Check data-------------------
function check_data($type="post") {
global $articlecontent,$max_post_length,$articletitle,$status,$articledes,$selections,$title,$by,$address,$downaddress,$file_size,$logourl;
	$check=1;
	if (strlen($articlecontent)>=$max_post_length) {$status="文章超过管理员指定的长度"; $check=0;}
	if (empty($articletitle)) {$status="没有填写标题"; $check=0;}
	elseif (strlen($articletitle)>=80) {$status="标题太长了"; $check=0;}
	if (strlen($articledes)>=80) {$status="文章描述太长了"; $check=0;}
	if ($type=="vote" && empty($selections)) {$status="不接受空选项"; $check=0;}
	if ($type=="ucom") {
		if (empty($title)) {$status="没有填写U-推荐名称"; $check=0;}
		if (empty($address)) $address="";
		if (empty($by)) $by="";
		if (empty($downaddress)) $downaddress="";
		if (empty($file_size)) $file_size="";
		if (empty($logourl)) $logourl="";
		if (strlen($title)>100) {$status="U-推荐名称太长"; $check=0;}
		if (strlen($file_size)>25) {$status="填写大小特性怎么会超过25个字符？"; $check=0;}
		if (strlen($by)>50) {$status="作者超长"; $check=0;}
		if (strlen($address)>70) {$status="网址超过规定长度"; $check=0;}
		if (strlen($downaddress)>70) {$status="下载地址超过规定长度"; $check=0;}
		if (strlen($logourl)>60) {$status="图片连接地址超长"; $check=0;}
	}

	return $check;
}
//+------------------------------------------------------------------------------------------------------
//--------Send HTML mails-------------------
function send_HTML_mail() {
global $bbs_title,$send_user_info,$lm_detail,$script_pos,$forumid,$filename;
$message="<html><head><style type='text/css'><!-- option, textarea, input {   FONT-FAMILY:verdana,arial;color:#000000; FONT-SIZE: 12px; } table,select{font-size: 9pt ; color:#333333; } a {color:#333333;font-size: 9pt;text-decoration:none; } a:hover {text-decoration:overline underline;} a:active {color:#FF6699;} --></style><title>VIB 论坛快递</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'></head><body bgcolor='#FFFFFF'>
<table width='450' border='0' cellspacing='1' cellpadding='1' align='center' bgcolor='BBBBBB'>
<tr><td><table width='100%' border='0' cellspacing='0' cellpadding='1' bgcolor='#FFFFFF'><tr> <td bgcolor='9bacdc'>{$bbs_title} -&gt; 您有回复:</td>
</tr><tr> <td>&nbsp;</td></tr><tr> <td>&nbsp;Hello, $send_user_info[0] , 您好</td></tr><tr> <td>&nbsp;</td></tr><tr> <td>&nbsp;这里是VIB邮件快递</td></tr><tr> <td>&nbsp;</td></tr><tr> <td>&nbsp;你在{$bbs_title}发的文章: $lm_detail[0]</td>
</tr><tr> <td>&nbsp;现在有人回复喽.快来看吧</td></tr><tr> <td>&nbsp;</td></tr><tr> <td>&nbsp;<a href='{$script_pos}vibread.php?forumid=$forumid&filename=$filename' target=_blank>{$script_pos}vibread.php?forumid=$forumid&filename=$filename</a></td></tr><tr> <td>&nbsp;</td>
</tr><tr> <td>&nbsp;下次再有人参与主题时,我将不来打扰了</td></tr><tr><td>&nbsp;</td></tr></table></td></tr></table><br><table width=500 border=0 align='center'><tr><td><center>本论坛由<a href='mailto:vieky990@sina.com'>Vieky</a>制作｜ &copy; 2003<br>
欢迎到<a href='http://gaming.ximan.com'>『游戏永远』</a>来<br><table width='146' border='0' cellspacing='0' cellpadding='1' height='17' bgcolor='#CCCCCC'><tr> <td> <table width='144' border='0' cellspacing='0' cellpadding='0' bgcolor='000066'><tr align='center'> <td width='34' bgcolor='#FFFFFF'></td>
</tr></table></td></tr></table></center></td><td align=right width=236><font face='Verdana' color='#111166'>Powered by Vieky.</td>
</tr></table></html>";
	include 'mime.class';
	$to=$send_address;
	$str = '你有回复~~~';
	$mime = new MIME_mail("$admin_email", "$send_address", "$str");
	$mime->attach($message, '', HTML, BASE64);
	$mime->attach($textmessage, '', TEXT, QP);
	$mime->send_mail();
}