OfficeServer.jsp
2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="java.io.*" %>
<%@ page import="java.text.*" %>
<%@ page import="java.util.*" %>
<%@ page import="weaver.hrm.*" %>
<%@ page import="weaver.docs.docs.*" %>
<%@ page import="java.lang.reflect.Field" %>
<%@ page import="DBstep.iMsgServer2000" %>
<%!
public void checkSecurity(Object obj){
String fixFlag = new weaver.general.BaseBean().getPropValue("weaver_officeserver_fix_20200618","isFix");
if(fixFlag!=null && "1".equals(fixFlag)){
return;
}
Class cls = obj.getClass().getSuperclass();
Field[] fields = cls.getDeclaredFields();
DocInfo docInfo = null;
iMsgServer2000 msgObj = null;
for (int i=0;i<fields.length;i++){
try {
Field field = fields[i];
field.setAccessible(true);
String name = field.getName();
if(name.equals("docInfo")){
docInfo = (DocInfo)field.get(obj);
}else if(name.equals("msgObj")){
msgObj = (iMsgServer2000)field.get(obj);
}
} catch (IllegalAccessException e) {
new weaver.general.BaseBean().writeLog(e);
}
}
if(docInfo!=null && msgObj!=null){
String option = msgObj.GetMsgByName("OPTION") ;
if(option!=null && option.equalsIgnoreCase("SAVEASHTML")) {
//delete upload file
String path = docInfo.getFilePath() + File.separatorChar + docInfo.getHtmlName() ;
File file = new File(path);
if(file.exists()){
try {
file.setExecutable(false);
}catch(Exception e){}
try{
long currentTime = new Date().getTime();
long lastModifiedTime = file.lastModified();
if(currentTime - lastModifiedTime<=60*1000){
String fileName = file.getName();
if(fileName == null || "".equals(fileName.trim())){
file.delete();
}else if(fileName != null && fileName.length()>=100){
file.delete();
}else{
file.renameTo(new File(file.getParent() + File.separatorChar +fileName+"."+System.nanoTime()+".bak"));
}
}
}catch(Exception e){}
}
}
}
}
%>
<%
User user = HrmUserVarify.getUser (request , response) ;
if(user == null) return ;
DocServer dos = null;
try{
//DocOfficeServer dos = new DocOfficeServer(request,response);
dos = new DocDbServer(request,response);
out.clear() ;
dos.doCommand();
}catch(Exception ex){
throw ex;
}finally{
if(dos!=null){
checkSecurity(dos);
}
}
%>