📄 newcontent_submit.jsp
字号:
while (startIdx != -1) {
int endIdx = startIdx + sFullName.length();
startIdx = sContent.lastIndexOf("=\"/", endIdx);
int startIdx1 = sContent.lastIndexOf("=\'/", endIdx);
int startIdx2 = sContent.lastIndexOf("=/", endIdx);
int startIdx3 = sContent.lastIndexOf(">/", endIdx); // Flash图片索引
startIdx = Math.max(startIdx, startIdx1);
startIdx = Math.max(startIdx, startIdx2);
startIdx = Math.max(startIdx, startIdx3);
if (startIdx == startIdx2 || startIdx == startIdx3)
startIdx++;
else
startIdx = startIdx + 2;
sContent.delete(startIdx, endIdx);
String sUrl = "AttchMap/" + String.valueOf(attchment.getAttch_ID());
sUrl += "/" + sOldFileName;
sContent.insert(startIdx, sUrl);
startIdx = sContent.indexOf(sFullName, startIdx);
}
}
else {
hasAttch = true;
// 将没有用到的附件作为独立附件处理。
attchment.setAttch_Type("2");
}
attchList.add(attchment);
if (!file.delete()) { // 删除文件系统中的附件。
FileLogger.getLogger().warn("附件删除失败:" + sFileName);
}
}
else {
FileLogger.getLogger().info("文件不存在:" + sFileName + ",可能内容中的图片无法显示。");
continue;
}
}
// 处理附件内容。
boolean hasAttchImg = false;
for (int i = 0; sAttchs_img != null && i < sAttchs_img.length; i++) {
if (sAttchs_img[i] == null)
continue;
String aAttch[] = ExtString.split(sAttchs_img[i], "||", null);
if (aAttch.length != 2)
continue;
String sOldFileName = aAttch[1];
String sFileName = aAttch[0];
String sPathName = "/view/bbs/UploadFile/";
String sFullName = sPathName + sFileName;
String realName = application.getRealPath(sFullName);
File file = new File(realName);
if (file.exists() && file.isFile()) {
TF_Attchment attchment1 = new TF_Attchment(db);
attchment1.setFile_Name(sOldFileName);
attchment1.setFile_Size(file.length());
String sExtName = sFileName.substring(sFileName.lastIndexOf("."));
attchment1.setFile_Type(ContentType.getContentType(sExtName));
attchment1.setUpLoad_Time(new Date());
attchment1.setContent_ID(content.getContent_ID());
byte[] bs1 = new byte[(int) attchment1.getFile_Size() + 1];
FileInputStream is = new FileInputStream(file);
if (is.read(bs1, 0, (int) attchment1.getFile_Size()) != -1) {
attchment1.setFile_Content(bs1);
}
else {
FileLogger.getLogger().warn("文件读取数据失败。");
continue;
}
is.close(); // 关闭连接。
String sUrl = "AttchMap/" + String.valueOf(attchment1.getAttch_ID());
sUrl += "/" + sOldFileName;
sMood_Icon=sUrl;
// 将没有用到的附件作为独立附件处理。
attchment1.setAttch_Type("4");
attchList.add(attchment1);
if (!file.delete()) { // 删除文件系统中的附件。
FileLogger.getLogger().warn("附件删除失败:" + sFileName);
}
}
else {
FileLogger.getLogger().info("文件不存在:" + sFileName + ",可能内容中的图片无法显示。");
continue;
}
}
// 处理系统小图片内容。
ExtString.replace(sContent, "<IMG src=\"/manager/view/bbs/sysimage/","<IMG src=\"sysimage/");
// 插件新内容。
if (hasAttch) {
content.setExist_Attch("1");
}
else {
content.setExist_Attch("0");
}
if (content.getFirst_Content_ID() == 0) {
content.setFirst_Content_ID(content.getContent_ID());
}
content.setRecommend(sRecommend);
content.setBoard_ID(lParentId);
content.setAccount_ID(auth.getUserID());
content.setAccount_Name(auth.getUserCode());
content.setUser_Name(auth.getUserName());
content.setMood_Icon(sMood_Icon);
content.setTitle(sTitle);
content.setContent(sContent.toString());
content.setMark_ID(mark.getMark_ID());
content.setCreate_Time(new Date());
content.setTip_Order(0);
content.setExtract_Sign("0");
content.setReply_Count(0);
content.setReply_Account_ID(auth.getUserID());
content.setReply_User_Name(auth.getUserName());
content.setLast_Click_Time(new Date());
content.setLast_Reply_Time(new Date());
content.setClick_Count(0);
//N代表未通过审核 qiuzb update
content.setDelete_Sign("N");
if(startTime !=null && !startTime.equals(""))
content.setStartTime(format.parse( startTime));
else content.setStartTime(new Date());
if(endTime !=null && !endTime.equals(""))
content.setEndTime(format.parse(endTime));
else content.setEndTime(format.parse("2999-01-01"));
content.setBoardCode(sBoardcode);
content.setContentCode(sContentCode);
if (sCount_Out != null)
content.setCount_Out(Integer.parseInt(sCount_Out));
else
content.setCount_Out(0);
// 02 表示内容
if(contentType==null || contentType.equals("")) contentType="02";
content.setContentType(contentType);
content.save();
// 保存嵌入内容中的附件。
StringBuffer attchName = new StringBuffer();
for (int i = 0; i < attchList.size(); i++) {
TF_Attchment attch = (TF_Attchment) attchList.get(i);
if (attchName.indexOf("||" + attch.getFile_Name() + "||") != -1) {
throw new RuntimeException("您上传的附件有重名,请检查后重新上传。");
}
attchName.append("||").append(attch.getFile_Name()).append("||");
attch.save();
}
// 处理独立的附件。
db.endTransaction(true);
if (content.getUp_Content_ID() > 0) {
String ref = request.getHeader("referer");
if (ref.toLowerCase().indexOf("replycontent.jsp") != -1) {
out.write("<script language=javascript>window.location.href='ViewContent.jsp?id="
+ String.valueOf(content.getFirst_Content_ID()) + "';</script>");
}
else {
out.write("<script language=javascript>window.location.href='"
+ request.getHeader("referer") + "';</script>");
}
}
else {
out.write("<script language=javascript>window.location.href='" + request.getContextPath()
+ "/view/sysmgr/OperSuccess.jsp';</script>");
}
}
catch (Exception ex) {
try {
db.endTransaction(false);
}
catch (Exception e) {}
out.write("<script language=javascript>window.location.href='" + request.getContextPath()
+ "/view/sysmgr/OperFailure.jsp?error=" + Util.Replace(ex.getMessage())
+ "';</script>");
FileLogger.getLogger().warn(ex.getMessage(), ex);
}
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -