📄 msgdb.java~171~
字号:
ps.setInt(8, expression);
ps.setString(9, "" + System.currentTimeMillis());
ps.setString(10, ip);
ps.setString(11, virtualpath + "/" + picturename);
ps.setString(12, extName);
ps.setInt(13, msgType);
ps.setString(14, votestr);
ps.setString(15, voteresult);
ps.setInt(16, show_ubbcode);
ps.setInt(17, show_smile);
ps.setInt(18, isWebedit);
ps.setString(19, "" + System.currentTimeMillis());
ps.setString(20, "" + System.currentTimeMillis());
ps.setString(21, "" + System.currentTimeMillis());
ps.setInt(22, intIsBlog);
ps.setString(23, blogUserDir);
ps.setString(24, plugin2Code);
ps.setInt(25, email_notify);
ps.setString(26, kind);
ps.setString(27, pluginCode);
re = conn.executePreUpdate()==1?true:false;
conn.commit();
if (re) {
// 保存frmAnnounce中filename上传的文件
if (fInfo != null)
if (!isDdxc) {
fInfo.write(Global.getRealPath() + "forum/" +
virtualpath + "/", picturename);
long attachId = SequenceMgr.nextID(SequenceMgr.SQ_MESSAGE_ATTACH);
sql =
"insert into sq_message_attach (id,fullpath,msgId,name,diskname,visualpath,orders,UPLOAD_DATE,FILE_SIZE,USER_NAME) values (" +
attachId + "," +
StrUtil.sqlstr(mfu.getSavePath() + fInfo.getDiskName()) +
"," + id + "," +
StrUtil.sqlstr(fInfo.getName()) + "," +
StrUtil.sqlstr(fInfo.getDiskName()) + "," +
StrUtil.sqlstr(FilePath) + ",1," +
StrUtil.sqlstr("" + System.currentTimeMillis()) + "," + fInfo.getSize() + "," + StrUtil.sqlstr(name) + ")";
conn.executeUpdate(sql);
UserPrivDb upd = new UserPrivDb();
upd = upd.getUserPrivDb(name);
upd.addAttachTodayUploadCount(1);
// 加分
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, 1);
}
}
}
// 更改用户发贴数 经验值 信用值
UserDb user = new UserDb();
user = user.getUser(name);
user.setAddCount(user.getAddCount() + 1);
user.save();
// 更改用户博客的文章统计信息
if (blog) {
UserConfigDb ucd = new UserConfigDb();
ucd = ucd.getUserConfigDb(name);
ucd.setMsgCount(ucd.getMsgCount() + 1);
ucd.save();
}
// 更改版面最新发贴信息
setBoardNewAddId(id);
// 更改版面统计信息
setBoardStatistic(true);
} 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, name, blog, blogUserDir);
}
if (!issuccess && conn != null) {
conn.close();
conn = null;
}
}
sql = "";
int orders = 1;
try {
mfu.writeFile(false); // 用文件本来的名称命名文件
// 将HTMLCODE中的文件保存至数据库
Vector files = mfu.getFiles();
java.util.Enumeration e = files.elements();
while (e.hasMoreElements()) {
FileInfo fi = (FileInfo) e.nextElement();
filepath = FilePath + "/" + fi.getName();
long imgId = SequenceMgr.nextID(SequenceMgr.SQ_IMAGES);
// System.out.println("filepath=" + filepath);
conn.executeUpdate(
"insert into sq_images (id,path,otherid,kind) values (" +
imgId + "," +
StrUtil.sqlstr(filepath) + "," + id +
",'sq_message')");
}
// 断点续传
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++) {
// 跳过filename文件
if (filenameIndex==i)
continue;
String fpath = mfu.getSavePath() + attachFileNames[i];
String fname = mfu.getUploadFileName(clientFilePaths[i]);
long attachId = SequenceMgr.nextID(SequenceMgr.SQ_MESSAGE_ATTACH);
sql =
"insert into sq_message_attach (id,fullpath,msgId,name,diskname,visualpath,orders,UPLOAD_DATE,USER_NAME) values (" +
attachId + "," +
StrUtil.sqlstr(fpath) + "," + id + "," +
StrUtil.sqlstr(fname) + "," +
StrUtil.sqlstr(attachFileNames[i]) + "," +
StrUtil.sqlstr(FilePath) + "," + orders + "," + StrUtil.sqlstr("" + System.currentTimeMillis()) + "," + StrUtil.sqlstr(name) + ")";
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==mfu.WRITE_ATTACHMENT_SUCCEED) {
Vector attachs = mfu.getAttachments();
Iterator ir = attachs.iterator();
// 将附件保存至数据库
while (ir.hasNext()) {
FileInfo fi = (FileInfo) ir.next();
String fpath = mfu.getSavePath() + fi.getDiskName();
long attachId = SequenceMgr.nextID(SequenceMgr.SQ_MESSAGE_ATTACH);
sql =
"insert into sq_message_attach (id,fullpath,msgId,name,diskname,visualpath,orders,UPLOAD_DATE,FILE_SIZE,USER_NAME) values (" +
attachId + "," +
StrUtil.sqlstr(fpath) + "," + id + "," +
StrUtil.sqlstr(fi.getName()) + "," +
StrUtil.sqlstr(fi.getDiskName()) + "," +
StrUtil.sqlstr(FilePath) + "," + orders +
"," + StrUtil.sqlstr("" + System.currentTimeMillis()) + "," + fi.getSize() + "," + StrUtil.sqlstr(name) + ")";
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(MsgDb.class.getName()).info("AddNewWE:" + e1.getMessage());
} finally {
if (conn != null) {
conn.close();
conn = null;
}
}
} else {
throw new ErrMsgException(mfu.getErrMessage(request));
}
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);
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;
return true;
}
/**
* 发回复贴(普通和UBB方式)
* @param application ServletContext
* @param request HttpServletRequest
* @param name String
* @param fu FileUpload
* @return boolean
* @throws ErrMsgException
*/
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); // "您输入的主题内容太短了,最短不能少于" + MIN_TOPIC_LEN);
if (length > MAX_TOPIC_LEN)
throw new ErrMsgException(LoadString(request, "err_too_large_title") + MAX_TOPIC_LEN); // "您输入的主题内容太长了,最长不能超过" + 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;
rootpath = request.getContextPath();
// 取出被回复的贴子的有关信息
int recount = 0, layer = 1, orders = 1, parentorders = 1;
int parentlayer = 1;
long parentreplyid = -1;
boolean isroot = false;
MsgDb msgDd = getMsgDb(replyid);
if (!msgDd.isLoaded()) {
throw new ErrMsgException(SkinUtil.LoadString(request, "err_msg_replied_lost")); // "回贴不存在!");
}
replyRootName = msgDd.getName();
recount = msgDd.getRecount();
parentlayer = msgDd.getLayer();
layer = parentlayer + 1;
rootid = msgDd.getRootid();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -