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

📄 wapservice.java

📁 论坛软件系统亦称电子公告板(BBS)系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		int waptpp = Integer.parseInt(settingMap.get("waptpp"));
		int page = pageString==null?1:Math.max(1, Integer.parseInt(pageString));
		int start_limit = (page-1)*waptpp;
		int number = start_limit;
		dow = dow==null||dow.equals("")||dow.equals("0")?"":"digest";
		String filteradd = dow.equals("digest") ? "AND digest>'0'" : "";
		int threadcount = 0;
		List<Map<String,String>> tempResult = dataBaseDao.executeQuery("SELECT COUNT(*) AS ct FROM "+tablePre+"threads WHERE fid='"+fid+"' "+filteradd+" AND displayorder>='0'");
		if(tempResult!=null&&tempResult.size()>0){
			threadcount = Integer.parseInt(tempResult.get(0).get("ct"));
		}
		
		String thread_prefix = "";
		List<Map<String,String>> threadMapList = dataBaseDao.executeQuery("SELECT * FROM "+tablePre+"threads " +
				"WHERE fid='"+fid+"' "+filteradd+" AND displayorder>='0' " +
				"ORDER BY displayorder DESC, lastpost DESC LIMIT "+start_limit+", "+waptpp);
		if(threadMapList!=null&&threadMapList.size()>0){
			for(Map<String,String> thread : threadMapList){
				thread_prefix = Integer.parseInt(thread.get("displayorder"))>0?"[顶]":"";
				thread_prefix += Integer.parseInt(thread.get("digest"))>0?"[精]":"";
				ThreadInfo threadInfo = forums_threadsVO.getThreadInfo();
				threadInfo.setAuthor(thread.get("author"));
				threadInfo.setNumber((++number)+"");
				threadInfo.setPrefix(thread_prefix);
				threadInfo.setReplies(thread.get("replies"));
				String subject = thread.get("subject");
				threadInfo.setSubject(subject.length()>30?subject.substring(0,30):subject);
				threadInfo.setTid(thread.get("tid"));
				threadInfo.setViews(thread.get("views"));
				
				threadList.add(threadInfo);
			}
		}
		forums_threadsVO.setMultipage(wapmulti(threadcount, waptpp, page, response.encodeURL("index.jsp?action=forum&amp;fid="+fid+"&amp;sid=$sid")));
		
		String subfrums = "";
		if(!dow.equals("digest")){
			String fidString = fid+"";
			for(Entry<String,Map<String,String>>  entry : forums.entrySet()){
				String subFid = entry.getKey();
				Map<String,String> subforum = entry.getValue();
				if(subforum.get("type").equals("sub")&&subforum.get("fup").equals(fidString) && (subforum.get("viewperm").equals("")||("\t"+subforum.get("viewperm").trim()+"\t").contains("\t"+groupid+"\t"))){
					subfrums += "<a href=\""+response.encodeURL("index.jsp")+"?action=forum&amp;fid="+subFid+"\">"+Common.strip_tags(subforum.get("name"))+"</a><br />";
				}
			}
		}
		forums_threadsVO.setForumId(fid+"");
		forums_threadsVO.setSubfrums(subfrums);
		String allowsearch = groupCache.get("allowsearch");
		forums_threadsVO.setAllowsearch(allowsearch!=null&&!allowsearch.equals("")&&!allowsearch.equals("0"));
		return forums_threadsVO;
	}
	
	public ThreadVO getThreadVO(HttpServletRequest request,HttpServletResponse response,Members currentMember,Map<String,String> thread,Map<String,String> settingMap,String formhash,String sid,String dow,String pageString,int offset,String pid,int start,Map<String,String> userGroupCache,float timeoffset){
		DataBaseDao dataBaseDao = (DataBaseDao)BeanFactory.getBean("dataBaseDao");
		
		ThreadVO threadVO = new ThreadVO();
		setHeaderVO(threadVO.getHeaderVO(), settingMap.get("bbname"));
		setFooterVO(request, settingMap, threadVO.getFooterVO(), currentMember, "thread", formhash, sid);
		
		String wapdateformat = settingMap.get("wapdateformat");
		String timeformat = settingMap.get("timeformat");
		int wapmps = Integer.parseInt(settingMap.get("wapmps"));
		
		String tid = thread.get("tid");
		
		threadVO.setTid(tid);
		threadVO.setSubject(thread.get("subject"));
		
		String threadposts = "";
		if (dow.equals("")) {
			threadVO.setViewThread(true);
			
			threadVO.setAuthorid(thread.get("authorid"));
			threadVO.setAuthor(thread.get("author"));
			SimpleDateFormat simpleDateFormat = new SimpleDateFormat(wapdateformat+" "+timeformat);
			threadVO.setDateline(Common.gmdate(simpleDateFormat, Integer.parseInt(thread.get("dateline")),timeoffset));
			
			int page = pageString==null?1:Math.max(1, Integer.parseInt(pageString));
			int wapppp = Integer.parseInt(settingMap.get("wapppp"));
			int start_limit = (page - 1)*wapppp;
			int number = start_limit;
			
			int end_limit = 0;
			if(page < 2 ){
				end_limit = wapppp + 1;
			} else {
				start_limit = start_limit + 1;
				end_limit = wapppp;
			}
			
			List<Map<String,String>> postsMapList = dataBaseDao.executeQuery("SELECT * FROM "+tablePre+"posts " +
					"WHERE tid='"+tid+"' AND invisible='0' " +
					"ORDER BY dateline LIMIT "+start_limit+", "+end_limit);
			
			int offset_last = 0;
			int offset_next = 0;
			boolean breaked = false;
			
			List<Map<String,String>> postlist = new ArrayList<Map<String,String>>();
			String fid = null;
			for(Map<String,String> postsMap : postsMapList){
				postsMap.put("message", wapcode(postsMap.get("message")));
				if(postsMap.get("first").equals("1")){
					if(offset > 0){
						String str = postsMap.get("message");
						int i = offset;
						for(;i>offset - wapmps ;i--){
							char temp = str.charAt(i-1);
							if(temp<0 || temp > 127){
								i--;
							}
						}
						offset_last = i;
						postsMap.put("message", substr(postsMap.get("message"), offset));
					}else {
						offset = 0;
					}
					int mLen = 0;
					String tempMessage = postsMap.get("message");
					try {
						mLen = tempMessage.getBytes("GBK").length;
					} catch (UnsupportedEncodingException e) {
						e.printStackTrace();
					}
					if(mLen > wapmps){
						postsMap.put("message", wapcutstr(tempMessage,wapmps));
						offset_next = offset + wapmps;
						breaked = true;
					}else{
						breaked = false;
					}
					if(postsMap.get("anonymous").equals("1")){
						postsMap.put("author", "匿名");
					}
					threadposts += postsMap.get("message").trim().replaceAll("\r|\n", "<br>");
					fid = postsMap.get("fid");
				}else{
					postlist.add(postsMap);
				}
			}
			threadVO.setThreadposts(threadposts);
			threadVO.setExistNextPage(breaked);
			threadVO.setExistLastPage(offset!=0);
			
			threadVO.setFid(fid);
			threadVO.setOffset_next(offset_next);
			threadVO.setOffset_last(offset_last);
			
			List<PostsInfo> postsList = threadVO.getPostsList();
			int waptlength = 30;
			if (postlist.size() > 0) {
				String replies = thread.get("replies");
				threadVO.setReplies(replies);
				for(Map<String,String> posts : postlist){
					PostsInfo postsInfo = threadVO.getPostsInfoInstance();
					postsInfo.setAuthor(posts.get("anonymous").equals("1")?"匿名":posts.get("author"));
					postsInfo.setDateline(Common.gmdate(simpleDateFormat, Integer.parseInt(posts.get("dateline")),timeoffset));
					postsInfo.setMessage(wapcutstr(posts.get("message"), waptlength));
					postsInfo.setNumber(++number);
					postsInfo.setPid(posts.get("pid"));
					postsList.add(postsInfo);
				}
				threadVO.setWapmulti(wapmulti(Integer.parseInt(replies), wapppp, page, response.encodeURL("index.jsp?action=thread&amp;tid="+tid)));
			}
		} else {
			List<Map<String,String>> postMapList = dataBaseDao.executeQuery("SELECT * FROM "+tablePre+"posts WHERE pid='"+pid+"' AND invisible='0'");
			boolean breaked = false;
			
			if(postMapList!=null && postMapList.size()>0){
				Map<String,String> postMap = postMapList.get(0);
				if (offset >0){
					postMap.put("message", ".."+substr(postMap.get("message"), offset-4));
				}
				int threadpostsLen  = 0;
				int postMessgeLen = 0 ;
				try {
					threadpostsLen = threadposts.getBytes("GBK").length;
					postMessgeLen = postMap.get("message").getBytes("GBK").length;
				} catch (UnsupportedEncodingException e) {
					e.printStackTrace();
				}
				if(threadpostsLen + postMessgeLen - wapmps > 0){
					int length = wapmps - threadpostsLen;
					postMap.put("message", wapcutstr(postMap.get("message"), length));
					offset += length;
					breaked = true;
				}
				if(postMap.get("anonymous").equals("1")){
					postMap.put("author", "匿名");
				}
				postMap.put("message", wapcode(postMap.get("message")));
				PostsInfo postsInfo = threadVO.getPostsInfo();
				postsInfo.setAnonymous(postMap.get("anonymous").equals("1"));
				postsInfo.setAuthor(postMap.get("author"));
				postsInfo.setAuthorid(postMap.get("authorid"));
				postsInfo.setMessage(postMap.get("message").trim().replaceAll("\n|\r", "<br>"));
				
				if(!breaked){
					start++;
					offset = 0;
				}
			}
		}
		String allowreply = userGroupCache.get("allowreply");
		threadVO.setAllowreply(!allowreply.equals(""));
		threadVO.setFid(thread.get("fid"));
		threadVO.setTid(thread.get("tid"));
		threadVO.setSid(sid);
		threadVO.setFormhash(formhash);
		return threadVO;
	}
	
	
	public GoToVo getGoToVo(HttpServletRequest request,Map<String,String> settingMap,Members currentMember,String formhash,String sid){
		GoToVo goToVo = new GoToVo();
		setHeaderVO(goToVo.getHeaderVO(), settingMap.get("bbname"));
		setFooterVO(request, settingMap, goToVo.getFooterVO(), currentMember, "goto", formhash, sid);
		return goToVo;
	}
	
	public NewThreadVO getNewThreadVO(HttpServletRequest request,Map<String,String> settingMap,Members currentMember,String formhash,String sid,String fid,String threadtypesString,DataParse dataParse){
		
		NewThreadVO newThreadVO = new NewThreadVO();
		setFooterVO(request, settingMap, newThreadVO.getFooterVO(), currentMember, "post", formhash, sid);
		setHeaderVO(newThreadVO.getHeaderVO(), settingMap.get("bbname"));
		
		Map threadtypesMap = dataParse.characterParse(threadtypesString, false);
		Object tempRequired = threadtypesMap.get("required");
		if(tempRequired!=null && !tempRequired.toString().equals("") && !tempRequired.toString().equals("0")){
			newThreadVO.setThreadtypes(threadtypesMap);
		}
		newThreadVO.setFid(fid);
		newThreadVO.setFormhash(formhash);
		return newThreadVO;
	}
	
	public NewReplyVO getNewReplyVO(HttpServletRequest request,Map<String,String> settingMap,Members currentMember,String formhash,String sid,String fid,String tid){
		NewReplyVO newReplyVO = new NewReplyVO();
		setFooterVO(request, settingMap, newReplyVO.getFooterVO(), currentMember, "post", formhash, sid);
		setHeaderVO(newReplyVO.getHeaderVO(), settingMap.get("bbname"));
		newReplyVO.setFid(fid);
		newReplyVO.setFormhash(formhash);
		newReplyVO.setTid(tid);
		newReplyVO.setSid(sid);
		return newReplyVO;
	}
	
	public MyVO getMyVO(HttpServletRequest request,Map<String,String> settingMap,Members currentMember,String formhash,String sid,Map<String,String> memberMap,int uid,int jsprun_uid,String username){
		MyVO myVO = new MyVO();
		myVO.setUid(uid+"");
		myVO.setUsername(username);
		setFooterVO(request, settingMap, myVO.getFooterVO(), currentMember, "my", formhash, sid);
		setHeaderVO(myVO.getHeaderVO(), settingMap.get("bbname"));
		String gender = memberMap.get("gender");
		
		if(gender.equals("1")){
			myVO.setGender("男");
		}else if(gender.equals("2")){
			myVO.setGender("女");
		}else{
			myVO.setGender("保密");
		}
		String bday = memberMap.get("bday");
		if(bday!=null && !bday.equals("") && !bday.equals("0000-00-00")){
			myVO.setBirthday(bday);
		}
		String location = memberMap.get("location");
		if(location!=null && !location.equals("")){
			myVO.setLocation(location);
		}
		String bio = memberMap.get("bio");
		if(bio!=null && !bio.equals("")){
			myVO.setBio(bio);
		}
		myVO.setSameMember(uid == jsprun_uid);
		
		return myVO;
	}
	
	public MyCollectionVO getMyCollectionVO(HttpServletRequest request,Map<String,String> settingMap,Members currentMember,String formhash,String sid,int jsprun_uid){
		MyCollectionVO myCollectionVO = new MyCollectionVO();
		setFooterVO(request, settingMap, myCollectionVO.getFooterVO(), currentMember, "my", formhash, sid);
		setHeaderVO(myCollectionVO.getHeaderVO(), settingMap.get("bbname"));
		
		DataBaseDao dataBaseDao = (DataBaseDao)BeanFactory.getBean("dataBaseDao");
		
		List<Map<String,String>> mythreadList = dataBaseDao.executeQuery("SELECT m.*, t.subject FROM "+tablePre+"mythreads m, "+tablePre+"threads t " +
				"WHERE m.uid = '"+jsprun_uid+"' AND m.tid = t.tid ORDER BY m.dateline DESC LIMIT 0, 3");
		if(mythreadList!=null ){
			for(Map<String,String> tempMap : mythreadList){
				tempMap.put("subject", Common.cutstr(tempMap.get("subject"), 15, null));
			}
		}
		myCollectionVO.setMythreadList(mythreadList);
		
		List<Map<String,String>> mypostList = dataBaseDao.executeQuery("SELECT m.*, t.subject FROM "+tablePre+"myposts m, "+tablePre+"threads t " +
				"WHERE m.uid = '"+jsprun_uid+"' AND m.tid = t.tid ORDER BY m.dateline DESC LIMIT 0, 3");
		if(mypostList!=null ){
			for(Map<String,String> tempMap : mypostList){
				tempMap.put("subject", Common.cutstr(tempMap.get("subject"), 15, null));
			}
		}
		myCollectionVO.setMypostList(mypostList);
		
		List<Map<String,String>> favthreadList = dataBaseDao.executeQuery("SELECT t.tid, t.subject FROM "+tablePre+"favorites fav, "+tablePre+"threads t " +
				"WHERE fav.tid=t.tid AND t.displayorder>='0' AND fav.uid='"+jsprun_uid+"' ORDER BY t.lastpost DESC LIMIT 0, 3");
		if(favthreadList!=null ){
			for(Map<String,String> tempMap : favthreadList){
				tempMap.put("subject", Common.cutstr(tempMap.get("subject"), 24, null));
			}
		}
		myCollectionVO.setFavthreadList(favthreadList);
		
		List<Map<String,String>> favforumList = dataBaseDao.executeQuery("SELECT f.fid, f.name FROM "+tablePre+"favorites fav, "+tablePre+"forums f WHERE fav.uid='"+jsprun_uid+"' AND fav.fid=f.fid ORDER BY f.displayorder DESC LIMIT 0, 3");
		myCollectionVO.setFavforumList(favforumList);
		
		return myCollectionVO;
	}
	
	
	public MyPhoneVO getMyPhoneVO(HttpServletRequest request,Map<String,String> settingMap,Members currentMember,String formhash,String sid){
		
		MyPhoneVO myPhoneVO = new MyPhoneVO();
		setFooterVO(request, settingMap, myPhoneVO.getFooterVO(), currentMember, "myphone", formhash, sid);
		setHeaderVO(myPhoneVO.getHeaderVO(), settingMap.get("bbname"));
		
		String user_agent = request.getHeader("user-agent").toLowerCase();
		myPhoneVO.setServerInfo(user_agent);
		Map<String,String> otherInfoMap = new HashMap<String, String>();
		
		Enumeration<String> headerInfo = request.getHeaderNames();
		while(headerInfo.hasMoreElements()){
			String tempName = headerInfo.nextElement();
			otherInfoMap.put(tempName, request.getHeader(tempName));
		}
		myPhoneVO.setOtherInfoMap(otherInfoMap);
		
		return myPhoneVO;
	}
	
	public SearchVO getSearchVO(HttpServletRequest request,Map<String,String> settingMap,Members currentMember,String formhash,String sid){
		SearchVO searchVO = new SearchVO();

⌨️ 快捷键说明

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