<?

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

include("datafile/usertitle.php");

if (!$forumid || !file_exists("forum$forumid")) exit;
if (!$filename || !file_exists("forum$forumid/$filename") || !ereg("^f_[0-9]+$",$filename) || !file_exists("forum$forumid/list.php")) 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]));
		$forum_admin[]=$detail[1];
	}
}

$articlelist=file("forum$forumid/$filename");
list($topic_name,$topic_author,$topic_content,$topic_date,$topic_area)=explode("|",$articlelist[0]);
$topic_name=str_replace('%a%','',$topic_name);
$topic_date=getfulldate($topic_date);
$add_title=" &gt; $forum_name &gt; $topic_name";

$list_temp=explode("\n",readfromfile("forum$forumid/list.php"));

$count=count($list_temp);
for ($i=0; $i<$count; $i++) {
	$list_info=explode("|",$list_temp[$i]);
	if ($list_info[5]==$filename) {
		$topic_hit = $list_info[7];
		$topic_reply = $list_info[6];
		$topic_islock= $list_info[9];
		$topic_type = trim($list_info[10]);
		$list_info[7]++;
		$list_temp[$i]=implode("|",$list_info);
		if ($i>0) { $pre  = explode("|",$list_temp[$i-1]); $pretitle=$pre[0]; $prefile=$pre[5]; }
		if ($list_temp[$i+1]) { $next = explode("|",$list_temp[$i+1]); $nexttitle=$next[0]; $nextfile=$next[5];}
		break;
	}
}

writetofile("forum$forumid/list.php",implode("\n",$list_temp));
//unset($list_temp);

require("header.php");

$des="您正阅读的主题 <br>已经被阅读 <b class=cau>$topic_hit</b> 次<br>并有回复贴 <b class=cau>$topic_reply</b> 篇";
navi_bar($des,"<a href='viblist.php?forumid=$forumid'>$forum_name</a>",$topic_name);

if (!$page) $page=1;

if ($page==1) 
switch($topic_type) {
	case "1": get_sta(); break;
	case "2": get_u(); break;
	case "4": get_sta(); break;
	case "5": get_u(); break;
}

$count=count($articlelist);
if ($count%$read_perpage==0) $maxpageno=$count/$read_perpage;
	else $maxpageno=floor($count/$read_perpage)+1;
if ($page=="last" || $page>$maxpageno) $page=$maxpageno;
$pagemin=min( ($page-1)*$read_perpage , $count-1);
$pagemax=min( $pagemin+$read_perpage-1, $count-1);

if ($maxpageno>1){
	$multi_page_bar="[ <b>";
	$nextpage=$page+1;
	$previouspage=$page-1;
	if ($page>1) $multi_page_bar.="<a href=\"vibread.php?forumid=$forumid&filename=$filename&page=$previouspage\">←</a> ";
	else $multi_page_bar.="← ";
	if ($page<=$maxpageno-1) $multi_page_bar.="<a href=\"vibread.php?forumid=$forumid&filename=$filename&page=$nextpage\">→</a> ";
	else $multi_page_bar.="→ ";

	for ($i=1; $i<=$maxpageno; $i++) {
		if ($i!=$page) 
		$multi_page_bar.=" <a href=\"vibread.php?forumid=$forumid&filename=$filename&page=$i\"><b>$i</b></a>";
		if ($i==50) {$multi_page_bar.="... <a style='color:333366' href=\"viblist.php?forumid=$forumid&page=last\">Last</a>"; break;}
	}
	$multi_page_bar.="</b> 页]";
}

print <<<EOT
<table width=$tablewidth border=0 cellspacing=0 cellpadding=1 align=center>
  <tr align=right> 
    <td align=left>
    <a href="vibpost.php?forumid=$forumid"><img src="images/system/newthread.gif" border=0></a>
    <a href="vibpost.php?action=reply&forumid=$forumid&filename=$filename"><img alt=回复贴子 src='images/system/reply.gif' border=0></a></td>
    <td align=right>
    $multi_page_bar
    </td>
  </tr>
</table>
EOT;

sline();

print <<<EOT
<table cellspacing=0 cellpadding=0 width=$tablewidth align=center border=0>
 <tr>
 <td valign=center width=1 bgcolor=$bordercolor height=22></td>
 <td valign=center align=left width=* bgcolor=$titlecolor background=images/style/catbg.gif>
 	<table cellspacing=1 cellpadding=0 width=100% border=0>
 	<tr bgcolor=$titlecolor>
 	<td background=images/style/catbg.gif valign=center align=left>&nbsp;
EOT;

if ($topic_type%3==0) echo "<b>* 本页主题</b>： $topic_name</td>";
	else echo "<b>* 跟随意见贴</b>";
echo "<td width=130 align=right background=images/style/catbg.gif>";
if (isset($prefile)) echo "<a href=\"vibread.php?forumid=$forumid&filename=$prefile\"><img src=\"images/system/prethread.gif\" alt=\"上一个主题：$pretitle\" border=0></a> ";
if (isset($nextfile)) echo "<a href=\"vibread.php?forumid=$forumid&filename=$nextfile\"><img src=\"images/system/nextthread.gif\" alt=\"下一个主题：$nexttitle\" border=0></a>";

echo "&nbsp;</td>
</tr>
</table>
</td>
<td valign=center width=1 bgcolor=$bordercolor height=22></td>
</tr>
</table>";

sline();

for ($i=$pagemin; $i<=$pagemax; $i++) {
	if ($topic_type % 3!=0 && $i==0) continue;
	if ($i%2==0) $bgcolor=$article_color1;
		else $bgcolor=$article_color2;
	
	list($title,$author,$content,$time,$area,$icon,$usesign)=explode("|",$articlelist[$i]);
	
	if (!$i) $title=str_replace('%a%','<img src="images/system/addon.gif" border=0>',$title);
	if (!$print_info[$author]) {
		list($print_info[$author],$bar[$author])=view_user_info($author);
	}
	if (!$topic_islock) $bar_add=
	"&nbsp;<a href='vibpost.php?action=quote&forumid=$forumid&filename=$filename&article=$i'><img height=19 alt=引用回复这个贴子 src='images/style/quote.gif' width=63 border=0></a>&nbsp;<a href='vibpost.php?action=reply&forumid=$forumid&filename=$filename'><img height=19 alt=回复这个贴子 src='images/style/replynow.gif' width=63 border=0></a><br>";

	$time=getfulldate($time);
	$bottombar="<a href='vibpost.php?action=modify&forumid=$forumid&filename=$filename&article=$i'><img src='images/style/edit.gif' width=63 height=19 border=0 alt=修改这个贴子></a> <input type=text name=T1 size=45 style=border-style: solid; border-color: #425C9B value='发表于 $time | 来自：$area'>";
	if ($i!=0) $bottombar.=" <a href='vibmanage2.php?action=del&forumid=$forumid&filename=$filename&article=$i'><img src='images/style/del.gif' width=63 height=19 border=0 alt=删了这个贴子></a>";
	if ($icon=="ran") $icon=mt_rand(0,25).".gif";
	$titleline="<tr><td valign=top align=left width=32><img height=13 src='images/emotion/$icon' width=13 align=left border=0></td><td style='LEFT: 0px; WIDTH: 100%; WORD-WRAP: break-word'><font color=#555555>$title</font></td><td width=16></td></tr>";
	$contentline="<tr><td colspan=3>".vibconvert($content,$vibcode_post);
	if ($usesign==1 && !empty($sign)) $contentline.="<HR align=left width=\"50%\" color=#777777 SIZE=1>".vibconvert($sign[$author],$vibcode_sign);
	$contentline.="</td></tr>";
	showarticle($print_info[$author],$bar[$author].$bar_add);
}
if ($multi_page_bar) { print
"<br><table cellspacing=0 cellpadding=0 width=$tablewidth align=center>
<tr><td>
$multi_page_bar
</td></tr>
</table>
";
}
?>
<TABLE style=BORDER-COLLAPSE: collapse borderColor=#111111 cellSpacing=0 cellPadding=0 width=95% 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>
<br>
<table cellspacing=0 cellpadding=0 width=<?=$tablewidth?> align=center bgcolor="#EEEEEE">
 <form name=jump method=post>
  <tr>
    <td width="70%">&nbsp;<b>管理选项：</b>
