📄 post.java
字号:
package com.laoer.bbscs.bbs;import java.sql.*;import java.io.*;import java.util.*;import com.laoer.bbscs.db.*;import com.laoer.bbscs.txthtml.*;/** * <p>Title: BBS-CS</p> * <p>Description: BBS-CS(BBS式虚拟社区系统)</p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: loveroom.com.cn</p> * @author 龚天乙(laoer) * @version 3.0 */public class Post { String SQL = ""; DbTrans DBSQL; DoText myDoText; ResultSet rs = null; public Post() { this.DBSQL = new DbTrans(); this.myDoText = new DoText(); } public int getFourmMaxID() { int numMaxID = 1; SQL = "select max(id)+1 as numMaxID from forum"; try { rs = DBSQL.executeQuery(SQL); if (rs.next()) { numMaxID = rs.getInt("numMaxID"); } rs.close(); if (numMaxID == 0) { numMaxID = 1; } } catch (SQLException e) { } return numMaxID; } public boolean addForum(int id,int id1,int id2,String board, String boardsname, String bq ,String strUserID ,String strUserName,String title, String detail, String sign_detail, String artsize, int email_inform, int msg_inform,String IP,int isNew, String strUserNickName) { SQL = "insert into forum (id,id1,id2,board,boardname,bq,UID,name,title,detail,sign,artsize,email_inform,msg_inform,time,lasttime,ip,vtime,new,nickname) values ('"+ id +"','"+id1+"','"+id2+"','"+ board +"','"+ boardsname +"','"+ bq +"','"+ strUserID +"','"+ strUserName +"','"+ title +"','"+ detail +"','"+ sign_detail +"','"+ artsize +"','"+ email_inform +"','"+ msg_inform +"',now(),now(),'"+ IP +"',now(),'"+isNew+"','"+ strUserNickName +"')"; try { DBSQL.executeUpdate(SQL); return true; } catch (SQLException e) { return false; } } public int getForumID(int id1,int id2,String board, String boardsname, String bq ,String strUserID ,String strUserName,String title, String detail, String sign_detail, String artsize, int email_inform, int msg_inform,String IP,int isNew,String strUserNickName) { int id = getFourmMaxID(); int i = 0; while (!addForum(id, id1,id2,board, boardsname, bq ,strUserID ,strUserName,title,detail, sign_detail,artsize,email_inform, msg_inform,IP, isNew, strUserNickName)) { i++; id = getFourmMaxID(); if (i >= 100) { return 0; } } return id; } public void setUpdateForum(int id) { SQL = "update forum set id2="+ id +" where id="+ id; try { DBSQL.executeUpdate(SQL); } catch (SQLException e) { } } public String setPost(int id1,int id2,String board, String boardsname, String bq ,String strUserID ,String strUserName,String title, String detail, String sign_detail, String artsize, int email_inform, int msg_inform,String IP,int isNew, String strUserNickName) { int id = getForumID(id1,id2,board, boardsname, bq ,strUserID ,strUserName,title,detail, sign_detail,artsize,email_inform, msg_inform,IP,isNew,strUserNickName); String sendShowDoc = ""; if (id!=0) { setUpdateForum(id); setInForm(strUserID, strUserName,id,board,email_inform, msg_inform); sendShowDoc = "showdoc.jsp?recid="+id+"&bid="+board; } else { sendShowDoc = "right.jsp?bid="+board+"&pages=1"; } return sendShowDoc; } public boolean setInForm(String strUserID, String strUserName,int id,String board,int email_inform, int msg_inform) { if (email_inform==1 || msg_inform==1) { SQL = "insert into dy (UID,Uname,RID,BID,email_inform,msg_inform) values ('"+ strUserID +"','"+ strUserName +"','"+ id +"','"+ board +"','"+ email_inform +"','"+ msg_inform +"')"; try { DBSQL.executeUpdate(SQL); return true; } catch (SQLException e) { return false; } } else { return false; } } public String setRePost(int id1,int id2,String board, String boardsname, String bq ,String strUserID ,String strUserName,String title, String detail, String sign_detail, String artsize, int email_inform, int msg_inform,String IP,int isNew, String strUserNickName) { int id = getForumID(id1,id2,board, boardsname, bq ,strUserID ,strUserName,title,detail, sign_detail,artsize,email_inform, msg_inform,IP,isNew,strUserNickName); String sendShowDoc = ""; if (id!=0) { setUpdateReNum(id2); setReInForm(id2, strUserID, strUserName,id2,board,email_inform,msg_inform); setCannotRe(id1); setSendMsgEmail(id2,board,title,strUserID,strUserName); sendShowDoc = "showdoc.jsp?recid="+id2+"&bid="+board; } else { sendShowDoc = "showdoc.jsp?recid="+id2+"&bid="+board; } return sendShowDoc; } public void setChangeForum(String recid,String bq ,String title,String detail,String artsize,String IP,String amend) { SQL = "update forum set bq='"+bq+"',title='"+title+"',detail='"+ detail +"',ip='"+IP+"',amend='"+ amend +"' where id = "+recid; try { DBSQL.executeUpdate(SQL); } catch (SQLException e) { } } public boolean setReInForm(int mainid, String strUserID, String strUserName,int id,String board,int email_inform, int msg_inform) { int dynum = 0; SQL = "select count(*) as dynum from dy where UID="+ strUserID +" and RID="+ mainid; try { rs = DBSQL.executeQuery(SQL); if (rs.next()) { dynum = rs.getInt("dynum"); } rs.close(); } catch (SQLException e) { } if (dynum == 0) { if (setInForm(strUserID, strUserName,id,board,email_inform, msg_inform)) { return true; } else { return false; } } else { return false; } } public void setUpdateReNum(int mainid) { SQL = "update forum set re=re+1, lasttime=now() where id="+ mainid; try { DBSQL.executeUpdate(SQL); } catch (SQLException e) { } } public void setSendMsgEmail(int mainid,String board,String title,String strUserID,String strUserName) { SQL = "select * from dy where RID="+ mainid; String SQL1 = ""; String note = ""; try { rs = DBSQL.executeQuery(SQL); while (rs.next()) { if (rs.getInt("msg_inform") == 1) { note = "<a href=showdoc.jsp?recid="+ mainid +"&bid="+ board +">"+ title +"</a>"; SQL1 = "insert into guestbook set UID='"+ rs.getInt("UID") +"',Uname=\""+ rs.getString("Uname") +"\",FID='"+ strUserID +"',Fname=\""+ strUserName +"\",mtype='1',note=\""+ note +"\",stime=now()"; DBSQL.executeUpdate(SQL1); } if (rs.getInt("email_inform") == 1) { } } rs.close(); } catch (SQLException e) { } } public void setCannotRe(int recid) { SQL = "update forum set cannotre = 1 where id = "+recid; try { DBSQL.executeUpdate(SQL); } catch (SQLException e) { } } public void close() { try { DBSQL.close(); } catch (SQLException e) { } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -