📄 dbforum.java
字号:
"readAction.do?sid=###&recid=" + this.myForumInfo.getID2() +
"&bid=" + this.myForumInfo.getBoardID() + ">" +
this.myForumInfo.getTitle() + "</a>";
aGuestBookInfo.setNote(note);
aGuestBook.setGuestBookInfo(aGuestBookInfo);
aGuestBook.createGuestBook(myDBTrans);
}
aGuestBookInfo = null;
aGuestBook = null;
}
aSubscibeInfo = null;
if (this.myForumInfo.getEmail_Inform() == 1 ||
this.myForumInfo.getMsg_Inform() == 1) {
aSubscibeInfo = new SubscibeInfo();
aSubscibeInfo.setID(String.valueOf(this.myForumInfo.getPostTime()) +
String.valueOf(this.myForumInfo.getUserID()));
aSubscibeInfo.setBID(this.myForumInfo.getBoardID());
aSubscibeInfo.setRID(this.myForumInfo.getID2());
ForumInfo afi = new ForumInfo();
afi.setBoardID(this.myForumInfo.getBoardID());
afi.setID(this.myForumInfo.getID2());
Forum af = ForumFactory.getInstance();
af.setForumInfo(afi);
af.getPost(myDBTrans, "ID", true);
aSubscibeInfo.setPostTitle(af.getForumInfo().getTitle());
afi = null;
af = null;
aSubscibeInfo.setUserID(this.myForumInfo.getUserID());
aSubscibeInfo.setUname(this.myForumInfo.getUserName());
aSubscibeInfo.setEmail_inform(this.myForumInfo.getEmail_Inform());
aSubscibeInfo.setMsg_inform(this.myForumInfo.getMsg_Inform());
aSubscibe.setSubscibeInfo(aSubscibeInfo);
int repeat = aSubscibe.getSubscibe(myDBTrans, "repeat", false);
if (repeat == Sys.RESULT_OBJECTNOEXISTEXCEPTION) {
aSubscibe.createSubscibe(myDBTrans);
}
aSubscibeInfo = null;
aSubscibe = null;
}
//处理版面信息
/*暂不处理版面信息
Boards myBoards = BoardsFactory.getInstance();
this.myBoardsInfo = this.myUserSessionCheck.getTheBoards();
this.myBoardsInfo.setLastPostID(this.myForumInfo.getID2());
this.myBoardsInfo.setLastPostTime(this.myForumInfo.getPostTime());
this.myBoardsInfo.setLastPostTitle(this.myForumInfo.getTitle());
this.myBoardsInfo.setLastPostUser(this.myForumInfo.getUserName());
this.myBoardsInfo.setLastPostUserID(this.myForumInfo.getUserID());
myBoards.setBoardsInfo(this.myBoardsInfo);
myBoards.updateBoards(myDBTrans, "PostNums");
myBoards.updateBoards(myDBTrans, "LastPost");*/
}
//处理气力值,文章数
if (!this.myUserSessionCheck.getiAttribs()[3]) {
if (this.myForumInfo.getArtSize() > 20) {
if (myUserSessionCheck.isSuperAdmin() ||
myUserSessionCheck.isManager() ||
myUserSessionCheck.isBoardManager() ||
myUserSessionCheck.isMainMaster()) {
this.myUserInfo.setArticleNum(this.myUserInfo.getArticleNum() + 1);
User myUser = UserFactory.getInstance();
myUser.setUserInfo(myUserInfo);
myUser.updateUser(myDBTrans, "datapost");
}
else {
this.myUserInfo.setArticleNum(this.myUserInfo.getArticleNum() + 1);
this.myUserInfo.setPower(this.myUserInfo.getPower() - 1);
User myUser = UserFactory.getInstance();
myUser.setUserInfo(myUserInfo);
myUser.updateUser(myDBTrans, "datapost");
}
}
else {
if (myUserSessionCheck.isSuperAdmin() ||
myUserSessionCheck.isManager() ||
myUserSessionCheck.isBoardManager() ||
myUserSessionCheck.isMainMaster()
) {
}
else {
this.myUserInfo.setPower(this.myUserInfo.getPower() - 1);
User myUser = UserFactory.getInstance();
myUser.setUserInfo(myUserInfo);
myUser.updateUser(myDBTrans, "datapost");
}
}
}
return Sys.RESULT_RIGHT;
}
catch (ObjectException e) {
logger.error(e);
return Sys.RESULT_OBJECTEXCEPTION;
}
catch (IOException e) {
logger.error(e);
return Sys.RESULT_OBJECTEXCEPTION;
}
finally {
if (aTranContext == null && myDBTrans != null) {
myDBTrans.freeCon();
}
}
}
public int createPost(TranContext aTranContext, String key, FormFile formFile) {
TranContext myDBTrans = null;
if (aTranContext == null) {
myDBTrans = new TranContext();
}
else {
myDBTrans = aTranContext;
}
try {
this.createPost(myDBTrans, key);
InputStream stream = formFile.getInputStream();
OutputStream bos = new FileOutputStream(Util.getImgPath(String.valueOf(this.
myForumInfo.getBoardID()), this.myForumInfo.getPostTime()) +
this.myForumInfo.getPicName());
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ( (bytesRead = stream.read(buffer, 0, 8192)) != -1) {
bos.write(buffer, 0, bytesRead);
}
bos.close();
stream.close();
bos = null;
stream = null;
return Sys.RESULT_RIGHT;
}
/*
catch (ObjectException e) {
logger.error(e);
return Sys.RESULT_OBJECTEXCEPTION;
}*/
catch (FileNotFoundException fnfe) {
logger.error(fnfe);
return Sys.RESULT_OBJECTEXCEPTION;
}
catch (IOException ioe) {
logger.error(ioe);
return Sys.RESULT_OBJECTEXCEPTION;
}
finally {
if (aTranContext == null && myDBTrans != null) {
myDBTrans.freeCon();
}
}
}
public int changePost(TranContext aTranContext) {
TranContext myDBTrans = null;
if (aTranContext == null) {
myDBTrans = new TranContext();
}
else {
myDBTrans = aTranContext;
}
try {
String filename = "post_" + this.myForumInfo.getID() + "_" +
this.myForumInfo.getBoardID() + "_" + this.myForumInfo.getPostTime() +
".html";
String filepath = Util.getForumPath(String.valueOf(this.myForumInfo.
getBoardID()), this.myForumInfo.getPostTime());
File file = new File(filepath + filename);
if (file.exists()) {
file.delete();
}
StringBuffer sb = new StringBuffer();
sb.append("<html><head><title>");
sb.append(this.myForumInfo.getTitle());
sb.append("</title><body>");
sb.append(this.myForumInfo.getDetail());
sb.append("</body></html>");
FileOutputStream wf = new FileOutputStream(filepath + filename);
if (Sys.isLocale()) {
wf.write(sb.toString().getBytes());
}
else {
wf.write(sb.toString().getBytes("UTF8"));
}
wf.close();
this.myForumInfo.setDetail(filename);
this.updateDB(myDBTrans, "change");
Sys.CACHE.remove(String.valueOf(this.myForumInfo.getID())); //从Cache清除
if ( (this.myForumInfo.getArtSize() <= 20) &&
! (myUserSessionCheck.isSuperAdmin() || myUserSessionCheck.isBMaster() ||
myUserSessionCheck.isMainMaster() ||
myUserSessionCheck.isAssiMaster() ||
myUserSessionCheck.isHideMaster())) {
User myUser = myUserSessionCheck.getUser();
this.myUserInfo.setPower(this.myUserInfo.getPower() - 1);
myUser.setUserInfo(myUserInfo);
myUser.updateUser(myDBTrans, "datapost");
}
return Sys.RESULT_RIGHT;
}
catch (ObjectException e) {
logger.error(e);
return Sys.RESULT_OBJECTEXCEPTION;
}
catch (IOException ioe) {
logger.error(ioe);
return Sys.RESULT_OBJECTEXCEPTION;
}
finally {
if (aTranContext == null && myDBTrans != null) {
myDBTrans.freeCon();
}
}
}
public int realDelPosts(TranContext aTranContext, String[] parm2,
String key) {
int len = 0;
String sPostIDs = "";
if (!key.equals("delall")) {
len = parm2.length;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < len; i++) {
sb.append(parm2[i] + ",");
}
sPostIDs = sb.toString();
if (sPostIDs.endsWith(",")) {
sPostIDs = sPostIDs.substring(0, sPostIDs.length() - 1);
this.sDelPostIDs = sPostIDs;
}
}
List myList = null;
TranContext myDBTrans = null;
if (aTranContext == null) {
myDBTrans = new TranContext();
}
else {
myDBTrans = aTranContext;
}
try {
myList = this.loadDBs(myDBTrans, key);
int flen = myList.size();
ForumInfo afi = null;
for (int i = 0; i < flen; i++) {
afi = (ForumInfo) myList.get(i);
String filepath = Util.getForumPath(String.valueOf(afi.getBoardID()),
afi.getPostTime());
File file = new File(filepath + afi.getDetail());
if (file.exists()) {
file.delete();
}
}
this.delDB(myDBTrans, key);
return Sys.RESULT_RIGHT;
}
catch (ObjectException e) {
logger.error(e);
return Sys.RESULT_RIGHT;
}
finally {
if (aTranContext == null && myDBTrans != null) {
myDBTrans.freeCon();
}
}
}
public int delaPost(TranContext aTranContext, String key, int de) {
TranContext myDBTrans = null;
if (aTranContext == null) {
myDBTrans = new TranContext();
}
else {
myDBTrans = aTranContext;
}
try {
this.updateDB(myDBTrans, "delaPost");
NewPost.delNewPost(this.myForumInfo.getID());
Sys.CACHE.remove(String.valueOf(this.myForumInfo.getID())); //从Cache清除
if (de == 0) {
Boards aBoards = BoardsFactory.getInstance();
aBoards.setBoardsInfo(this.myUserSessionCheck.getTheBoards());
if (this.myForumInfo.getID() != this.myForumInfo.getID2()) {
ForumInfo afi = new ForumInfo();
afi.setBoardID(this.myForumInfo.getBoardID());
afi.setID(this.myForumInfo.getID2());
Forum af = ForumFactory.getInstance();
af.setForumInfo(afi);
af.updatePost(myDBTrans, "decReNum");
aBoards.updateBoards(myDBTrans, "DecPostNums");
afi = null;
af = null;
}
else {
aBoards.updateBoards(myDBTrans, "DecPostMainNum");
}
aBoards = null;
UserInfo ui = new UserInfo();
ui.setID(this.myForumInfo.getUserID());
User au = UserFactory.getInstance();
au.setUserInfo(ui);
if (au.getUser(myDBTrans, "ID", true) == Sys.RESULT_RIGHT) {
ui = au.getUserInfo();
if (ui.getArticleNum() >= 1 && this.myForumInfo.getArtSize() > 20) {
BoardsMaster pBoardsMaster = new BoardsMaster(ui.getUserName(),
this.myUserSessionCheck.getTheBoards());
if (!pBoardsMaster.isMainMaster() &&
!this.myUserSessionCheck.
getTheBoard().getBMaster().equals(this.myForumInfo.getUserName())) {
ui.setArticleNum(ui.getArticleNum() - 1);
if (this.myForumInfo.getElite() != 0 && ui.getExpression() > 5) {
ui.setExpression(ui.getExpression() - 5);
}
au.setUserInfo(ui);
au.updateUser(myDBTrans, "datapost");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -