⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 topic.jsp

📁 这是一个用JAVA语言编写的BBS论坛程序
💻 JSP
字号:
<%
/*
 * Copyright:  Copyright (c) 2004 
 * @author http://hi.baidu.com/lael80*/
%>
<%@ page contentType="text/html; charset=gb2312" errorPage=""%>
<%@ include file="head.jsp"%>
<br>
<table width="96%" border="0" align="center" cellpadding="5" cellspacing="0">
 <tr>
 <td width="120" align="left">
 <a href="post.jsp?forum=<%=forum%>&pageid=<%=pageid%>&action=topic">
 <img id="post1" src="skins/<%=skins%>/post1.gif">
 </a>
 </td>
 <td align="right" valign="middle"><img src="images/ren.gif">版主:<%=workDB.queryAdmin(Integer.parseInt(request.getParameter("forum")))%></td></tr>
</table>
<%=tabletop%>
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
 <tr><td height="25" colspan="6" class="b1">&nbsp;</td></tr>
 <tr height="20" valign="middle" align="center" class="style3">
  <td width="4%">&nbsp;</td>
  <td width="50%">主题</td>
  <td width="11%">作者</td>
  <td width="5%">回复</td>
  <td width="5%">人气</td>
  <td width="25%">最后更新</td>
 </tr>
<%
int i=0,j=0;
String tmpsql="";
if(pageid==1){
  tmpsql="(topic_forum="+forum+" and topic_type=1) or (topic_forum="+forum+sql+")";
  sql="select a.topic_id,a.user_name,count(b.topic_id),a.topic_theme,a.topic_date,max(b.reply_date),a.topic_read,a.topic_type from user_topic a left join user_reply b using(topic_id) where (a.topic_forum="+forum+" and a.topic_type=1) or (a.topic_forum="+forum+sql+") group by topic_id order by a.topic_type*10000000000+a.topic_id desc";
}else{
  tmpsql="topic_forum="+forum+sql;
  sql="select a.topic_id,a.user_name,count(b.topic_id),a.topic_theme,a.topic_date,max(b.reply_date),a.topic_read,a.topic_type from user_topic a left join user_reply b using(topic_id) where a.topic_forum="+forum+sql+" group by topic_id order by a.topic_id desc";
}
String topicdata[]=workDB.queryData(sql,8,pageid,30);
for(i=0;i<topicdata.length/8;i++){
  String stheme="",sname="",supdate="",slist="",stpimg="<img src='images/topic2.gif' width='17' height='12'>";
  String snew="";
  String simage="<img src='images/sub.gif'>";
  String replydata[]=new String[3];
  String stitle="作者:"+topicdata[8*i+1]+"&#13;&#10;时间:"+topicdata[8*i+4]+"&#13;&#10;没有回复";
  if(Integer.parseInt(topicdata[8*i+2])!=0){
    replydata=workDB.queryData("select user_name,substring(reply_content,1,10),reply_date from user_reply where topic_id="+topicdata[8*i]+" order by reply_date desc",3,1,1);
    stpimg="<img src='images/topic1.gif' width='17' height='12'>";
    simage="<a href='javascript:hiddenvisible("+topicdata[8*i]+");'><img id='"+topicdata[8*i]+"100' src='images/add.gif'></a>";
    stitle="作者:"+topicdata[8*i+1]+"&#13;&#10;时间:"+topicdata[8*i+4]+"&#13;&#10;最后回复:"+replydata[1]+"&#13;&#10;由"+replydata[0]+"回复于:"+replydata[2];
    if((Integer.parseInt(topicdata[8*i+2])+9)/10>1){
      slist="&nbsp;&nbsp;&nbsp;[<img src='images/list.gif'>";
      for(j=1;j<=(Integer.parseInt(topicdata[8*i+2])+9)/10;j++){       
        if(j==10&&(Integer.parseInt(topicdata[8*i+2])+9)/10>10)break;
        slist=slist+"&nbsp;<a href='display.jsp?forum="+forum+"&topic="+topicdata[8*i]+"&pageid="+pageid+"&id="+j+"'>"+j+"</a>";
      }
      if((Integer.parseInt(topicdata[8*i+2])+9)/10>10)slist=slist+"......<a href='display.jsp?forum="+forum+"&topic="+topicdata[8*i]+"&pageid="+pageid+"&id="+(Integer.parseInt(topicdata[8*i+2])+9)/10+"'>"+(Integer.parseInt(topicdata[8*i+2])+9)/10+"</a>";
      slist=slist+"&nbsp;]";      
    }
  }
  java.text.SimpleDateFormat format=new java.text.SimpleDateFormat("yyyy-MM-dd");
  java.util.Date date=format.parse(topicdata[8*i+4]);
  String str1=format.format(date);
  String str2=format.format(new java.util.Date()); 
  if(str1.equals(str2))snew="&nbsp;<img src='images/new.gif'>";

  if(topicdata[8*i+7].equals("1"))stpimg="<img src='images/topic3.gif' width='17' height='12'>"; 
  stheme=simage+"<a href='display.jsp?forum="+forum+"&topic="+topicdata[8*i]+"&pageid="+pageid+"&id=1' title='"+stitle+"'>"; 
  if(session.getAttribute("u_name").equals(workFC.GBtoUni(topicdata[8*i+1])))sname="<img src='images/ren.gif'>";  
  if(Integer.parseInt(topicdata[8*i+2])==0){
    supdate=topicdata[8*i+4]+"|"+topicdata[8*i+1];
  }else supdate=replydata[2]+"|<a href='userinfo.jsp?name="+replydata[0]+"'>"+replydata[0]+"</a>";
  
  out.println("<tr height='20' align='center'><td width='4%' class='style4'>"+stpimg+"</td>"+
     "<td width='50%' align='left' class='style5'>"+stheme+topicdata[8*i+3]+"</a>"+snew+slist+"</td>"+
     "<td width='11%' class='style4'>"+sname+"<a href='userinfo.jsp?name="+topicdata[8*i+1]+"'>"+topicdata[8*i+1]+"</a></td>"+
     "<td width='5%' class='style5'>"+topicdata[8*i+2]+"</td>"+
     "<td width='5%' class='style5'>"+topicdata[8*i+6]+"</td>"+
     "<td width='25%' class='style4'>"+supdate+"</td></tr>");
  if(Integer.parseInt(topicdata[8*i+2])!=0){
     out.println("<tr id='"+topicdata[8*i]+"' style='display:none' height='20' align='center'>");
     out.println("<td width='4%'>&nbsp;</td><td width='95%' align='left' colspan='6'>");
     out.println("<iframe id='frm"+topicdata[8*i]+"' name='frm"+topicdata[8*i]+"' frameborder='0' width='100%' height='20' scrolling='no' src='listtree.jsp?forum="+forum+"&topic="+topicdata[8*i]+"&pageid="+pageid+"&id=1'>");        
     out.println("</iframe></td></tr>");
  }
}
workDB.PageInfo("select count(topic_id) from user_topic where "+tmpsql,30,pageid);
%>
</table>
<%=tablebottom%>

<table width="96%" align="center" border="0" cellspacing="5" cellpadding="0" style="background-color:#FFFFFF;">
  <form name="form1" onSubmit="return false;"><tr>
    <td width="40%" align="left"><%out.println("&nbsp;页次:"+pageid+"/"+workDB.getPageCount()+"页&nbsp;本页:"+workDB.getPageNowCount()+"&nbsp;主题数:"+workDB.getDataCount());%></td>
    <td width="48%" align="right"><%=workFC.ShowPage(workDB.getPageCount(),pageid,"topic.jsp?forum="+forum+"&"+urlpath+"pageid")%></td>
    <td width="12%" align="right"><input name="go_page" id="go_page" type="text" size="5" maxlength="10" onkeyup="if(isNaN(this.value)||this.value==' ')this.value='';" onkeydown="if(this.value!=''&&event.keyCode==13)goes();" title="转到指定页">&nbsp;<input type="button" name="Submit" value="GO" onclick="goes();" title="转到指定页">&nbsp;</td>
  </tr></form>
</table>
<br>

<table width="96%" height="25" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
  <form name="form2" method="post" action="topic.jsp?forum=<%=forum%>&pageid=1">
    <td width="60%"><input type="text" name="search" size="25" maxlength="200">&nbsp;<input type="submit" name="Submit2" value="快速搜索"></td>
</form>
<td width="40%"><div align="right">
      <select name="select" onchange="if(this.options[this.selectedIndex].value!=''){location=this.options[this.selectedIndex].value;}">
        <option value="index.jsp" selected>选择要跳转到的论坛</option>
        <option value="index.jsp" value="index.jsp">|--论坛首页</option>
        <option value="topic.jsp?&forum=1&pageid=1">|----网页设计</option>
        <option value="topic.jsp?&forum=2&pageid=1">|----平面设计</option>
        <option value="topic.jsp?&forum=3&pageid=1">|----动漫前沿</option>
        <option value="topic.jsp?&forum=4&pageid=1">|----编程开发</option>
        <option value="topic.jsp?&forum=5&pageid=1">|----电脑网络</option>
        <option value="topic.jsp?&forum=6&pageid=1">|----灌水乐园</option>
        <option value="topic.jsp?&forum=7&pageid=1">|----电视电影</option>
        <option value="topic.jsp?&forum=8&pageid=1">|----贴图专区</option>
        <option value="topic.jsp?&forum=9&pageid=1">|----论坛事务</option>
      </select>
</div></td>
  </tr>
</table>
<br>
<br>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="31%" align="right"><img src="images/topic1.gif" width="25" height="14"></td>
    <td width="15%">有回复</td>
    <td width="3%"><img src="images/topic2.gif" width="25" height="14"></td>
    <td width="14%">无回复</td>
    <td width="3%"><img src="images/topic3.gif" width="25" height="14"></td>
    <td width="34%">锁定贴子</td>
  </tr>
</table>
<br>
<%@ include file="footer.jsp"%>
<script language=javascript>
<!--
   function goes(){
     if(document.form1.go_page.value==""||document.form1.go_page.value==0)return false;
     window.location="topic.jsp?forum=<%=request.getParameter("forum")%>&<%=urlpath%>pageid="+document.form1.go_page.value;
   }
//-->
</script>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -