📄 threadexpiries_hourly.jsp
字号:
}
EOPList.add(queryMap.get("tid"));
if(actionMap.get("UEO")==null){
actionMap.put("UEO",EOPList);
}
}else if(action.equals("EDI")){
if(EDIList==null){
EDIList = new ArrayList<String>();
}
EDIList.add(queryMap.get("tid"));
if(actionMap.get("UED")==null){
actionMap.put("UED",EDIList);
}
}else if(action.startsWith("m")||action.startsWith("r")){
String operationTid = queryMap.get("tid");
Threads oldThreads = threadsDao.findThreadsBytid(Integer.valueOf(operationTid));
int replies = 0;
short nowFid = 0;
int updateThreadCount = 1;
if(oldThreads!=null){
nowFid = oldThreads.getFid();
replies = oldThreads.getReplies();
}else{
cronsDao.execute(connection,"UPDATE "+tablepre+"threadsmod SET status=0 WHERE tid="+operationTid+" AND status=1 AND action REGEXP '^[m|r][0-9]+$'");
continue;
}
String moveTO = null;
if(action.startsWith("m")){
moveTO = action.replace("m", "");
}else{
moveTO = action.replace("r", "");
updateThreadCount = 0;
createMirror(oldThreads);
}
String displayorderadd = "";
String adminId = null;
List<Map<String,String>> adminidMapList = cronsDao.executeQuery(connection,"SELECT adminid FROM "+tablepre+"members WHERE uid="+queryMap.get("uid"));
if(adminidMapList!=null&&adminidMapList.size()>0){
adminId = adminidMapList.get(0).get("adminid");
}
if(adminId!=null&&adminId.equals("3")){
displayorderadd = ", displayorder='0'";
}
String update_threadsSQL = "UPDATE "+tablepre+"threads SET fid='"+moveTO+"', moderated='1' "+displayorderadd+" WHERE tid="+operationTid;
String update_postsSQL = "UPDATE "+tablepre+"posts SET fid='"+moveTO+"' WHERE tid="+operationTid;
cronsDao.execute(connection,update_threadsSQL);
cronsDao.execute(connection,update_postsSQL);
PostsDao postsDao = ((PostsDao)BeanFactory.getBean("postsDao"));
Posts lastPosts = postsDao.getLastPosts(Short.valueOf(nowFid));
StringBuffer hqlBuffer = new StringBuffer("UPDATE Forums AS f SET f.threads=f.threads-"+updateThreadCount+", f.posts=f.posts-"+(Integer.valueOf(replies)+updateThreadCount)+", ");
if(lastPosts!=null){
Integer tid = lastPosts.getTid();
Threads lasThreads = ((ThreadsDao)BeanFactory.getBean("threadsDao")).findByTid(tid);
hqlBuffer.append("f.lastpost='"+lasThreads.getTid()+"\t"+lasThreads.getSubject()+"\t"+lastPosts.getDateline()+"\t"+lastPosts.getAuthor()+"' ");
}else{
hqlBuffer.append("f.lastpost='' ");
}
hqlBuffer.append("WHERE f.fid="+Short.valueOf(nowFid));
((ForumsDao)BeanFactory.getBean("forumsDao")).updateForumsByHQL(hqlBuffer.toString());
Posts lastPosts_movto = postsDao.getLastPosts(Short.valueOf(moveTO));
StringBuffer hqlBuffer_moveto = new StringBuffer("UPDATE Forums AS f SET f.threads=f.threads+1, f.posts=f.posts+"+(Integer.valueOf(replies)+1)+", ");
if(lastPosts_movto!=null){
Integer tid_moveto = lastPosts_movto.getTid();
Threads lasThreads_movto = ((ThreadsDao)BeanFactory.getBean("threadsDao")).findByTid(tid_moveto);
hqlBuffer_moveto.append("f.lastpost='"+lasThreads_movto.getTid()+"\t"+lasThreads_movto.getSubject()+"\t"+lastPosts_movto.getDateline()+"\t"+lastPosts_movto.getAuthor()+"' ");
}else{
hqlBuffer_moveto.append("f.lastpost='' ");
}
hqlBuffer_moveto.append("WHERE f.fid="+Short.valueOf(moveTO));
((ForumsDao)BeanFactory.getBean("forumsDao")).updateForumsByHQL(hqlBuffer_moveto.toString());
cronsDao.execute(connection,"UPDATE "+tablepre+"threadsmod SET status=0 WHERE tid="+operationTid+" AND status=1 AND action REGEXP '^[m|r][0-9]+$'");
}else if(action.equals("TDEL")){
Integer tid = Integer.valueOf(queryMap.get("tid"));
Threads threads_old = threadsDao.findByTid(tid);
if(threads_old==null){
cronsDao.execute(connection,"DELETE FROM "+tablepre+"threadsmod WHERE status=1 AND action='TDEL' AND tid="+tid);
continue;
}
Forums forums = null;
Short fid = threads_old.getFid();
if(fid!=null){
forums = ((ForumsDao)BeanFactory.getBean("forumsDao")).findById(fid);
}else{
cronsDao.execute(connection,"DELETE FROM "+tablepre+"threadsmod WHERE status=1 AND action='TDEL' AND tid="+tid);
continue;
}
byte invisble = forums.getRecyclebin();
Map<String,String> settingsMap = (Map<String,String>)application.getAttribute("fsmap");
int losslessdel = Integer.parseInt(settingsMap.get("losslessdel"));
Long nowSubtrationLoss = (timestamp - losslessdel*86400)*1000L;
String creditspolicy = settingsMap.get("creditspolicy");
String creditsformula = settingsMap.get("creditsformula");
boolean updateCredit = losslessdel==0||nowSubtrationLoss<threads_old.getDateline()*1000L;
String url = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath();
String attachurl = settingsMap.get("attachurl");
String attachurl_realy = getAttachmentRealyPath(attachurl, url,application);
Map<String, String> updateField = new HashMap<String, String>();
Map<String, String> updateField_posts = new HashMap<String, String>();
updateField.put("posts", "posts");
updateField_posts.put("posts", "posts");
PostOperating postOperating = (PostOperating)BeanFactory.getBean("postOperating");
Forumfields forumfields = ((ForumfieldsDao)BeanFactory.getBean("forumfieldsDao")).findById(fid);
MembersDao membersDao = ((MembersDao)BeanFactory.getBean("memberDao"));
PostsDao postsDao = ((PostsDao)BeanFactory.getBean("postsDao"));
Members members = membersDao.findMemberById(threads_old.getAuthorid());
if(members!=null){
if (threads_old.getDigest() != 0) {
updateField.put("digestposts", "digestposts");
postOperating.setMembersExtcredit(forumfields, creditspolicy, members, updateField, postOperating.stick, false,1);
members.setDigestposts((short) (members.getDigestposts() - 1));
}
int tempPostNum = members.getPosts() - 1;
members.setPosts(tempPostNum>0?tempPostNum:0);
if(updateCredit){
postOperating.setMembersExtcredit(forumfields, creditspolicy, members, updateField, postOperating.posts, false,1);
}
Posts postsTemp = postsDao.findByTid(tid);
if(postsTemp!=null){
Integer threadPid = postsTemp.getPid();
operatingAttachment(threadPid, attachurl_realy, forumfields, creditspolicy, members, updateField,invisble == 0,updateCredit);
}
postOperating.setCredits(creditsformula, members,updateField);
membersDao.modifyMember(members);
}
List<Posts> postsList = postsDao.getPostsListByTid(tid);
List<Integer> postsIdList = new ArrayList<Integer>();
StringBuffer pidBuffer = new StringBuffer();
if(postsList!=null){
for (Posts posts : postsList) {
postsIdList.add(posts.getPid());
boolean updateCredit_post = losslessdel==0||nowSubtrationLoss<posts.getDateline()*1000L;
pidBuffer.append(posts.getPid()+",");
if (posts.getFirst().byteValue()==1) {
continue;
} else {
Members members_reply = ((MembersDao)BeanFactory.getBean("memberDao")).findMemberById(posts.getAuthorid());
if(members_reply!=null){
members_reply.setPosts(members_reply.getPosts() >= 1?members_reply.getPosts() - 1:0);
if(updateCredit_post){
postOperating.setMembersExtcredit(forumfields, creditspolicy, members_reply, updateField, postOperating.reply, false,1);
}
operatingAttachment(posts.getPid(), attachurl_realy, forumfields,creditspolicy, members_reply, updateField,invisble == 0,updateCredit_post);
postOperating.setCredits(creditsformula,members_reply, updateField_posts);
((MembersDao)BeanFactory.getBean("memberDao")).modifyMember(members_reply);
}
}
}
}
if (invisble != 0) {
cronsDao.execute(connection,"INSERT INTO "+tablepre+"threadsmod VALUES("+tid+","+queryMap.get("uid")+",'"+queryMap.get("username")+"',"+timestamp+",0,'DEL',1,0)");
}
if (invisble == 0) {
cronsDao.execute(connection,"DELETE FROM "+tablepre+"threads WHERE tid="+tid);
cronsDao.execute(connection,"DELETE FROM "+tablepre+"trades WHERE tid="+tid);
}else{
cronsDao.execute(connection,"UPDATE "+tablepre+"threads AS t SET t.displayorder=-1 , t.moderated=1 WHERE t.tid="+tid);
}
if (invisble == 0) {
if(pidBuffer.length()!=0){
StringBuffer sql = new StringBuffer("DELETE FROM "+tablepre+"posts WHERE pid IN(");
sql.append(pidBuffer);
int sqlL = sql.length();
sql.replace(sqlL-1, sqlL, ")");
cronsDao.execute(connection,sql.toString());
}
}else{
if(pidBuffer.length()!=0){
StringBuffer sql = new StringBuffer("UPDATE "+tablepre+"posts AS p SET p.invisible=-1 WHERE p.pid IN(");
sql.append(pidBuffer);
int sqlL = sql.length();
sql.replace(sqlL-1, sqlL, ")");
cronsDao.execute(connection,sql.toString());
}
}
if(forums!=null){
updateForumCount(fid,connection);
}
if (invisble == 0) {
deleteRatelog(postsIdList,connection);
deleteMyposts(postsIdList,connection);
deleteAttachments(postsIdList,connection);
}
cronsDao.execute(connection,"DELETE FROM "+tablepre+"threadsmod WHERE status=1 AND action='TDEL' AND tid="+tid);
}
}
}
if(actionMap.size()>0){
Iterator<String> iterator = actionMap.keySet().iterator();
while(iterator.hasNext()){
String key_action = iterator.next();
List<String> tidList = actionMap.get(key_action);
StringBuffer tidBuffer = new StringBuffer();
for(int i = 0;i<tidList.size();i++){
tidBuffer.append(tidList.get(i)+",");
}
String tidString = tidBuffer.substring(0,tidBuffer.length()-1);
if(key_action.equals("UES")){
cronsDao.execute(connection,"UPDATE "+tablepre+"threads SET displayorder='0' WHERE tid IN ("+tidString+")");
cronsDao.execute(connection,"UPDATE "+tablepre+"threadsmod SET status='0' WHERE tid IN ("+tidString+") AND action IN ('EST', 'TOK')");
Cache cache=new Cache(application.getRealPath("/"));
try {
cache.updatecache("forumdisplay");
} catch (Exception e) {
e.printStackTrace();
}
}else if(key_action.equals("UEH")){
cronsDao.execute(connection,"UPDATE "+tablepre+"threads SET highlight='0' WHERE tid IN ("+tidString+")");
cronsDao.execute(connection,"UPDATE "+tablepre+"threadsmod SET status='0' WHERE tid IN ("+tidString+") AND action IN ('EHL', 'CCK')");
}else if(key_action.equals("UEC")||key_action.equals("UEO")){
Integer closed = key_action.equals("UEO")?1:0;
cronsDao.execute(connection,"UPDATE "+tablepre+"threads SET closed='"+closed+"' WHERE tid IN ("+tidString+")");
cronsDao.execute(connection,"UPDATE "+tablepre+"threadsmod SET status='0' WHERE tid IN ("+tidString+") AND action IN ('EOP', 'ECL', 'CLK')");
}else if(key_action.equals("UED")){
cronsDao.execute(connection,"UPDATE "+tablepre+"threadsmod SET status='0' WHERE tid IN ("+tidString+") AND action='EDI'");
StringBuffer authorIdBuffer = new StringBuffer();
List<Integer> authorIdList = new ArrayList<Integer>();
Map<Integer,Integer> digestMap = new HashMap<Integer,Integer>();
List<Map<String,String>> threadsResultList = cronsDao.executeQuery(connection,"SELECT authorid, digest FROM "+tablepre+"threads WHERE tid IN ("+tidString+")");
if(threadsResultList!=null&&threadsResultList.size()>0){
for(int i = 0;i<threadsResultList.size();i++){
Map<String,String> threadsResultMap = threadsResultList.get(i);
authorIdList.add(Integer.valueOf(threadsResultMap.get("authorid")));
authorIdBuffer.append(threadsResultMap.get("authorid")+",");
if(digestMap.get(threadsResultMap.get("authorid"))==null){
Integer authodId = Integer.valueOf(threadsResultMap.get("authorid"));
digestMap.put(authodId,Integer.valueOf(threadsResultMap.get("digest")));
}else{
Integer authodId = Integer.valueOf(threadsResultMap.get("authorid"));
Integer digest = Integer.valueOf(threadsResultMap.get("digest"));
digestMap.put(authodId,digestMap.get(authodId)+digest);
}
}
String authorIdString = authorIdBuffer.substring(0,authorIdBuffer.length()-1);
cronsDao.execute(connection,"UPDATE "+tablepre+"members SET digestposts=digestposts-1 WHERE uid IN ("+authorIdString+")");
Map digestMap_creditspolicy = null;
List<Map<String,String>> tempList = cronsDao.executeQuery(connection,"SELECT value FROM "+tablepre+"settings WHERE variable='creditspolicy'");
if(tempList!=null&&tempList.size()!=0){
Map<String,String> tempMap = tempList.get(0);
if(tempMap!=null){
String value = tempMap.get("value");
Map stringToMap = ((DataParse)BeanFactory.getBean("dataParse")).characterParse(value,false);
digestMap_creditspolicy = (Map)stringToMap.get("digest");
}
}
updateCredits(digestMap,digestMap_creditspolicy);
cronsDao.execute(connection,"UPDATE "+tablepre+"threads SET digest='0' WHERE tid IN ("+tidString+")");
}
}
}
}
}
RequestDispatcher dispatcher = request.getRequestDispatcher("/include/crons/setNextrun.jsp");
try {
dispatcher.include(request, response);
} catch (Exception e) {
e.printStackTrace();
}
Map<String,String> crons = (Map<String,String>)request.getAttribute("crons");
if("0".equals(crons.get("available"))){
cronsDao.execute(connection,"UPDATE "+tablepre+"crons SET available='0' WHERE cronid="+crons.get("cronid"));
}else{
cronsDao.execute(connection,"UPDATE "+tablepre+"crons SET lastrun='"+timestamp+"',nextrun='"+crons.get("nextrun")+"' WHERE cronid="+crons.get("cronid"));
}
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -