⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cleanup_daily.jsp

📁 论坛软件系统亦称电子公告板(BBS)系统
💻 JSP
字号:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:directive.page import="cn.jsprun.utils.BeanFactory" />
<jsp:directive.page import="cn.jsprun.utils.Cache" />
<jsp:directive.page import="java.io.File"/>
<%@page import="cn.jsprun.dao.CronsDao"%>
<%@page import="java.sql.Connection"%>
<%! 
	private String tablepre = "jrun_"; 
	private CronsDao cronsDao = ((CronsDao)BeanFactory.getBean("cronsSetDao"));

	private boolean removedir(String cachethreaddir,boolean bool){ 
		cachethreaddir = wipespecial(cachethreaddir);
		File file = new File( cachethreaddir);
		if(!file.isDirectory()){
			return false;
		}else{
			File[] fileArray = file.listFiles();
			for(int i = 0;i<fileArray.length;i++){
				File fileTemp = fileArray[i];
				if(fileTemp.isDirectory()){
					removedir(fileTemp.getPath(),false);
				}else{
					fileTemp.delete();
				}
			}
		}
		if(!bool){
			if(file.delete()){
				return true;
			}else{
				return false;
			}
		}else{
			return true;
		}
	}
	private String wipespecial(String cachethreaddir){
		return cachethreaddir.replace("..","").replace("\n","").replace("\r","");
	}
%>

<%	
	int timestamp=(Integer)request.getAttribute("timestamp");
	Connection connection = (Connection)request.getAttribute("connection");
	cronsDao.execute(connection,"UPDATE "+tablepre+"advertisements SET available='0' WHERE endtime>'0' AND endtime<="+ timestamp);
	
	Cache cache = new Cache(application.getRealPath("/"));
	String[] cacheArray = { "settings", "archiver", "register", "index", "forumdisplay", "viewthread" };
	for (int i = 0; i < cacheArray.length; i++) {
		try {
			cache.updatecache(cacheArray[i]);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	cronsDao.execute(connection,"TRUNCATE "+tablepre+"searchindex");
	cronsDao.execute(connection,"DELETE FROM "+tablepre+"threadsmod WHERE dateline<"+(timestamp-31536000));
	cronsDao.execute(connection,"DELETE FROM "+tablepre+"subscriptions WHERE lastpost<"+(timestamp-7776000));
	cronsDao.execute(connection,"DELETE FROM "+tablepre+"forumrecommend WHERE expiration<"+timestamp);
	cronsDao.execute(connection,"UPDATE "+tablepre+"trades SET closed='1' WHERE expiration<>0 AND expiration<"+timestamp);
	cronsDao.execute(connection,"DELETE FROM "+tablepre+"tradelog WHERE status=0 AND lastupdate<'"+(timestamp - 5 * 86400)+"'");
	List<Map<String,String>> tempList2 = cronsDao.executeQuery(connection,"SELECT COUNT(*) count FROM "+tablepre+"forums WHERE status>0 AND threadcaches>0");
	if(tempList2!=null&&tempList2.size()>0){
		Map<String,String> tempMap = tempList2.get(0);
		if(tempMap!=null){
			int cachethreadon = Integer.valueOf(tempMap.get("count"));
			if(cachethreadon>0){
				List<Map<String,String>> tempList4 = cronsDao.executeQuery(connection,"SELECT value FROM "+tablepre+"settings WHERE variable='cachethreaddir'");
				if(tempList4!=null&&tempList4.size()>0){
					Map<String,String> tempMap2 = tempList4.get(0);
					if(tempMap2!=null){
						String tempValue = tempMap2.get("value");
						if(tempValue!=null&&!tempValue.equals("")){
							removedir(application.getRealPath(tempValue),true);
						}
					}
				}
			}
		}
	}
	
	List<Map<String,String>> tempList3 = cronsDao.executeQuery(connection,"SELECT value FROM "+tablepre+"settings WHERE variable='regstatus'");
	if(tempList3!=null&&tempList3.size()>0){
		Map<String,String> tempMap = tempList3.get(0);
		if(tempMap!=null){
			Integer tempValue = Integer.valueOf(tempMap.get("value"));
			if(tempValue>1){
				cronsDao.execute(connection,"UPDATE "+tablepre+"invites SET status='4' WHERE expiration<"+timestamp+" AND status IN ('1', '3')");
			}
		}
	}

	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 + -