📄 msgdb.java
字号:
new Long(id), new Integer(i), voptions[i] }); } } if (!name.equals("")) { UserDb user = new UserDb(); user = user.getUser(name); user.setAddCount(user.getAddCount() + 1); user.save(); } if (blog) { UserConfigDb ucd = new UserConfigDb(); ucd = ucd.getUserConfigDb(blogId); ucd.setMsgCount(ucd.getMsgCount() + 1); ucd.setUpdateDate(new java.util.Date()); ucd.save(); } } catch (SQLException e) { conn.rollback(); Logger.getLogger(MsgDb.class.getName()).error("AddNewWE: " + e.getMessage()); issuccess = false; throw new ErrMsgException(SkinUtil.LoadString(request, SkinUtil.ERR_DB)); } catch (ResKeyException e) { issuccess = false; Logger.getLogger(MsgDb.class.getName()).error("AddNewWE: " + e.getMessage(request)); throw new ErrMsgException(e.getMessage(request)); } finally { if (re) { MsgCache mc = new MsgCache(); mc.refreshAdd(boardcode, blogId, blog, blogUserDir); } if (!issuccess) { if (isFtpUsed) ftp.close(); if (conn != null) { conn.close(); conn = null; } } } sql = ""; int orders = 1; try { Vector files = mfu.getFiles(); if (isFtpUsed) { Iterator ir = files.iterator(); while (ir.hasNext()) { FileInfo fi = (FileInfo) ir.next(); try { ftp.storeFile(virtualpath + "/" + fi.getName(), fi.getTmpFilePath()); } catch (IOException e) { LogUtil.getLog(getClass()).error( "AddNew: storeFile - " + e.getMessage()); } } } else { mfu.writeFile(false); } java.util.Enumeration e = files.elements(); while (e.hasMoreElements()) { FileInfo fi = (FileInfo) e.nextElement(); filepath = virtualpath + "/" + fi.getName(); long imgId = SequenceMgr.nextID(SequenceMgr.SQ_IMAGES); conn.executeUpdate( "insert into sq_images (id,path,otherid,kind,is_remote) values (" + imgId + "," + StrUtil.sqlstr(filepath) + "," + id + ",'sq_message'," + (isFtpUsed?1:0) + ")"); } if (isDdxc) { String[] attachFileNames = mfu.getFieldValues( "attachFileName"); String[] clientFilePaths = mfu.getFieldValues( "clientFilePath"); int len = 0; if (attachFileNames != null) len = attachFileNames.length; int filenameIndex = -1; String attachFileName = StrUtil.getNullString(mfu. getFieldValue("filename")); if (!attachFileName.equals("")) { String strIndex = attachFileName.substring("attachment". length(), attachFileName.length()); if (StrUtil.isNumeric(strIndex)) filenameIndex = Integer.parseInt(strIndex); } for (int i = 0; i < len; i++) { if (filenameIndex == i) continue; String fname = mfu.getUploadFileName(clientFilePaths[i]); long attachId = SequenceMgr.nextID(SequenceMgr. SQ_MESSAGE_ATTACH); sql = "insert into sq_message_attach (id,msgId,name,diskname,visualpath,orders,UPLOAD_DATE,USER_NAME,is_remote,ext) values (" + attachId + "," + id + "," + StrUtil.sqlstr(fname) + "," + StrUtil.sqlstr(attachFileNames[i]) + "," + StrUtil.sqlstr(virtualpath) + "," + orders + "," + StrUtil.sqlstr("" + System.currentTimeMillis()) + "," + StrUtil.sqlstr(name) + "," + (isFtpUsed?1:0) + "," + StrUtil.sqlstr(StrUtil.getFileExt(fname)) + ")"; conn.executeUpdate(sql); orders++; } if (len > 0) { ScoreMgr sm = new ScoreMgr(); Vector vatt = sm.getAllScore(); Iterator iratt = vatt.iterator(); while (iratt.hasNext()) { ScoreUnit su = (ScoreUnit) iratt.next(); IPluginScore ips = su.getScore(); if (ips != null) ips.onAddAttachment(name, len); } } UserPrivDb upd = new UserPrivDb(); upd = upd.getUserPrivDb(name); upd.addAttachTodayUploadCount(len); } else { writeAttachmentResult = mfu.writeAttachment(true); if (writeAttachmentResult == MultiFileUpload.WRITE_ATTACHMENT_SUCCEED) { Vector attachs = mfu.getAttachments(); Iterator ir = attachs.iterator(); ir = attachs.iterator(); while (ir.hasNext()) { FileInfo fi = (FileInfo) ir.next(); long attachId = SequenceMgr.nextID(SequenceMgr. SQ_MESSAGE_ATTACH); sql = "insert into sq_message_attach (id,msgId,name,diskname,visualpath,orders,UPLOAD_DATE,FILE_SIZE,USER_NAME,is_remote,ext) values (" + attachId + "," + id + "," + StrUtil.sqlstr(fi.getName()) + "," + StrUtil.sqlstr(fi.getDiskName()) + "," + StrUtil.sqlstr(virtualpath) + "," + orders + "," + StrUtil.sqlstr("" + System.currentTimeMillis()) + "," + fi.getSize() + "," + StrUtil.sqlstr(name) + "," + (isFtpUsed?1:0) + "," + StrUtil.sqlstr(fi.getExt()) + ")"; conn.executeUpdate(sql); orders++; } if (attachs.size() > 0) { ScoreMgr sm = new ScoreMgr(); Vector vatt = sm.getAllScore(); Iterator iratt = vatt.iterator(); while (iratt.hasNext()) { ScoreUnit su = (ScoreUnit) iratt.next(); IPluginScore ips = su.getScore(); if (ips != null) ips.onAddAttachment(name, attachs.size()); } } UserPrivDb upd = new UserPrivDb(); upd = upd.getUserPrivDb(name); upd.addAttachTodayUploadCount(orders - 1); } } } catch (Exception e1) { Logger.getLogger(getClass()).error("AddNewWE:" + e1.getMessage()); } finally { if (isFtpUsed) ftp.close(); if (conn != null) { conn.close(); conn = null; } } } else { throw new ErrMsgException(mfu.getErrMessage(request)); } if (checkStatus == CHECK_STATUS_PASS) { setBoardNewAddId(id); setBoardStatistic(true, id); } if (writeAttachmentResult == mfu.DISKSPACEUSED_TOO_LARGE) throw new ErrMsgException(LoadString(request, "err_space_full")); return true; } public boolean CheckReply(HttpServletRequest req, FileUpload fu) throws ErrMsgException { String strreplyid = fu.getFieldValue("replyid"); if (strreplyid == null) throw new ErrMsgException(LoadString(req, "err_need_reply_id")); if (!strreplyid.equals("")) replyid = Integer.parseInt(strreplyid); CheckTopic(req, fu); TimeConfig tc = new TimeConfig(); if (tc.isPostNeedCheck(req)) { checkStatus = CHECK_STATUS_NOT; } else { Leaf lf = new Leaf(); lf = lf.getLeaf(boardcode); if (lf.getCheckMsg() == Leaf.CHECK_TOPIC_REPLY) { checkStatus = CHECK_STATUS_NOT; } else checkStatus = CHECK_STATUS_PASS; } return true; } public boolean CheckReplyWE(HttpServletRequest req, FileUpload fu) throws ErrMsgException { String strreplyid = fu.getFieldValue("replyid"); if (strreplyid == null) throw new ErrMsgException(LoadString(req, "err_need_reply_id")); if (!strreplyid.equals("")) replyid = Integer.parseInt(strreplyid); CheckTopicWE(req, fu); isWebedit = WEBEDIT_REDMOON; TimeConfig tc = new TimeConfig(); if (tc.isPostNeedCheck(req)) { checkStatus = CHECK_STATUS_NOT; } else { Leaf lf = new Leaf(); lf = lf.getLeaf(boardcode); if (lf.getCheckMsg() == Leaf.CHECK_TOPIC_REPLY) { checkStatus = CHECK_STATUS_NOT; } else checkStatus = CHECK_STATUS_PASS; } return true; } public synchronized boolean AddReply(ServletContext application, HttpServletRequest request, String name, FileUpload fu) throws ErrMsgException { this.name = name; CheckReply(request, fu); int length = 0; if (title != null) length = title.length(); if (length < MIN_TOPIC_LEN) throw new ErrMsgException(LoadString(request, "err_too_short_title") + MIN_TOPIC_LEN); if (length > MAX_TOPIC_LEN) throw new ErrMsgException(LoadString(request, "err_too_large_title") + MAX_TOPIC_LEN); if (content != null) length = content.length(); if (length < MIN_CONTENT_LEN) throw new ErrMsgException(LoadString(request, "err_too_short_content") + MIN_CONTENT_LEN); if (length > MAX_CONTENT_LEN) throw new ErrMsgException(LoadString(request, "err_too_large_content") + MAX_CONTENT_LEN); int islocked = 0; int recount = 0, layer = 1, orders = 1, parentorders = 1; int parentlayer = 1; long parentreplyid = -1; MsgDb msgReplied = getMsgDb(replyid); if (!msgReplied.isLoaded()) { throw new ErrMsgException(SkinUtil.LoadString(request, "err_msg_replied_lost")); } recount = msgReplied.getRecount(); parentlayer = msgReplied.getLayer(); layer = parentlayer + 1; rootid = msgReplied.getRootid(); blogId = msgReplied.getBlogId(); blog = msgReplied.isBlog(); parentorders = msgReplied.getOrders(); parentreplyid = msgReplied.getReplyid(); islocked = msgReplied.getIsLocked(); if (islocked == 1) throw new ErrMsgException(LoadString(request, "err_locked")); ResultSet rs = null; String sql = ""; boolean isvalid = true; MsgDb rootmsg = getMsgDb(rootid); if (rootmsg.getIsLocked()==1) { throw new ErrMsgException(LoadString(request, "err_locked")); } if (!msgReplied.isRootMsg()) { recount = rootmsg.getRecount(); islocked = rootmsg.getIsLocked(); blogId = rootmsg.getBlogId(); blog = rootmsg.isBlog(); } int intIsBlog = blog ? 1 : 0; Conn conn = new Conn(connname); boolean updat
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -