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

📄 viewthreadaction.java

📁 论坛软件系统亦称电子公告板(BBS)系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
			} else if (gender == 2) {
				genders = "女";
			} else{
				genders = "保密";
			}
			customvalue.add("<dt>UID</dt><dd>"+usermap.get("uid")+"</dd>");
			customvalue.add("<dt>帖子</dt><dd>"+usermap.get("posts")+"</dd>");
			customvalue.add("<dt>精华</dt><dd>"+usermap.get("digestposts")+"</dd>");
			customvalue.add("<dt>积分</dt><dd>"+usermap.get("credits")+"</dd>");
			customvalue.add("<dt>"+extname[0]+"</dt><dd>"+usermap.get("extcredits1")+extunit[0]+"</dd>");
			customvalue.add("<dt>"+extname[1]+"</dt><dd>"+usermap.get("extcredits2")+extunit[1]+"</dd>");
			customvalue.add("<dt>"+extname[2]+"</dt><dd>"+usermap.get("extcredits3")+extunit[2]+"</dd>");
			customvalue.add("<dt>"+extname[3]+"</dt><dd>"+usermap.get("extcredits4")+extunit[3]+"</dd>");
			customvalue.add("<dt>"+extname[4]+"</dt><dd>"+usermap.get("extcredits5")+extunit[4]+"</dd>");
			customvalue.add("<dt>"+extname[5]+"</dt><dd>"+usermap.get("extcredits6")+extunit[5]+"</dd>");
			customvalue.add("<dt>"+extname[6]+"</dt><dd>"+usermap.get("extcredits7")+extunit[6]+"</dd>");
			customvalue.add("<dt>"+extname[7]+"</dt><dd>"+usermap.get("extcredits8")+extunit[7]+"</dd>");
			customvalue.addAll(profievalue);
			customvalue.add("<dt>阅读权限</dt><dd>"+usermap.get("readaccess")+"</dd>");
			customvalue.add("<dt>性别</dt><dd>"+genders+"</dd>");
			customvalue.add(location);
			customvalue.add("<dt>在线时间</dt><dd>"+usermap.get("oltime")+"&nbsp;&nbsp;小时</dd>");
			customvalue.add("<dt>注册时间</dt><dd>"+Common.gmdate(dateformat, (int)(Common.toDigit(usermap.get("regdate"))+timeoffset))+"</dd>");
			customvalue.add("<dt>最后访问</dt><dd>"+Common.gmdate(dateformat, (int)(Common.toDigit(usermap.get("lastactivity"))+timeoffset))+"</dd>");
			List<String> leftlist = new ArrayList<String>();
			List<String> menulist = new ArrayList<String>();
			List<String> spacelist = new ArrayList<String>();
			int size = custom.size();
			if (customMap != null && customMap.get(0) != null) {
				Map customreMap = (Map) customMap.get(0);
				for (int i = 0; i < size; i++) {
					if (customreMap.get(custom.get(i)) != null) {
						Map disMap = (Map) customreMap.get(custom.get(i));
						Iterator its = disMap.keySet().iterator();
						while (its.hasNext()) {
							Object diskey = its.next();
							String customname = customvalue.get(i);
							if(!customname.equals("")){
								if (diskey.equals("left")) {
									leftlist.add(customvalue.get(i));
								} else if (diskey.equals("menu")) {
									menulist.add(customvalue.get(i));
								} else {
									spacelist.add(customvalue.get(i));
								}
							}
						}
					}
				}
			}
			resultMap.put("left", leftlist);
			resultMap.put("menu", menulist);
			resultMap.put("special", spacelist);
			leftlist = null;spacelist=null;profievalue=null;
			menulist = null;custom = null;customvalue=null;
			return resultMap;
	}
	private String parseSmilies(int parnum,Map<String,String>threads,Posts posts,Map<String, String> bbcodelist,List<Map<String,String>> smilieslist) {
		String message = posts.getMessage()+" ";
		if(Common.toDigit(threads.get("allowbbcode"))>0 && posts.getBbcodeoff()<=0){
			message = jspcode.parsecode(message,true);
			message = jspcode.parsetable(message);
			message = jspcode.parsemedia(message,Common.toDigit(threads.get("allowmediacode"))>0);
			message = jspcode.parseFlashorQQ(message,bbcodelist);
		}
		message = jspcode.parseimg(message,Common.toDigit(threads.get("allowimgcode"))>0);
		if(Common.toDigit(threads.get("allowsmilies"))>0 && posts.getSmileyoff()<=0){
			message = relacesmile(message, parnum,smilieslist);
		}
		message = message.replaceAll("\\n", "<br/>");
		message = message.replaceAll("(?i)<br/>(<TD>|<TR>|</TR>)", "$1");
		return message;
	}

	private String relacesmile(String message, int parnum,List<Map<String,String>> smilieslist) {
		int count = 0;
		for(Map<String,String> smiles:smilieslist){
			if (count > parnum) {
				break;
			}
			if(message.indexOf(smiles.get("code")+" ")!=-1 || message.indexOf(" "+smiles.get("code"))!=-1){
				StringBuffer buffer = new StringBuffer(100);
				buffer.append("<img src='images/smilies/");
				buffer.append(smiles.get("directory"));
				buffer.append("/");
				buffer.append(smiles.get("url"));
				buffer.append("' smilieid='");
				buffer.append(smiles.get("id"));
				buffer.append("' border='0' alt='' /> ");
				message = StringUtils.replace(message, smiles.get("code"), buffer.toString());
				count++;
			}
		}
		smilieslist = null;
		return message;
	}
	@SuppressWarnings("unchecked")
	private Map<String,String[]> getCreditsunit(Map extcreditMap) {
		Map<String,String[]> extnameunitmap = new HashMap<String,String[]>();
		Iterator it = extcreditMap.keySet().iterator();
		String extname[] = new String[8];
		String extunit[] = new String[8];
		while (it.hasNext()) {
			Object key = it.next();
			Map extMap = (Map) extcreditMap.get(key);
			extname[Integer.valueOf(key.toString()) - 1] = (String) extMap.get("title")+ " ";
			extunit[Integer.valueOf(key.toString()) - 1] = " "+ (String) extMap.get("unit");
		}
		extnameunitmap.put("extname", extname);
		extnameunitmap.put("extunit", extunit);
		return extnameunitmap;
	}

	@SuppressWarnings("unchecked")
	private Map calcSumreson(List<Polloptions> list) {
		Map resonMap = new HashMap();
		int count = 0;
		for (Polloptions options : list) {
			count += options.getVotes();
			String voterids = options.getVoterids();
			if (!voterids.equals("")) {
				String[] ids = voterids.split("\t");
				for(String id:ids)
				{
					if(resonMap.get(id) == null)
					{
						resonMap.put(convertInt(id), "reson");
					}
				}
			}
		}
		if(count==0){
			count=1;
		}
		int resonnum = resonMap.size();
		resonMap.put("num", resonnum);
		resonMap.put("ballot", count);
		return resonMap;
	}

	private String calcSparetime(int expiration) {
		String time = "";
		int nowtime=Common.time();
		int sparetime = expiration - nowtime;
		if(expiration==0){
			return "";
		}
		if (sparetime < 0) {
			time = "投票已经结束";
		} else {
			int day = sparetime / 86400;
			sparetime = sparetime % 86400;
			int horse = sparetime / (60 * 60);
			sparetime = sparetime % (60 * 60);
			int minute = sparetime / 60;
			time = "距结束还有:  " + day + " 天 " + horse + " 小时 " + minute + " 分钟";
		}
		return time;
	}

	@SuppressWarnings("unchecked")
	public ActionForward printable(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		HttpSession session = request.getSession();
		Map<String, String> settings = (Map<String, String>) request.getAttribute("settings");
		int uid = (Integer)session.getAttribute("jsprun_uid");
		String tid = request.getParameter("tid");
		String posthql = "from Posts as p where p.tid=" + tid;
		List<Map<String,String>> threadpost = dataBaseService.executeQuery("select t.*,f.threadcaches,f.fup,f.name,f.allowmediacode,f.allowpostspecial,f.allowbbcode,f.allowimgcode,f.jammer,f.allowsmilies,f.displayorder as dis,f.type,f.allowspecialonly,f.allowshare,f.allowhtml,f.alloweditpost,f.autoclose from jrun_threads t left join jrun_forums f on t.fid=f.fid  where  t.displayorder>=0 and t.tid="+tid);
		if (threadpost == null || threadpost.size()<=0) {
			request.setAttribute("errorInfo", "指定的主题不存在或已被删除或正在被审核,请返回");
			return mapping.findForward("showMessage");
		}
		Map<String,String> threads = threadpost.get(0);
		request.setAttribute("fid", Short.valueOf(threads.get("fid")));
		threadpost=null;
		Map<String,String> usergroups = (Map<String,String>)request.getAttribute("usergroups");
		int readaccess = Common.toDigit(usergroups.get("readaccess"));
		request.setAttribute("readaccess", readaccess);
		Members members = (Members)session.getAttribute("user");
		short groupid = (Short)session.getAttribute("jsprun_groupid");
		List<Map<String, String>> forumslist = dataBaseService.executeQuery("SELECT ff.modrecommend, ff.viewperm, a.allowview, ff.postperm, ff.typemodels,ff.threadtypes,ff.replyperm,ff.getattachperm,ff.password,ff.formulaperm FROM  jrun_forumfields ff LEFT JOIN jrun_access a ON a.uid='"+ uid+ "' AND a.fid=ff.fid WHERE ff.fid="+threads.get("fid"));
		Map<String, String> forumMap = forumslist.get(0);
		String modrecommend = forumMap.get("modrecommend");
		Map modrecommendMap = dataParse.characterParse(modrecommend, false);
		request.setAttribute("modrecommendMap", modrecommendMap);
		forumslist = null;
		String extgroupids=members!=null?members.getExtgroupids():null;
		boolean allowgetattach = false;
		if (forumMap.get("alloview") == null) {
			if (forumMap.get("viewperm").equals("") && (usergroups==null || usergroups.get("readaccess").equals("0"))) {
				String grouptitle = usergroups==null?"游客":usergroups.get("grouptitle");
				request.setAttribute("show_message", "您所在的用户组(" + grouptitle+ ")无法进行此操作。");
				return mapping.findForward("nopermission");
			} else if (!forumMap.get("viewperm").equals("")&& !Common.forumperm(forumMap.get("viewperm"), groupid,extgroupids)) {
				request.setAttribute("show_message", " 本版块只有特定用户组可以访问。");
				return mapping.findForward("nopermission");
			}
			String getattachperm = forumMap.get("getattachperm");
			allowgetattach = (getattachperm.equals("")&&(usergroups!=null&&!usergroups.get("readaccess").equals("0")))||(!getattachperm.equals("")&&Common.forumperm(getattachperm, groupid,extgroupids))||(usergroups!=null&&!usergroups.get("allowgetattach").equals("0"));
		}
		request.setAttribute("allowgetattach",allowgetattach);
		boolean modertar = Common.ismoderator(Common.toDigit(threads.get("fid"),100000000L, 0L).shortValue(), members);
		request.setAttribute("modertar", modertar);
		String extcredit = settings.get("extcredits");
		Map<Integer,Map<String,String>> extcredits=dataParse.characterParse(extcredit, false);
		String formulaperm=forumMap.get("formulaperm");
		if(formulaperm.length()>0){
			Map<String,String> messages=Common.forumformulaperm(formulaperm, members,modertar, extcredits);
			if(messages!=null){
				request.setAttribute("show_message", "您不满足访问这个版块所需的条件。</b><br />&nbsp;&nbsp;&nbsp;访问条件: "+messages.get("formulamessage")+"<br />&nbsp;&nbsp;&nbsp;您的信息: "+messages.get("usermsg")+"<b>");
				return mapping.findForward("nopermission");
			}				
		}
		if(usergroups!=null && Common.toDigit(threads.get("readperm"))>Common.toDigit(usergroups.get("readaccess")) && !modertar && !threads.get("authorid").equals(uid+"")){
			request.setAttribute("show_message", "对不起,本帖要求阅读权限高于 "+threads.get("readperm")+" 才可浏览,请返回。");
			return mapping.findForward("nopermission");
		}
		if(Common.toDigit(threads.get("digest"))>0 && (usergroups==null || usergroups.get("allowviewdigest").equals("0")) && !threads.get("authorid").equals(uid+"")){
			request.setAttribute("show_message", "对不起,你所在的用户组("+usergroups==null?"游客":usergroups.get("grouptitle")+")不能浏览精华帖。");
			return mapping.findForward("nopermission");
		}
		String password=forumMap.get("password");
		if(password!=null&&!"".equals(password))
		{
			 if(!password.equals(session.getAttribute("fidpw"+threads.get("fid")))){
				request.setAttribute("fid", threads.get("fid"));
				return mapping.findForward("toForumdisplay_passwd");
			}
		}
		List<Posts> postlist = postService.findPostByhql(posthql, 0, 1000);
		List list = new ArrayList();
		List<Map<String,String>> smilieslist = dataBaseService.executeQuery("select s.id,s.typeid,s.code,s.url,i.directory from jrun_smilies s left join jrun_imagetypes  i on s.typeid=i.typeid where s.type='smilies' order by s.displayorder");
		for (int i = 0; i < postlist.size(); i++) {
			Map resmap = new HashMap();
			Posts posts = postlist.get(i);
			String messagse = parseSmilies(10,threads,posts,null,smilieslist);
			messagse = replacemessage(messagse);
			if(allowgetattach && posts.getAttachment()>0){
				messagse = messagse.replaceAll("\\[attach\\]\\d+\\[/attach\\]", "");
				posts.setMessage(messagse);
				List<Map<String,String>> attalist = dataBaseService.executeQuery("select * from jrun_attachments where pid="+posts.getPid());
				for(Map<String,String> attach:attalist){
					if(!attach.get("price").equals("0")){
						if(!modertar&&!attach.get("uid").equals(uid+"")){
							List<Map<String,String>> payloglist = dataBaseService.executeQuery("select uid from jrun_attachpaymentlog 

⌨️ 快捷键说明

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