<?
if ($login_status==1 && (($forum_admin && in_array($username,$forum_admin)) || $username==$admin_name ) ) {
	if ($topic_islock==0) echo "[<a href='vibmanage.php?action=lock&forumid=$forumid&filename=$filename'>加锁</a>] ";
		else echo "[<a href='vibmanage.php?action=unlock&forumid=$forumid&filename=$filename'>解锁</a>] ";
	echo "[<a href='vibmanage.php?action=del&forumid=$forumid&filename=$filename'>删除</a>]
[<a href='vibmanage.php?action=move&forumid=$forumid&filename=$filename'>移动</a>]
[<a href='vibmanage.php?action=copy&forumid=$forumid&filename=$filename'>复制</a>]
[<a href='vibmanage2.php?action=btfront&forumid=$forumid&filename=$filename'>提前</a>] ";
	if ($topic_type>=3) echo "[<a href='vibmanage2.php?action=unhold&forumid=$forumid&filename=$filename'>取消置顶</a>]";
		else echo "[<a href='vibmanage2.php?action=holdfront&forumid=$forumid&filename=$filename'>置顶</a>]";
} else {
	echo " 对不起，未登录用户 或 未授权用户 无法使用管理功能";
}
?>
    <td valign=center noWrap align=right width=30%>
      <script language=JavaScript>
<!-- 
function menu(){
var URL = document.jump.jumpto.options[document.jump.jumpto.selectedIndex].value;
top.location.href = URL; target = '_self';
}
// -->
</script>
        <select onChange=menu() name=jumpto>
<?
$count=count($forumlist)-1;
for ($i=0; $i<=$count; $i++) {
	$forum_list_info=explode("|",$forumlist[$i]);
	if ($forum_list_info[0]=="category") echo "<OPTION target=\"_self\" value=\"viboard.php\">$forum_list_info[1]";
		else echo "<OPTION target=\"_self\" value=\"viblist.php?forumid=$forum_list_info[3]\">&nbsp;&nbsp;|-$forum_list_info[1]";
}
?>
</option>
        </select>
    </td>
  </tr></form>
</table>
<img src='' width=9 height=8><br>
<script language="JavaScript1.2">
<!--
helpstat = false;
stprompt = true;
basic = false;
clckcnt = 0;
var postmaxchars = <?=$max_post_length?>;
ie = (document.all)? true:false
if (ie){
function ctlent(eventobject){if(event.ctrlKey && window.event.keyCode==13){this.document.FORM.submit();}}
}
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("请完成标题和内容栏目.");
clckcnt=0;
return false; }
if (postmaxchars != 0) {
if (theform.articlecontent.value.length > <?=$max_post_length?>) {
alert("你的信息太长了.\n\n请限制在 <?=$max_post_length?> 字节以内.\n当前已有 "+theform.articlecontent.value.length+" 字节.");
clckcnt=0;
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>
<table cellspacing=0 cellpadding=0 width=<?=$tablewidth?> align=center bgcolor=<?=$bordercolor?> border=0> 
<tr>
<td height=1></td>
</tr>
</table>
<table cellspacing=0 cellpadding=0 width=<?=$tablewidth?> align=center border=0>
<tr>
<td valign=center width=1 bgcolor=<?=$bordercolor?> height=22></td>
<td valign=center align=left width=* background=images/style/catbg.gif>
<table cellspacing=1 cellpadding=0 width=100% border=0>
<tr bgcolor=<?=$titlecolor?>>
<td valign=center align=left background=images/style/catbg.gif>&nbsp;<b>-=&gt; 快速回复贴子</b>
</td>
</tr>
</table> 
</td>
<td valign=center width=1 bgcolor=<?=$bordercolor?> height=22></td>
</tr>
</table>
<table cellspacing=0 cellpadding=0 width=<?=$tablewidth?> align=center bgcolor=<?echo"$bordercolor";?> border=0>
<tr>
<td height=1></td>
</tr>
</table>
<table cellspacing=0 cellpadding=0 width=<?=$tablewidth?> align=center border=1 bordercolor=<?echo"$bordercolor";?>>
<tr>
<td bgcolor=<? if ($bgcolor==$article_color1) $bgcolor=$article_color2; else $bgcolor=$article_color1;echo"$bgcolor";?>>
<table cellspacing=0 cellpadding=4 width=100% height="100%" bgcolor=<?echo"$bgcolor";?>>
<tr>
<td valign=top width=20% bgcolor=<?=$bgcolor?> rowspan=2 align="center"> 
<br>
<b>文章内容</b>：<br>
<br>
HTML 代码不可用 <br> 
<b class=cau><a href="javascript:openScript('vibfaq.php',700,500)"><font face="Courier New, Courier">VIB Code</font></a></b> 开放<br> 
点击 <a href="javascript:openScript('vibfaq.php',700,500)"><b>这里</b></a> 
看使用方法 <br> 
<b>VIB代码选项</b>：<br>
<font face=verdana>
<? 
echo '[img]   -'; 
if ($vibcode_post['pic']) echo ' 
</font> 开启<font face=verdana>'; else echo ' 
</font> 关闭<font face=verdana>'; 
echo '<br>[flash] -'; 
if ($vibcode_post['flash']) echo ' 
</font> 开启<font face=verdana>'; else echo ' 
</font> 关闭<font face=verdana>'; 
echo '<br>[size]  -'; 
if ($vibcode_post['fontsize']) echo ' 
</font> 开启<font face=verdana>'; else echo ' 
</font> 关闭<font face=verdana>'; 
?>
</font> <br>
</td>
<td width=* bgcolor=<?echo"$bgcolor";?> height=100% rowspan=2>
<table height=100% cellspacing=0 cellpadding=0 width=1 bgcolor=<?echo"$bordercolor";?>>
<tr>
<td width=1></td>
</tr>
</table>
</td>
<td width=* bgcolor=<?echo"$bgcolor";?> rowspan=2> 
<script>
function DoTitle(addTitle) {
var revisedTitle;
var currentTitle = document.FORM.articletitle.value;
revisedTitle = currentTitle+addTitle;
document.FORM.articletitle.value=revisedTitle;
document.FORM.articletitle.focus();
return; }
function DoComments(addTitle) { 
var revisedTitle; 
var currentTitle = document.FORM.articlecontent.value; revisedTitle = currentTitle+addTitle; document.FORM.articlecontent.value=revisedTitle; document.FORM.articlecontent.focus(); 
return; 
}
</script>
<form name="FORM" method="post" action="vibpost.php" onSubmit="return validate(this)" enctype="multipart/form-data">
<br>
标题: 
<input type="text" name="articletitle" value="回复:<?=$topic_name ?>" size="35" maxlength="45" style="background-color:#ffffff; border: 1 double #B4B4B4" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''"><br>
<textarea onkeydown=ctlent() name="articlecontent" cols="90" rows="6" style="background-color:#F0F0f3; border: 1 double #B4B4B4"></textarea>
              <br>
<input type=hidden value=2 name=step>
<input type=hidden value="reply" name=action> 
<input type=hidden value=<?=$forumid?>  name=forumid> 
<input type=hidden value="<?=$filename?>" name=filename>
<?if ($login_status==0) { 
?> 
昵称: 
<input type=text name=username maxlength=25 size=12 style="background-color:#ffffff; border: 1 double #B4B4B4" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''">
密码:  
<input onkeydown=ctlent() type=password name=password maxlength=25 size=12 style="background-color:#ffffff; border: 1 double #B4B4B4" onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''">
<? } ?> 
<input onclick="return clckcntr();" type="submit" value="发 表" style="height:20px;background-color:#f3f3f3;border:1 solid black" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='#f3f3f3'"> 
<input type="reset" value="重 写" style="height:20px;background-color:#f3f3f3;border:1 solid black" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='#f3f3f3'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;可按 [CTRL]+[ENTER] 直接发表
</form>
<form name=preview action="preview.php" method=post target="preview_page">
<input type=hidden name=nhtitle value=""><input type=hidden name=nhbody value="">
</form>
</td>
</tr>
</table>
</td>
</tr>
<TABLE style=BORDER-COLLAPSE: collapse borderColor=#111111 cellSpacing=0 cellPadding=0 width=95% 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>

<? require("footer.php");
function showarticle($print_info,$bar) {
global $bgcolor,$bottombar,$titleline,$contentline,$bordercolor,$tablewidth;
print <<<EOT
<table cellspacing=0 cellpadding=0 width=$tablewidth align=center border=1 bordercolor=$bordercolor>
<tr>
<td bgcolor=$bgcolor>
<table cellspacing=0 cellpadding=4 width=100% bgcolor=$bgcolor>
<tr>
<td valign=top width=20% bgcolor=$bgcolor rowspan=2>$print_info</td>
<td width=1 bgcolor=$bgcolor height=100% rowspan=2>
<table height=100% cellspacing=0 cellpadding=0 width=1 bgcolor=$bordercolor><tr><td width=1></td></tr></table>
</td>
<td valign=top width=* bgcolor=$bgcolor height=100%>$bar
<hr width=100% color=$bordercolor size=1>
<table cellspacing=0 cellpadding=0 width=100% style="WORD-WRAP: break-word">
$titleline $contentline
</table>
</td>
</tr>
<tr>
<td valign=bottom bgcolor=$bgcolor><hr width=100% color=$bordercolor size=1>$bottombar</td></tr>
</table>
</td>
</tr>
</table>
EOT;
}
function sline() {
global $bordercolor,$tablewidth;
print(
"<table cellspacing=0 cellpadding=0 width=$tablewidth align=center bgcolor=$bordercolor border=0><tr><td height=1></td></tr></table>");
}

function view_user_info($author) {
global $id_unique,$sign;
	if (file_exists("$id_unique/$author")) { //----已注册----
	list($id,$pwd,$usericon,$useremail,$oicq,$regdate,
	     $sign[$author],$homepage,$from,$com,$honor,
	     $lp,$amount,$publicemail)
	= explode("|",readfromfile("$id_unique/$author"));
	
	$userlevel=getUserLevel($amount,$id);
	$userIcon=getUserIcon($amount,$id);
	$nextlevel=getNextLevel($amount,$id);

	$regdate=get_date($regdate);
	$usericon=get_user_portait($usericon);
	$email="<a href='sendmail.php?target=$target'>$email</a>";

	$print_info="<TABLE style='FILTER: glow(color=#FFFF99,strength=4)'><FONT color=#000066><i>$author</i></FONT></TABLE>&nbsp;$usericon<br>";
	$print_info.="&nbsp;<img src='images/system/".$userIcon."'><br>";
	if ($honor) $print_info.="&nbsp;&nbsp;".$honor."<br>";
	$print_info.=
	"&nbsp;当前等级：$userlevel<br>
	&nbsp;<font color=#555555>升级所需的贴数：<b>$nextlevel</b> 贴</font><br>
	&nbsp;来自：$from<br>
	&nbsp;<font color=#555555>已经发了：<b>$amount</b> 贴</font><br>
	&nbsp;出道时间：$regdate<br>";
	$bar="&nbsp;<a href='vibprofile.php?job=show&target=$author'><img height=19 alt=查看该用户的个人资料 src='images/style/profile.gif' width=63 border=0></a>&nbsp;<a onclick='Show(messanger);' href='messanger.php?job=write&target=$author' target=msg><img src='images/style/message.gif' width=63 height=19 border=0 alt=给该用户发送短讯></a>";
	if (!empty($publicemail)) $bar.="&nbsp;<a href='mailto:$useremail'><img src='images/style/email.gif' border=0 width=63 height=19 alt=给该用户发一封邮件></a>";
	if ($oicq) $bar.="&nbsp;<a href=http://search.tencent.com/cgi-bin/friend/user_show_info?ln=$oicq target=_blank><img src='images/style/oicq.gif' alt='看看 QQ:$oicq 的资料' border=0 width=63 height=19></a>";
	if ($homepage) {
		if (strpos($homepage,"://")===false) $homepage="http://$homepage";
		$bar.="&nbsp;<a href=$homepage target=_blank><img src=images/style/homepage.gif border=0 width=63 height=19 alt=访问{$id}的主页></a>";
	}
	} else { //---未注册---
		$print_info="<TABLE style='FILTER: glow(color=#FFFF99,strength=4)'><FONT color=#000066><B>$author</B></FONT></TABLE>";
		$print_info.="<BR>&nbsp--未注册用户--";
		$bar="&nbsp;";
	}
	return array($print_info,$bar);
}

function get_sta() {
global $forumid,$filename,$addhead,$username,$login_status,$username,
$bgcolor,$bordercolor,$titlecolor,$topic_author,$topic_name,$topic_date,
$topic_content,$topic_area,$print_info,$bar;

	if (!file_exists("forum$forumid/$filename.sta")) return;
	list($print_info[$topic_author],$bar[$topic_author])=view_user_info($topic_author);

	$sta_data=file("forum$forumid/$filename.sta");
	$detail=explode("|",$sta_data[0]);
	$vote_sel=explode("|",$sta_data[1]); $pic=""; $amountsum=0;
	$count=min(count($vote_sel),6);
	for ($i=0; $i<$count; $i++) {
		list($name[$i],$amount[$i]) =explode(",",$vote_sel[$i]);
		$amountsum+=$amount[$i];
	}
	$zero=0;
	if ($amountsum==0) {$zero=1; $amountsum=1;}

	if ($detail[0]=="pie") {

		$clrLst=array("777799","8ad500","eed805","FF0000","e46101","333366");
		$pic="<img src=\"votepie.php?forumid=$forumid&filename=$filename\" align=left>";
		$pic.="<table>";
		for ($i=0; $i<$count; $i++) {
			$pic.="<tr><td align=right><font color=$clrLst[$i]><b>$name[$i]</b></font>：</td><td align=left width=40>&nbsp;<b>$amount[$i]</b> 票</td></tr>";
		}
		$pic.="</table>";

	}elseif ($detail[0]=="bar") {

		$pic.="<table>";
		for ($i=0; $i<$count; $i++) {
			$width=floor(300*$amount[$i]/$amountsum);
			$pic.="<tr><td align=right>&nbsp;$name[$i] ：</td><td><img src=\"images/system/bar".($i+1).".gif\" width=$width height=10>&nbsp;{$amount[$i]} 票</td>";
		}
		$pic.="</table>";
	}

	if ($zero==1) $amountsum=0;
	$picinfo="总共有 <b style=\"font-family:verdana\">$amountsum</b> 人参与本次投票 发起于 $topic_date 鉴定：$topic_area";

	$status="";
	if ($login_status==1) {
		if (strpos($sta_data[0],"|$username|")!==false) {
			$status="&nbsp;* <b>您已经参与了这次投票</b>";
		}
		else {
			for ($i=0; $i<$count; $i++) {
				list($selectionname) =explode(",",$vote_sel[$i]);
				$status.=("※ <input type=radio value=$i name=mychoice>$selectionname ");
			}
			$status.="<input type=hidden value=\"$forumid\" name=forumid><input type=hidden value=\"$filename\" name=filename>";
			$status.="<input type=\"submit\" value=\"我也投\" style=\"height:20px;background-color:#f3f3f3;border:1 solid black\" onMouseOver=\"this.style.backgroundColor='#FFC864'\" onMouseOut =\"this.style.backgroundColor='#f3f3f3'\">";
		}
	}
	else $status="&nbsp;* <b>对不起，您还未登录，无法参与投票</b>";
print <<<EOT
<table bgcolor=$bordercolor border=0 cellpadding=0 cellspacing=1 width=600 align=center>
 <form action=vote.php method=post>
 <tr bgcolor=FFFFFF><td>
  <table border=0 cellpadding=1 cellspacing=0 width=100%>
   <tr height=22 bgcolor=$titlecolor><td background=images/style/catbg.gif>&nbsp;<b>* 投票：</b>$topic_name</td></tr>
   <tr height=1 bgcolor=$bordercolor><td></td></tr>
   <tr>
    <td>
     <table width=100% align=center>
      <tr>
       <td width=25% valign=top rowspan=3>$print_info[$topic_author]</td>
       <td width=70% style="WORD-WRAP: break-word">
EOT;
echo vibconvert($topic_content,$vibcode_post);
print <<<EOT
        <hr width=100% color=$bordercolor size=1>
       </td>
       <td width=5% rowspan=3></td>
      </tr>
      <tr bgcolor=#EEEEF8 height=100><td>$pic</td></tr>
      <tr height=*><td><hr width=100% color=$bordercolor size=1>$picinfo</td></tr>
     </table>
    </td>
   </tr>
   <tr bgcolor=$bordercolor height=1><td></td></tr>
   <tr height=22 bgcolor=FFFFFF><td>$status</td></tr>
  </table></td>
 </tr>
 </form>
</table>
<TABLE style=BORDER-COLLAPSE: collapse borderColor=#111111 cellSpacing=0 cellPadding=0 width=600 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>
<br>
EOT;
}

function get_u() {
global $forumid,$filename,$addhead,$username,$login_status,$username,$bgcolor,$bordercolor,$titlecolor,$topic_author,$topic_name,$topic_date,$id_unique,$topic_content,$topic_area;
	if (!file_exists("forum$forumid/$filename.u")) return;

global $print_info,$bar;
	list($print_info[$topic_author],$bar[$topic_author])=view_user_info($topic_author);

	$u_data=file("forum$forumid/$filename.u");
	for ($i=0; $i<5; $i++) $u_data[$i]=str_replace("\n","",$u_data[$i]);
print <<<EOT
<table bgcolor=$bordercolor border=0 cellpadding=0 cellspacing=1 width=600 align=center>
 <tr bgcolor=FFFFFF><td>
  <table border=0 cellpadding=1 cellspacing=0 width=100%>
   <tr height=22 bgcolor=$titlecolor><td background=images/style/catbg.gif>&nbsp;<b>* <font face=verdana>U</font>-推荐：</b>$topic_name</td></tr>
   <tr height=1 bgcolor=$bordercolor><td></td></tr>
   <tr><td>
     <table width=100% align=center><tr>
      <td width=25% valign=top rowspan=3>$print_info[$topic_author]</td>
      <td width=75%>
	<table width=97% align=center border=0 style="WORD-WRAP: break-word" cellspacing=0 cellpadding=2>
	 <tr>
	  <td width=70><b><font face=Verdana>U</font>名称</b>：</td>
	  <td width=300><TABLE style='FILTER: glow(color=#9999FF,strength=4)'><FONT color=#000066><B>$u_data[0]</B></FONT></TABLE></td>
	 </tr>
EOT;
if ($u_data[5] && $u_data[5]!='http://') echo "<tr><td colspan=2><img src='$u_data[5]'></td></tr>";
if ($u_data[1] && $u_data[1]!='http://') echo "<tr><td width=70><b><font face=Verdana>BY</font></b>：</td><td>$u_data[1]</td></tr>";
if ($u_data[2] && $u_data[2]!='http://') echo "<tr><td width=70>网址：</td><td><a href='$u_data[2]' target=_blank style=\"font-family:verdana\">$u_data[2]</a></td></tr>";
if ($u_data[3] && $u_data[3]!='http://') echo "<tr><td width=70>下载地址：</td><td><a href='$u_data[3]' style=\"font-family:verdana\"><img src='images/system/download.gif' border=0>$u_data[3]</a></td></tr>";
if ($u_data[4]) echo "<tr><td width=70>大小：</td><td><font face=verdana>$u_data[4] KB</font></td></tr>";
if ($topic_content) echo "<tr><td colspan=2>简单资料：</td></tr><tr><td colspan=2>&nbsp; ".vibconvert($topic_content)."<hr size=1>推荐于 $topic_date 鉴定：$topic_area</td></tr>";
echo "	</table>
      </td>
     </tr>
    </table></td>
   </tr>
  </table></td>
 </tr>
<TABLE style=BORDER-COLLAPSE: collapse borderColor=#111111 cellSpacing=0 cellPadding=0 width=600 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>
<br>";
}