vBulletin HACK--树型结构式目录帖子列表

原因:不少人比较习惯那种树型结构的帖子列表模式,可以对某贴回复,而不是话题。
优点:自动记录、识别用户所使用的显示模式;虽然修改了原有数据表的结构,但不影响原有帖子,而且也不需要对旧帖子进行任何加工,程序能自动将旧的都正常显示出来。
缺点:应该会有,正在测试中。
自评:从K.W.大哥那得到的启发。做起来并不算复杂,但恐怕很多玩惯UBB的朋友需要改变一下习惯,就是每次发言都要输入标题——当然,程序已经缺省地为他们加了。
范例:http://gogosoft.oso.com.cn/forum/showthread.php?threadid=54

步骤:建议在网络速度可以的情况下更新,否则在你更新过程中的访问者可能会出错。
一、文件篇
⒈打开 global.php ,查找“
if (isset($username)!=0 and $username!="" and isset($password)!=0) {
”,在前面加入“
// Hack tree
if (isset($showmethod)!=0 AND $showmethod!="") {
  setcookie("bbshowmethod",$showmethod,mktime(0,0,0,0,0,2020),$cookiepath);
} else {
    if (isset($bbshowmethod)!=0 AND $bbshowmethod!="") {
      $showmethod=$bbshowmethod;
    } else {
      $showmethod="showthread";
    }
}
// End hack tree
”,保存退出;

⒉打开 member.php ,查找“
  setcookie("bbuserid","",mktime(0,0,0,0,0,1998),$cookiepath);
  setcookie("bbpassword","",mktime(0,0,0,0,0,1998),$cookiepath);
”,在后面加入“
  setcookie("bbshowmethod","",mktime(0,0,0,0,0,1998),$cookiepath);
”,保存退出;

⒊打开 newreply.php ,查找“
  // check for subject and message
  if ($message=="") {
    echo standarderror($bbtitle,gettemplate("error_nosubject",0));
”,将中间一行替换为“
  if ($message=="" or $title=="") {
”,查找“

  $threadid=verifyid("thread",$threadid);
”,在前面加入“
  // hack thread-flat
  $parentpostid=$postid;
  $threadinfo=$DB_site->query_first("SELECT thread.threadid,thread.title,thread.forumid,
                                            thread.replycount,thread.open
                                     FROM post 
                                     LEFT JOIN thread ON (thread.threadid = post.threadid) 
                                     WHERE postid=$parentpostid");
  $threadid=$threadinfo[threadid];
  // end hack thread-flat
”,查找“
  $threadinfo=$DB_site->query_first("SELECT title,forumid,replycount,open FROM thread WHERE threadid=$threadid");
”,在此行前面加“//”屏蔽掉,查找“
      $DB_site->query("INSERT INTO post (postid,threadid,title,username,userid,dateline,pagetext,allowsmilie,email,signature,ip
ddress,iconid,visible) VALUES (NULL,$threadid,'".addslashes($title)."','".addslashes($postusername)."',$userid,".time().",'".ad
slashes($message)."',$allowsmilie,$email,$signature,'$ipaddress',$iconid,$visible)");
”,替换为“
      // hack thread-flat add /parentpostid and $postparentid/
      $DB_site->query("INSERT INTO post (postid,threadid,title,username,userid,dateline,pagetext,allowsmilie,email,signature,ipaddress,iconid,visible,parentpostid) VALUES (NULL,$threadid,'".addslashes($title)."','".addslashes($postusername)."',$userid,".time().",'".addslashes($message)."',$allowsmilie,$email,$signature,'$ipaddress',$iconid,$visible,$parentpostid)");
”,查找“
      if ($getthread[title]!="") {
        $title="Re: $getthread[title]";
      }
”,去掉判断,也就是替换为“
        $title="Re: $getthread[title]";
”,查找“
      eval("$message = "".gettemplate("quotereply")."";");
”,替换为“
      // hack thread-flat
      if ($quota=="yes") {
        eval("$message = "".gettemplate("quotereply")."";");
      }
      // end hack thread-flat
”,查找“
    if (!$thread=$DB_site->query_first("SELECT threadid FROM thread WHERE threadid=$threadid")) {
      $idname="thread";
      eval("echo standarderror($bbtitle,"".gettemplate("error_invalidid")."");");

      exit;
    }
”,在后面加入“
    $post=$DB_site->query_first("SELECT postid,title FROM post WHERE threadid=$threadid ORDER BY dateline $postorder");
    $postid=$post[postid];
    $title="Re: $post[title]";
”,保存退出;

⒋打开 showthread.php ,查找“
$threadid = verifyid("thread",$threadid);

$threadinfo=$DB_site->query_first("SELECT title,forumid,open,lastpost,replycount+1 AS posts,views,visible FROM thread WHERE threadid=$threadid");
”,在前面加入“
// Hack tree
if (isset($threadid)==0 or $threadid==0 or $threadid=="") {
  $thread=$DB_site->query_first("SELECT threadid FROM post WHERE postid=$postid");
  $threadid=$thread[threadid];
}
if (isset($postid)==0 or $postid==0 or $postid=="") {
  $post=$DB_site->query_first("SELECT postid FROM post WHERE threadid=$threadid ORDER BY dateline DESC");
  $postid=$post[postid];
}
$currentpostid=$postid;

$post=$DB_site->query_first("SELECT postid FROM post WHERE threadid=$threadid ORDER BY dateline");
$parentpostid=$post[postid];
// End Hack tree
”,查找“
} else {
  $usetemplate="showthread";
}
”,替换为“
} else {
  $usetemplate=$showmethod;
}
”,查找“
if ($foruminfo[active]==0) {
  echo standarderror($bbtitle,gettemplate("error_forumclosed",0));
  exit;
}
”,开始标记,直至“
$counter=0;
”(第一个),连同后面的全部PHP代码剪切到新文件 sub_showthread.php 中(注意在文件头、尾加入PHP标记 <?PHP 和 ?>),并在后面加入“
include("sub_".$showmethod.".php");
”,顺便将以下内容粘贴为新文件 sub_treethread.php “
<?php
$treebits
="";
$postbits="";

getThreadChildren();    // 对于新安装的讨论区,这个不需要

// Begin the post
  
$post=$DB_site->query_first("SELECT post.dateline as dateline,post.postid as postid,
                                      post.pagetext as pagetext,
                                      post.allowsmilie as allowsmilie,post.signature AS showsignature,
                                      post.title as title,
                                      post.ipaddress as ipaddress,post.iconid as iconid,
                                      post.username as fakename,
                                      post.userid as userid, 
                                      user.userid as userid,user.email as email,
                                      user.username as username,
                                      user.usertitle as usertitle,user.signature as signature,
                                      user.showemail as showemail,
                                      user.homepage as homepage,user.icq as icq,user.aim as aim,
                                      user.yahoo as yahoo,
                                      user.joindate as joindate,user.posts as posts 
                               FROM post 
                               LEFT JOIN user ON (user.userid = post.userid) 
                               WHERE post.postid=$postid AND visible=1 
                              "
);

//  $postid=$post[postid];

  
$backcolor="{firstaltcolor}";

  
$postdate=date($dateformat,$post[dateline]+(($timeoffset+$bbtimezoneoffset)*3600));
  
$posttime=date($timeformat,$post[dateline]+(($timeoffset+$bbtimezoneoffset)*3600));

  if (
$wordwrap!=0) {
    
$post[title]=dowordwrap($post[title]);
  }
  
$postitle=htmlspecialchars($post[title]);

  if (
$post[dateline]>$bblastvisit) {
    
$foldericon="<IMG SRC="images/posticonnew.gif" BORDER=0>";
  } else {
    
$foldericon="<IMG SRC="images/posticon.gif" BORDER=0>";
  }
  if (
$showicons==or $post[iconid]==0) {
    
$posticon="";
  } else {
          if (!
$iconcache) {
              
$icons=$DB_site->query("SELECT iconid,title,iconpath FROM icon");
              while(
$icon=$DB_site->fetch_array($icons)) {
                  
$iconcache["$icon[iconid]"][title] = $icon[title];
                  
$iconcache["$icon[iconid]"][iconpath] = $icon[iconpath];
              }
          } else {
              if (
$iconcache["$post[iconid]"]) {
                  
$theid $post[iconid];
                  
$posticon="<img src="".$iconcache[$theid][iconpath]."" alt="".$icon[$theid][title]."" border=0>";
              } else {
                  
$posticon "";
              }
          }
  }

  
$userid=$post[userid];

  if (
$userid!=0) {
    
$userinfo=$post;

    
$username=htmlspecialchars($userinfo[username]);

    
// User Logo Hack
    
$userlogo "images/member/".$username.".gif";
    if (
file_exists($userlogo)) {
     
$userlogo "<img src="$userlogo">";
    } else {
     
$userlogo "";
    }
    
// End User Logo Hack

    
$searchuser=urlencode($userinfo[username]);
    
$usertitle=$userinfo[usertitle];
    
$userjoindate=date($registereddateformat,$userinfo[joindate]+(($timeoffset+$bbtimezoneoffset)*3600));
    
$userpostcount=$userinfo[posts];

    if (
$userinfo[showemail]==and $displayemails==1) {
      
$email=$userinfo[email];
      eval(
"$useremail = "".gettemplate("postbit_useremail")."";");
    } else {
      
$email="";
      
$useremail="";
    }
    if (
$userinfo[icq]!="") {
      
$icqnumber=$userinfo[icq];
      eval(
"$icq = "".gettemplate("icq")."";");
    } else {
      
$icqnumber="";
      
$icq="";
    }
    if (
$userinfo[aim]!="") {
      
$aimhandle=$userinfo[aim];
      eval(
"$aim = "".gettemplate("aim")."";");
    } else {
      
$aimhandle="";
      
$aim="";
    }
    if (
$userinfo[yahoo]!="") {
      
$yahoohandle=$userinfo[yahoo];
      eval(
"$yahoo = "".gettemplate("yahoo")."";");
    } else {
      
$yahoohandle="";
      
$yahoo="";
    }

    if (
$userinfo[homepage]!="" and $userinfo[homepage]!="http://") {
      
$homepageurl=$userinfo[homepage];
      eval(
"$homepage = "".gettemplate("postbit_homepage")."";");
    } else {
      
$homepageurl="";
      
$homepage="";
    }

    eval(
"$profile = "".gettemplate("postbit_profile")."";");
    
$findposts="";

    if (
$post[showsignature]==and $allowsignatures==and trim($userinfo[signature])!="") {
      
$signature"nn<hr size=1><smallfont>".bbcodeparse($userinfo[signature],0,$allowsmilies)."</smallfont>";
    } else {
      
$signature="";
    }
  } else {
    
$username=htmlspecialchars($post[fakename]);

    
// User Logo Hack 
    
$userlogo "";
    
// End User Logo Hack

    
$searchuser=urlencode($post[fakename]);
    
$usertitle="游客";
    
$userjoindate="还未";
    
$userpostcount="(无)";

    
$profile="";
    
$userlocation="";
    
$email="";
    
$useremail="";
    
$icqhandle="";
    
$icq="";
    
$aimhandle="";
    
$aim="";
    
$yahoohandle="";
    
$yahoo="";
    
$homepageurl="";
    
$homepage="";
    
$searchuser="";
    
$findposts="";
    
$signature="";

  }

  if (
$post[ipaddress]!="") {
    if (
$logip==2) {
      
$iplogged="IP: $post[ipaddress]";
    }
    if (
$logip==1) {
      
$iplogged="IP: <a href="postings.php?action=getip&postid=$postid">已登记</a>";
    }
    if (
$logip==0) {
      
$iplogged="";
    }
  } else {
    
$iplogged="";
  }

  
$message=bbcodeparse($post[pagetext],$forumid,$post[allowsmilie]);

  eval(
"$postbits = "".gettemplate("$usetemplatebit")."";");

  
// End the post

  // Moved out

  
getChildren($parentpostid);

  
// End Moved out

  
if ($threadinfo[lastpost]>$bblastvisit) {
    
// do blue arrow link
    
$counter=0;
    
$posts=$DB_site->query("SELECT postid,dateline FROM post WHERE post.threadid=$threadid AND post.visible=1 ORDER BY dateline $postorder");
    while (
$post=$DB_site->fetch_array($posts)) {
  
      
$counter++;
  
      if (
$post[dateline]>$bblastvisit) {
        if (
$counter%$perpage==0) {
          
$firstnewpagenum=intval($counter/$perpage);
        } else {
          
$firstnewpagenum=intval($counter/$perpage)+1;
        }
        if (
$firstnewpagenum==$pagenumber) {
          
$newpostlink="#newpost";
        } else {
          
$newpostlink="showthread.php?threadid=$threadid&pagenumber=$firstnewpagenum#newpost";
        }
        break;
      }
    }
  
    if (
$newpostlink=="") {
      
$firstunread="";
    } else {
      eval(
"$firstunread = "".gettemplate("firstunread")."";");
    }
  } else {
    
$firstunread="";
  }
  
  if (
$getnextnewest=$DB_site->query_first("SELECT threadid FROM thread WHERE lastpost>$threadinfo[lastpost] AND forumid=$forumid AND visible=1 ORDER BY lastpost LIMIT 1")) {
    
$nextnewestthreadid=$getnextnewest[threadid];
    eval(
"$nextnewest = "".gettemplate("showthread_nextnewestthread")."";");
  } else {
    
$nextnewestthreadid=$threadid;
  }
  
  if (
$getnextoldest=$DB_site->query_first("SELECT threadid FROM thread WHERE lastpost<$threadinfo[lastpost] AND forumid=$forumid AND visible=1 ORDER BY lastpost DESC LIMIT 1")) {
    
$nextoldestthreadid=$getnextoldest[threadid];
    eval(
"$nextoldest = "".gettemplate("showthread_nextoldestthread")."";");
  } else {
    
$nextoldestthreadid=$threadid;
  }
  
  if (
$threadinfo[open]%2==1) {
    
$replyclose="$replyimage";
    
$openclosed="关闭帖子";
  } else {
    
$replyclose="$closedthreadimage";
    
$openclosed="打开帖子";
  }
  
  if (
$threadinfo[open]<2) {
    
$settoped="设置置顶";
  } else {
    
$settoped="取消置顶";
  }
  
  
// parse header ##################
  
if ($foruminfo[headertemplate]!="") {
    if (
$foruminfo[useadvheader]==1) {
      eval(
gettemplate("$foruminfo[headertemplate]").";");
    } else {
      eval(
"$header = "".gettemplate("$foruminfo[headertemplate]")."";");
    }
  }
  if (
$foruminfo[footertemplate]!="") {
    if (
$foruminfo[useadvfooter]==1) {
      eval(
gettemplate("$foruminfo[footertemplate]").";");
    } else {
      eval(
"$footer = "".gettemplate("$foruminfo[footertemplate]")."";");
    }
  }
 
  eval(
"echo dovars("".gettemplate("$usetemplate")."");");

// ############### get children post ###########################
  
function getChildren($ppostid,$treeDeep=0) {

  global 
$treebits,$counter,$DB_site,$threadid,$currentpostid;
  global 
$timeformat,$dateformat,$postorder;

  
$treedeepspace=str_repeat ("<img src=images/blank.gif width=16 height=16>",$treeDeep);

  
$post=$DB_site->query_first("SELECT post.dateline as dateline,post.postid as postid,
                                      post.title as title,post.iconid AS iconid,icon.iconpath,
                                      post.username as fakename,post.userid as userid,
                                      user.username as username,user.posts as posts,
                                      user.usertitle as usertitle,user.signature as signature,
                                      LENGTH(post.pagetext) AS size
                               FROM post 
                               LEFT JOIN user ON (user.userid = post.userid) 
                               LEFT JOIN icon ON (icon.iconid = post.iconid)
                               WHERE post.postid=$ppostid AND visible=1 
                               ORDER BY dateline $postorder
                              "
);
  
  
$counter++;
  
  
$postid=$post[postid];
  
$postsize=$post[size];
  
$postsize=iif($postsize>1024,number_format($postsize/1024,1)."K",$postsize)."B";
  
  if (
$counter%2==0) {
    
$backcolor="{firstaltcolor}";
  } else {
    
$backcolor="{secondaltcolor}";
  }

  
$postdate=date($dateformat,$post[dateline]+(($timeoffset+$bbtimezoneoffset)*3600));
  
$posttime=date($timeformat,$post[dateline]+(($timeoffset+$bbtimezoneoffset)*3600));
  
  
$postitle=htmlspecialchars($post[title]);
  
$postitle=iif($postitle=="","(无标题)",$postitle);
  if (
$currentpostid==$postid) {
    
$postitlelink=$postitle;
  } else {
    
$postitlelink="<a href=showthread.php?postid=$postid>$postitle</a>";
  }
  if (
$post[dateline]>$bblastvisit) {
    
$foldericon="<IMG SRC="images/posticonnew.gif" BORDER=0>";
  } else {
    
$foldericon="<IMG SRC="images/posticon.gif" BORDER=0>";
  }

  if (
$showicons==or $post[iconid]!=0) {
    
$posticon="<img src="$post[iconpath]" alt="$post[icontitle]" border=0>";
  } else {
    
$posticon="<img src=images/blank.gif width=15 height=15>";
  }
  
  
$userid=$post[userid];
  
  if (
$userid!=0) {
    
$userinfo=$post;
    
$username=htmlspecialchars($userinfo[username]);
    
$usertitle=$userinfo[usertitle];
  } else {
    
$username=htmlspecialchars($post[fakename]);
    
$usertitle="游客";
  }

//  eval("$postbits .= "".gettemplate("$usetemplatebit")."";");
  
eval("$treebits .= "".gettemplate("treethreadbit")."";");
  
  
$pposts=$DB_site->query("SELECT postid FROM post WHERE parentpostid=$ppostid AND visible=1 
                                  ORDER BY dateline $postorder
                          "
);
  while (
$ppost=$DB_site->fetch_array($pposts)) {
    
getChildren($ppost[postid],$treeDeep+1);
  }
}
// #############################################################

// ################ getThread Other Child ######################
function getThreadChildren() {

  global 
$treebits,$counter,$DB_site,$threadid,$currentpostid;
  global 
$timeformat,$dateformat,$postorder;

  
$treedeepspace="";

  
$posts=$DB_site->query("SELECT post.dateline as dateline,post.postid as postid,
                                      post.title as title,post.iconid AS iconid,icon.iconpath,
                                      post.username as fakename,post.userid as userid,
                                      user.username as username,user.posts as posts,
                                      user.usertitle as usertitle,user.signature as signature,
                                      LENGTH(post.pagetext) AS size
                               FROM post 
                               LEFT JOIN user ON (user.userid = post.userid) 
                               LEFT JOIN icon ON (icon.iconid = post.iconid)
                               WHERE post.threadid=$threadid AND post.parentpostid=0 AND visible=1 
                               ORDER BY dateline $postorder
                              "
);
  while (
$post=$DB_site->fetch_array($posts)) {

    
$counter++;

    
$postid=$post[postid];
    
$postsize=$post[size];
    
$postsize=iif($postsize>1024,number_format($postsize/1024,1)."K",$postsize)."B";
    
    if (
$counter%2==0) {
      
$backcolor="{firstaltcolor}";
    } else {
      
$backcolor="{secondaltcolor}";
    }
  
    
$postdate=date($dateformat,$post[dateline]+(($timeoffset+$bbtimezoneoffset)*3600));
    
$posttime=date($timeformat,$post[dateline]+(($timeoffset+$bbtimezoneoffset)*3600));
    
    
$postitle=htmlspecialchars($post[title]);
    
$postitle=iif($postitle=="","(无标题)",$postitle);
    if (
$currentpostid==$postid) {
      
$postitlelink=$postitle;
    } else {
      
$postitlelink="<a href=showthread.php?postid=$postid>$postitle</a>";
    }
    if (
$post[dateline]>$bblastvisit) {
      
$foldericon="<IMG SRC="images/posticonnew.gif" BORDER=0>";
    } else {
      
$foldericon="<IMG SRC="images/posticon.gif" BORDER=0>";
    }
  
    if (
$showicons==or $post[iconid]!=0) {
      
$posticon="<img src="$post[iconpath]" alt="$post[icontitle]" border=0>";
    } else {
      
$posticon="<img src=images/blank.gif width=15 height=15>";
    }
    
    
$userid=$post[userid];
    
    if (
$userid!=0) {
      
$userinfo=$post;
      
$username=htmlspecialchars($userinfo[username]);
      
$usertitle=$userinfo[usertitle];
    } else {
      
$username=htmlspecialchars($post[fakename]);
      
$usertitle="游客";
    }
  
  
//  eval("$postbits .= "".gettemplate("$usetemplatebit")."";");
    
eval("$treebits .= "".gettemplate("treethreadbit")."";");
  }
}
// #############################################################

?>
”,保存退出。
注意:我这里的签名与大家的可能不同,如有问题请修改“
      $signature= "nn<hr size=1><smallfont>".bbcodeparse($userinfo[signature],0,$allowsmilies)."</smallfont>";
”一行为“
      $signature= "nn__________________n$userinfo[signature]";
”。

⒌打开 newthread.php ,查找“
      $DB_site->query("INSERT INTO post (postid,threadid,title,username,userid,dateline,pagetext,allowsmilie,email,signature,ipaddress,iconid,visible) VALUES (NULL,$threadid,'','".addslashes($postusername)."',$userid,".time().",'".addslashes($message)."',$allowsmilie,$email,$signature,'$ipaddress',$iconid,1)");
”,替换为“
      // hack thread-flat
      $DB_site->query("INSERT INTO post (postid,threadid,title,username,userid,dateline,pagetext,allowsmilie,email,signature,ipaddress,iconid,visible) VALUES (NULL,$threadid,'".addslashes($subject)."','".addslashes($postusername)."',$userid,".time().",'".addslashes($message)."',$allowsmilie,$email,$signature,'$ipaddress',$iconid,1)");
      // end hack thread-flat
”,保存退出。


二、模板篇
⒈新增模板 treethread ,内容为“
{htmldoctype}
<HTML>
<HEAD>
<TITLE>$bbtitle - $threadtitle</title>
$cssinclude
</head>
<body>
$header


<table border="0" width="100%"><tr>
<td valign="top" align="left"><a href="index.php"><img src="$titleimage" border="0"></a></td>

<td valign="middle" align="center" nowrap>
$fivelinks
<br><smallfont><img src="images/sendtofriend.gif" border="0"> <a href="sendtofriend.php?threadid=$threadid">Email给朋友!</a></smallfont>
<smallfont><img src="images/printer.gif" border="0"> <a href="printthread.php?threadid=$threadid">可打印版本</a></smallfont>
<smallfont><img src="images/favorites.gif" border="0"> <a href="favorites.php?action=add&threadid=$threadid">收藏此话题</a></smallfont>
</td></tr></table>

<table border="0" width="100%" cellpadding="2">
<tr><td width="100%">

<normalfont><b><a href="index.php">$bbtitle</A> &gt; <A HREF="forumdisplay.php?forumid=$forumid">$forumtitle</a><br>$threadtitle</b></normalfont>

</td>
<td valign="bottom" align="right" nowrap><smallfont><a
href=showthread.php?showmethod=showthread&threadid=$threadid&postid=$postid>平板目录</a> |
$nextoldest $nextnewest</smallfont></TD>
</tr></table>

<a name="posttop"></a>
<table width="100%" bgcolor="{tablebordercolor}" cellspacing="0" cellpadding="0"><tr>
<td width="100%" bgcolor="{tablebordercolor}">
<table width=100% border=0 cellspacing=1 cellpadding=4>
<TR bgcolor="{tableheadbgcolor}">
<TD valign="middle" width="175" nowrap>
<smallfont color="{tableheadtextcolor}" class=thtcolor><B>发表者</B></smallfont>
</TD>
<TD valign="middle" width="100%">

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td width="100%" valign="middle">

<smallfont color="{tableheadtextcolor}" class=thtcolor><B>帖子</B></smallfont>

</td><td valign="middle">

<A HREF="newthread.php?action=newthread&forumid=$forumid"><IMG SRC="$newthreadimage"  BORDER=0 ALT="发表新帖子"></A>

</td><td valign="middle">
<normalfont>&nbsp;&nbsp;&nbsp;</normalfont>

</td><td valign="middle">

<A HREF="newreply.php?action=newreply&postid=$postid"><IMG SRC="$replyclose" BORDER=0 ALT="发表回复"></A>

</td></tr></table>

</TD>
</TR>
</table>
</td></tr></table>

$postbits

<table width="100%" bgcolor="{tablebordercolor}" cellspacing="0" cellpadding="0"><tr>
<td width="100%" bgcolor="{tablebordercolor}">
<table width=100% border=0 cellspacing=1 cellpadding=4>
<TR bgcolor="{tableheadbgcolor}">
<TD valign="middle" width="100%" colspan="2">

<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td width="100%" valign="middle">

<smallfont color="{tableheadtextcolor}"><b>
时区为$timezone</b></smallfont>

</td><td valign="middle">

<A HREF="newthread.php?action=newthread&forumid=$forumid"><IMG SRC="$newthreadimage"  BORDER=0 ALT="发表新帖子"></A>

</td><td valign="middle">
<normalfont>&nbsp;&nbsp;&nbsp;</normalfont>

</td><td valign="middle">

<A HREF="newreply.php?action=newreply&postid=$postid"><IMG SRC="$replyclose" BORDER=0 ALT="发表回复"></A>

</td></tr></table>

</td></tr></table>
</td></tr></table>
<br>
<table width="100%" bgcolor="{tablebordercolor}" cellspacing="0" cellpadding="0"><tr>
<td width="100%" bgcolor="{tablebordercolor}">
<table width=100% border=0 cellspacing=1 cellpadding=4>
<tr><td bgcolor="{tableheadbgcolor}">
<smallfont color="{tableheadtextcolor}" class=thtcolor><B>树型目录</B></smallfont>
</td></tr>
$treebits
</table></td></tr></table>

<table border="0" width="100%" cellpadding="2">
<tr><td width="100%" valign="top">

$forumjump

</td>
<td valign="top" align="right" nowrap><smallfont>$nextoldest $nextnewest</smallfont></TD>
</tr></table>


<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td width="100%">
<p><smallfont><b>论坛规则:</b><br>
$forumrules</smallfont></p>
</td><td nowrap>
<p><smallfont><b>管理员选项:</b><br>
<a href="postings.php?action=openclosethread&threadid=$threadid">$openclosed</a>|<a
href="postings.php?action=settopthread&threadid=$threadid">$settoped</a><br>
<a href="postings.php?action=move&threadid=$threadid">移动</a>|<a
href="postings.php?action=deletethread&threadid=$threadid">删除</a>|<a
href="postings.php?action=editthread&threadid=$threadid">编辑</a>帖子</smallfont></p>
</td></tr></table>

$footer

</body>
</html>
”。

⒉新增模板 treethreadbit ,内容为“
<tr bgcolor="$backcolor">
<td width="100%" valign="top" nowrap>
<smallfont>$treedeepspace $foldericon $posticon
<B>$postitlelink</b>
($postsize)
- $username,
$postdate $posttime
</td>
</tr>
”。

⒊编辑模板 showthread ,在适当位置加入树型目录的连接,例如查找“
$nextoldest $nextnewest
”,在前面紧加入“
<a href="showthread.php?showmethod=treethread&postid=$postid">树型目录</a> | 
”,保存。

⒋编辑模板 postbit ,查找“
<A HREF="newreply.php?action=newreply&postid=$postid">
”,替换为“
<A HREF="newreply.php?action=newreply&quota=yes&postid=$postid">
”,即为“引用回复”的连接增加一个参数 quota ,值为 yes ,并在此图片连接后加入回复连接“
<A HREF="newreply.php?action=newreply&postid=$postid"><IMG SRC="images/reply2.gif" BORDER=0 ALT="回复"></A>
”,顺便的,你得准备一个 reply2.gif 以连接回复帖子(而不是回复话题),准备一个 blank.gif 全透明的,排版用。保存。

⒌编辑模板 newrelpy ,查找“
<INPUT TYPE="HIDDEN" NAME="threadid" VALUE="$threadid">
”,替换为“
<INPUT TYPE="HIDDEN" NAME="postid" VALUE="$postid">
”,保存。

这里的模板都有一个 {tablebordercolor} 变量,作用请参考我在奥索发表的题为《vBulletin的使用心得----两则版面方面的改良》一文。


三、数据库篇(最好是第一步做)
使用 phpMyAdmin 或其它工具打开讨论区数据库,修改 post 表的结构,在数据库尾新增一字段:
字段    parentpostid
类型    int(10)
属性    UNSIGNED
Null    否