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

📄 threadexpiries_hourly.jsp

📁 论坛软件系统亦称电子公告板(BBS)系统
💻 JSP
📖 第 1 页 / 共 2 页
字号:
<%@ 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="cn.jsprun.domain.Members"/>
<jsp:directive.page import="cn.jsprun.dao.user.MembersDao"/>
<jsp:directive.page import="java.lang.reflect.Method"/>
<jsp:directive.page import="cn.jsprun.utils.DataParse"/>
<%@page import="cn.jsprun.domain.Crons"%>
<%@page import="cn.jsprun.domain.Threads"%>
<%@page import="cn.jsprun.dao.posts.ThreadsDao"%>
<%@page import="cn.jsprun.dao.posts.PostsDao"%>
<%@page import="cn.jsprun.domain.Posts"%>
<%@page import="cn.jsprun.dao.ForumsDao"%>
<%@page import="cn.jsprun.domain.Forums"%>
<%@page import="cn.jsprun.foreg.service.PostOperating"%>
<%@page import="cn.jsprun.domain.Forumfields"%>
<%@page import="cn.jsprun.dao.ForumfieldsDao"%>
<%@page import="cn.jsprun.domain.Attachments"%>
<%@page import="cn.jsprun.dao.posts.AttachmentsDao"%>
<%@page import="java.io.File"%>
<%@page import="cn.jsprun.utils.CronsLocker"%>
<%@page import="cn.jsprun.utils.LockerFactory"%>
<%@page import="cn.jsprun.service.otherset.CronsSetService"%>
<%@page import="cn.jsprun.utils.Common"%>
<%@page import="cn.jsprun.dao.CronsDao"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.SQLException"%>
<%!
	private String tablepre = "jrun_"; 
	private CronsDao cronsDao = ((CronsDao)BeanFactory.getBean("cronsSetDao"));
	private ThreadsDao threadsDao = (ThreadsDao)BeanFactory.getBean("threadsDao");
	private MembersDao membersDao = (MembersDao)BeanFactory.getBean("memberDao");
	
	private void updateCredits(Map<Integer,Integer> memberId_digestMap, Map digestMap){
	
		List<Integer> membersIdList = new ArrayList<Integer>();
		Iterator<Integer> iterator = memberId_digestMap.keySet().iterator();
		while(iterator.hasNext()){
			Integer key = iterator.next();
			membersIdList.add(key);
		}
		List<Members> membersList = membersDao.getMemberListWithMemberIdList(membersIdList);
		
		for(int i = 0;i<membersList.size();i++){
			Members members = membersList.get(i);
			Iterator<Integer> iterator2 = digestMap.keySet().iterator();
			while(iterator2.hasNext()){
				Integer kye = iterator2.next();
				try{
					Method method_get = Members.class.getMethod("getExtcredits"+kye);
					
					Method method_set = Members.class.getMethod("setExtcredits"+kye,Integer.class);
					
					method_set.invoke(members,((Integer)method_get.invoke(members)- memberId_digestMap.get(members.getUid()) * Integer.valueOf(digestMap.get(kye).toString())));
				}catch(Exception exception){
					exception.printStackTrace();
				}
			}
		}
	}
	private void createMirror(Threads threads){
		/*
		 * threads_old.setTid(null);
		 */
		
		Threads mirror = new Threads();
		mirror.setViews(0);
		mirror.setReplies(0);
		mirror.setDisplayorder((byte) 0);
		mirror.setDigest((byte) 0);
		mirror.setClosed(threads.getTid());
		mirror.setSpecial((byte) 0);
		mirror.setAttachment((byte) 0);
		
		mirror.setAuthor(threads.getAuthor());
		mirror.setAuthorid(threads.getAuthorid());
		mirror.setBlog(threads.getBlog());
		mirror.setDateline(threads.getDateline());
		mirror.setFid(threads.getFid());
		mirror.setHighlight(threads.getHighlight());
		mirror.setTypeid(threads.getTypeid());
		mirror.setSupePushstatus(threads.getSupePushstatus());
		mirror.setSubscribed(threads.getSubscribed());
		mirror.setSubject(threads.getSubject());
		mirror.setReadperm(threads.getReadperm());
		mirror.setRate(threads.getRate());
		mirror.setIconid(threads.getIconid());
		mirror.setItemid(threads.getItemid());
		mirror.setLastpost(threads.getLastpost());
		mirror.setLastposter(threads.getLastposter());
		mirror.setModerated(threads.getModerated());
		mirror.setPrice(threads.getPrice());
		threadsDao.addThread(mirror);
	}
	
	
	public String getAttachmentRealyPath(String attachmentPath,String serverUrl,ServletContext application){
		if(attachmentPath.startsWith("http://")){
			attachmentPath = attachmentPath.substring(serverUrl.length());
		}
		return application.getRealPath(attachmentPath);
	}
	private void operatingAttachment(Integer pid,String attachurl_realy,Forumfields forumfields,String creditspolicy,Members members_reply,Map<String,String> updateField,boolean deleteAttachment,boolean updateCredit_post){
		List<Attachments> attachmentslist = ((AttachmentsDao)BeanFactory.getBean("attachmentsDao")).findByPostsID(pid);
		if(attachmentslist.size()<1){
			return ;
		}
		if (deleteAttachment) {
			for(int j = 0;j<attachmentslist.size();j++){
				Attachments attachments = attachmentslist.get(j);
				String uri = attachments.getAttachment();
				File file = new File(attachurl_realy+"/"+uri);
				if(file.isFile()){
					if(!file.delete()){
						try{
							throw new Exception("删除附件失败!");
						}catch(Exception exception){
							exception.printStackTrace();
						}
					}
				}else{
					try{
						throw new Exception("附件目录错误或附件已经被删除!");
					}catch(Exception exception){
						exception.printStackTrace();
					}
				}
				if(attachments.getThumb()==1){
					String imagePostfix = uri.substring(uri.lastIndexOf("."),uri.length());
					File breviaryImage = new File(attachurl_realy+"/"+uri+".thumb"+imagePostfix);
					if(breviaryImage.isFile()){
						if(!breviaryImage.delete()){
							try{
								throw new Exception("删除附件缩略图失败!");
							}catch(Exception exception){
								exception.printStackTrace();
							}
						}
					}
				}
			}
		}
		if(updateCredit_post){
			PostOperating postOperating = (PostOperating)BeanFactory.getBean("postOperating");
			postOperating.setMembersExtcredit(forumfields, creditspolicy, members_reply, updateField, postOperating.attachment, false,1);
		}
	}
	private void deleteRatelog(List<Integer> pidList,Connection connection) throws SQLException{
		if(pidList==null){
			try{
				throw new Exception("pidList IS NULL");
			}catch(Exception exception){
				exception.printStackTrace();
				return ;
			}
		}
		if(pidList.size()>0){
			StringBuffer pidBuffer = new StringBuffer();
			for(int i = 0;i<pidList.size();i++){
				if(pidList.get(i)!=null){
					pidBuffer.append(pidList.get(i)+",");
				}
			}
			String pidString = pidBuffer.substring(0,pidBuffer.length()-1);
			String sql = "DELETE FROM "+tablepre+"ratelog WHERE pid IN ("+pidString+")";
			cronsDao.execute(connection,sql);
		}
	}
	private void deleteMyposts(List<Integer> pidList,Connection connection) throws SQLException{
		if(pidList==null){
			try{
				throw new Exception("pidList IS NULL");
			}catch(Exception exception){
				exception.printStackTrace();
				return ;
			}
		}
		if(pidList.size()>0){
			StringBuffer pidBuffer = new StringBuffer();
			for(int i = 0;i<pidList.size();i++){
				pidBuffer.append(pidList.get(i)+",");
			}
			String pidString = pidBuffer.substring(0,pidBuffer.length()-1);
			String sql = "DELETE FROM "+tablepre+"myposts WHERE pid IN ("+pidString+")";
			cronsDao.execute(connection,sql);
		}
	}
	private void deleteAttachments(List<Integer> pidList,Connection connection) throws SQLException{
		if(pidList==null){
			try{
				throw new Exception("pidList IS NULL");
			}catch(Exception exception){
				exception.printStackTrace();
				return ;
			}
		}
		if(pidList.size()>0){
			StringBuffer pidBuffer = new StringBuffer();
			for(int i = 0;i<pidList.size();i++){
				pidBuffer.append(pidList.get(i)+",");
			}
			String pidString = pidBuffer.substring(0,pidBuffer.length()-1);
			String sql = "DELETE FROM "+tablepre+"attachments WHERE pid IN ("+pidString+")";
			cronsDao.execute(connection,sql);
		}
	}
	private void updateForumCount(Object fid, Connection connection) throws SQLException{
		List<Map<String,String>> tempML = cronsDao.executeQuery(connection,"SELECT COUNT(*) AS threadcount, SUM(t.replies)+COUNT(*) AS replycount " +
				"FROM "+tablepre+"threads t, "+tablepre+"forums f " +
				"WHERE f.fid='"+fid+"' AND t.fid=f.fid AND t.displayorder>='0'");
		Map<String,String> tempM = null;
		String threadcount = "0";
		String replycount = "0";
		if(tempML!=null && tempML.size()>0){
			tempM = tempML.get(0);
			threadcount = tempM.get("threadcount");
			replycount = tempM.get("replycount");
		}
		
		tempML = cronsDao.executeQuery(connection,"SELECT tid, subject, author, lastpost, lastposter FROM "+tablepre+"threads " +
				"WHERE fid='"+fid+"' AND displayorder>='0' ORDER BY lastpost DESC LIMIT 1");
		String lastpost = "";
		if(tempML!=null && tempML.size()>0){
			tempM = tempML.get(0);
			String tempS = tempM.get("author");
			if(tempS == null || tempS.equals("")){
				tempS = "匿名";
			}else{
				tempS = Common.addslashes(tempM.get("lastposter"));
			}
			lastpost = tempM.get("tid")+"\t"+Common.addslashes(tempM.get("subject"))+"\t"+tempM.get("lastpost")+"\t"+tempS;
		}
		cronsDao.execute(connection,"UPDATE "+tablepre+"forums SET posts='"+replycount+"', threads='"+threadcount+"', lastpost='"+lastpost+"' WHERE fid='"+fid+"'");
	}
	%>
<%
	int timestamp=(Integer)request.getAttribute("timestamp");
	Connection connection = (Connection)request.getAttribute("connection");
	Map<String,List<String>> actionMap = new HashMap<String,List<String>>();
	List<Map<String,String>> queryList = cronsDao.executeQuery(connection,"SELECT * FROM "+tablepre+"threadsmod WHERE expiration>'0' AND expiration<='"+timestamp+"' AND status='1'");
	if(queryList!=null&&queryList.size()>0){
		List<String> ESTList = null;
		List<String> EHLList = null;
		List<String> ECLList = null;
		List<String> EOPList = null;
		List<String> EDIList = null;
		for(int i = 0;i<queryList.size();i++){
			Map<String,String> queryMap = queryList.get(i);
			if(queryMap!=null){
				String action = queryMap.get("action");
				if(action.equals("EST")||action.equals("TOK")){
					if(ESTList==null){
						ESTList = new ArrayList<String>();
					}
					ESTList.add(queryMap.get("tid"));
					if(actionMap.get("UES")==null){
						actionMap.put("UES",ESTList);
					}
				}else if(action.equals("EHL")||action.equals("CCK")){
					if(EHLList==null){
						EHLList = new ArrayList<String>();
					}
					EHLList.add(queryMap.get("tid"));
					if(actionMap.get("UEH")==null){
						actionMap.put("UEH",EHLList);
					}
				}else if(action.equals("ECL")||action.equals("CLK")){
					if(ECLList==null){
						ECLList = new ArrayList<String>();
					}
					ECLList.add(queryMap.get("tid"));
					if(actionMap.get("UEC")==null){
						actionMap.put("UEC",ECLList);
					}
				}else if(action.equals("EOP")){
					if(EOPList==null){
						EOPList = new ArrayList<String>();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -