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

📄 miscaction.java

📁 论坛软件系统亦称电子公告板(BBS)系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
			}
			OtherBaseVO othervo = new OtherBaseVO();
			othervo.setReasonList(reasonlist);
			request.setAttribute("valueObject", othervo);
		}
		String inajax = request.getParameter("inajax");
		int timestamp = (Integer)(request.getAttribute("timestamp"));
		String tid = request.getParameter("tid");
		String pid = request.getParameter("pid");
		HttpSession session = request.getSession();
		String dateformat = (String)session.getAttribute("dateformat");
		String timeformat = (String)session.getAttribute("timeformat");
		int timeoffset=(int)((Float)session.getAttribute("timeoffset")*3600);
		String boardurl = (String) session.getAttribute("boardurl");
		String message = "";
		int jrun_uid = (Integer)session.getAttribute("jsprun_uid");
		if(jrun_uid==0){
			message = "对不起,您还没有登录,无法进行此操作。";
			if(inajax==null){
				request.setAttribute("errorInfo", message);
				return mapping.findForward("showMessage");
			}else{
				this.showMessage(true, message, response, false);
				return null;
			}
		}
		short jsprun_groupid = (Short) session.getAttribute("jsprun_groupid");
		byte jsprun_adminid = (Byte) session.getAttribute("jsprun_adminid");
		Members member = (Members)session.getAttribute("user");
		List<Map<String,String>> usergroups = dataBaseService.executeQuery("select raterange,grouptitle,reasonpm from jrun_usergroups where groupid="+jsprun_groupid);
		Map<String,String> usergroup = usergroups.get(0);
		usergroups = null;
		Posts post = postService.getPostsById(convertInt(pid));
		String edittimelimit = settings.get("karmaratelimit");
		request.setAttribute("post", post);
		if(post==null){
			message = "未定义操作,请返回。";
			if(inajax==null){
				request.setAttribute("errorInfo", message);
				return mapping.findForward("showMessage");
			}else{
				this.showMessage(true, message, response, false);
				return null;
			}
		}
		tid = post.getTid()+"";
		request.setAttribute("tid", post.getTid());
		request.setAttribute("pid", pid);
		boolean modertar = Common.ismoderator(post.getFid(), member);
		Map<String,String> threads = dataBaseService.executeQuery("select t.tid,t.subject,f.fid,f.name,f.type,f.fup from jrun_threads as t left join jrun_forums as f on t.fid=f.fid where t.tid="+tid).get(0);
		if(inajax==null){
			request.setAttribute("thread", threads);
			String page = request.getParameter("page");
			request.setAttribute("page", page);
			String navigation = "<a href='forumdisplay.jsp?fid="+threads.get("fid")+"'>"+threads.get("name")+"</a> &raquo; <a href='viewthread.jsp?tid="+threads.get("tid")+"'>"+threads.get("subject")+"</a>";
			if(threads.get("type").equals("sub")){
				Forums parentforum = forumService.findById(Common.toDigit(threads.get("fup"),10000000L,0L).shortValue());
				navigation = "<a href='forumdisplay.jsp?fid="+parentforum.getFid()+"'>"+parentforum.getName()+"</a> &raquo; <a href='forumdisplay.jsp?fid="+threads.get("fid")+"'>"+threads.get("name")+"</a> &raquo <a href='viewthread.jsp?tid="+threads.get("tid")+"'>"+threads.get("subject")+"</a>";
			}
			request.setAttribute("navigation", navigation);
			}
		if(jrun_uid==post.getAuthorid()){
			message = "对不起,您不能对自己发表的帖子评分。";
			if(inajax==null){
				request.setAttribute("errorInfo", message);
				return mapping.findForward("showMessage");
			}else{
				this.showMessage(true, message, response, false);
				return null;
			}
		}
		if(!edittimelimit.equals("0")){
		if(!modertar && jrun_uid!=post.getAuthorid() && (timestamp-post.getDateline())<=convertInt(edittimelimit)*60){
			message = "评分超过时间限制,请返回。";
			if(inajax==null){
				request.setAttribute("errorInfo", message);
				return mapping.findForward("showMessage");
			}else{
				this.showMessage(true, message, response, false);
				return null;
			}
		}
		}
		String dupkarmarate = settings.get("dupkarmarate");
		if(dupkarmarate!=null && dupkarmarate.equals("0")){
			String retelogsql = "SELECT pid FROM jrun_ratelog WHERE uid="+ jrun_uid+ " AND pid="+pid;
			List<Map<String, String>> retelist = dataBaseService.executeQuery(retelogsql);
			if(retelist!=null && retelist.size()>0){
				retelist = null;
				message = "管理员设置了不能对同一帖子重复评分,请返回。";
				if(inajax==null){
					request.setAttribute("errorInfo", message);
					return mapping.findForward("showMessage");
				}else{
					this.showMessage(true, message, response, false);
					return null;
				}
			}
		}
		String ratesubmit = request.getParameter("ratesubmit");
		String settind = settings.get("modratelimit");
		if (usergroup.get("raterange").equals("")) {
			message = "您所在的用户组(" + usergroup.get("grouptitle") + ")无法进行此操作。";
			if(inajax==null){
				request.setAttribute("errorInfo", message);
				return mapping.findForward("showMessage");
			}else{
				showMessage(true, message, response, false);
				return null;
			}
		} else if (jsprun_adminid == 3 && !modertar && settind.equals("1")) {
			message = "对不起,作为版主您只能在自己的管辖范围内评分,请返回。";
			if(inajax==null){
				request.setAttribute("errorInfo", message);
				return mapping.findForward("showMessage");
			}else{
				this.showMessage(true, message, response, false);
				return null;
			}
		}
		int times = timestamp-86400;
		String retelogsql = "SELECT extcredits, SUM(ABS(score)) AS todayrate FROM jrun_ratelog WHERE uid='"+ jrun_uid
		+ "' AND dateline>="+ times+" GROUP BY extcredits";
		List<Map<String, String>> retelist = dataBaseService.executeQuery(retelogsql);
		String raterange = usergroup.get("raterange");
		Map rangresult = new TreeMap();
		if (!raterange.equals("")) {
			String[] reaterang = raterange.split("\\s+");
			List ranglist = null;
			String key = "";
			for (int i = 0, j = 0; i < reaterang.length; i++) {
				if ((i + 4) % 4 == 0) {
					key = reaterang[i];
					ranglist = new ArrayList();
				} else {
					j++;
					if (j % 3 == 0) {
						if (retelist != null) {
							for (Map<String, String> retemap : retelist) {
								if (retemap.get("extcredits").equals(key)) {
									reaterang[i] = (convertInt(reaterang[i])- convertInt(retemap.get("todayrate")) + "");
								}
							}
						}
					}
					ranglist.add(reaterang[i]);
				}
				if (j % 3 == 0) {
					rangresult.put(key, ranglist);
				}
			}
		}
		retelist = null;
		String setting = settings.get("extcredits");
		Map<String,String[]> extnameMap = getCreditsName(setting);
		request.setAttribute("extnameMap", extnameMap);
		if (ratesubmit == null) {
			Iterator it = rangresult.keySet().iterator();
			Map regMap = new TreeMap();
			while (it.hasNext()) {
				Object keys = it.next();
				List values = (List) rangresult.get(keys);
				List options = new ArrayList();
				int offset = (int) Math.abs(Math.ceil(((convertInt(values.get(1).toString()) - convertInt(values.get(0).toString())) / 32)));
				if(offset==0){
					offset = 1;
				}
				for (int p = convertInt(values.get(0).toString()); p <= convertInt(values.get(1).toString()); p += offset) {
					if(p!=0){
						options.add(p);
					}
				}
				values.remove(0);
				values.remove(0);
				values.add(options);
				regMap.put(keys, values);
			}
			request.setAttribute("rangresult", regMap);
			if(usergroup.get("reasonpm").equals("1")||usergroup.get("reasonpm").equals("3")){
				request.setAttribute("reasons", "您必须输入理由才能进行操作");
			}
			return mapping.findForward("torate");
		} else {
			String page = request.getParameter("page");
			String reason = request.getParameter("reason");
			reason = Common.cutstr(reason, 40, "");
			if(usergroup.get("reasonpm").equals("1")||usergroup.get("reasonpm").equals("3")){
				if(reason==null || reason.equals("")){
					message = "对不起,在您进行操作前必须选择或需入理由,请返回修改。";
					if(inajax==null){
						request.setAttribute("errorInfo", message);
						return mapping.findForward("showMessage");
					}else{
						writeMessage(response,message,true);
						return null;
					}
				}
			}
			Iterator it = rangresult.keySet().iterator();
			double rate = post.getRate();
			double ratetime = post.getRatetimes();
			boolean flag = false;
			boolean isone = false;
			String ratelogs = "";
			String realPath=servlet.getServletContext().getRealPath("/");
			while (it.hasNext()) {
				Object key = it.next();
				List values = (List) rangresult.get(key);
				String scores = request.getParameter("score" + key);
				if (scores != null) {
					flag = true;
					int score = convertInt(scores);
					int max = convertInt(values.get(1).toString());
					int min = convertInt(values.get(0).toString());
					if (Math.abs(score) <= convertInt(values.get(2).toString())) {
						if(score==0 && !it.hasNext() && !isone){
							message = "您未输入分值或超过每次评分范围限制,请返回修改。";
							if(inajax==null){
								request.setAttribute("errorInfo", message);
								return mapping.findForward("showMessage");
							}else{
								writeMessage(response,message,true);
								return null;
							}
						}
						if (score > max || score < min ) {
							message = "您未输入分值或超过每次评分范围限制,请返回修改。";
							if(inajax==null){
								request.setAttribute("errorInfo", message);
								return mapping.findForward("showMessage");
							}else{
								writeMessage(response,message,true);
								return null;
							}
						} else {
							if(score!=0){
							isone = true;
							rate += score;
							double ratetimes = Math.ceil(Math.max(Math.abs(min), Math.abs(max)) / 5);
							if(ratetimes<=0){
								ratetimes = 1;
							}
							ratetime += ratetimes;
							rateCredits(post.getAuthorid(), score, convertInt(key.toString()));
							String insertratelogsql = "insert into jrun_ratelog(pid,uid,username,extcredits,dateline,score,reason)values('"
									+ pid
									+ "','"
									+ jrun_uid
									+ "','"
									+ member.getUsername()
									+ "','"
									+ key
									+ "','"
									+ timestamp
									+ "','"
									+ score
									+ "','"
									+ reason + "')";
							dataBaseService.runQuery(insertratelogsql);
							String raterate = score+"";
							if(score>0){
								raterate = "+"+raterate;
							}
							ratelogs = ratelogs +","+ extnameMap.get("name")[Integer.valueOf(key.toString())-1]+raterate+extnameMap.get("unit")[Integer.valueOf(key.toString())-1];
							String ratelog = timestamp+"\t"+member.getUsername()+"\t"+member.getGroupid()+"\t"+post.getAuthor()+"\t"+key+"\t"+raterate+"\t"+post.getTid()+"\t"+threads.get("subject")+"\t"+reason.trim();
							Log.writelog(realPath, "ratelog", ratelog);
						}
						}
					} else {
						message = "对不起,您最近 24 小时评分数超过限制,请返回修改。";
						if(inajax==null){
							request.setAttribute("errorInfo", message);
							return mapping.findForward("showMessage");
						}else{
							writeMessage(response,message,true);

⌨️ 快捷键说明

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