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

📄 knowmate_k.jsp

📁 用手机浏览的一个类似于聊天室 博克 homepage 等 对这方面有 兴趣的朋友 有所帮助的
💻 JSP
📖 第 1 页 / 共 2 页
字号:
<!-------------------------------------------------------------
* @ name: knowmate_k.jsp
* @ Author : ranxu 
* @ date :2008-06-06
-------------------------------------------------------------->
<%@ page import='java.io.*,java.text.*,java.util.Date,java.util.Vector, java.sql.*, com.entaz.lib.db.*, com.entaz.relay.net.*' contentType='text/html;charset=euc-kr'%>
<%@ include file="../imgpath.jsp"%>
<%@ include file="../common_func.jsp"%>
<%@ include file="../makeKOR.jsp"%>
<%! 
	/*------------------------------------------------------------------------------------------------------
	+	method:getAnswer()
		action:Answer 1(db)--"O"(jsp)  0(db)--"X"(jsp)
		author:ranxu 2008-06-05
	-------------------------------------------------------------------------------------------------------*/
	int ANSWER_O = 1;
	int ANSWER_X = 0;	
	public String getAnswer(int key) 
	{
		String ret = "";
		if(key==ANSWER_O){
			ret = "O";
		}else if(key==ANSWER_X){
			ret = "X"; 
		}
		return ret;
	}	
	String STR_ANSWER_O = "1";
	String STR_ANSWER_X = "0";
	public String getAnswer(Object key) 
	{
		String ret = "";
		if(key==STR_ANSWER_O){
			ret = "O";
		}else if(key==STR_ANSWER_X){
			ret = "X"; 
		}
		return ret;
	}	
%>
<%
	/*------------------------------------------------------------------------------------------------------
		parameter from last page:knowmate_s.jap
	-------------------------------------------------------------------------------------------------------*/
	String 		nickname 			= java.net.URLDecoder.decode(makeKOR(request.getParameter("nickname")));
	String 		mphone 				= request.getParameter("mphone");
	String 		gphone 				= request.getParameter("gphone");
	String 		status 				= java.net.URLDecoder.decode(makeKOR(request.getParameter("status")));	
	String 		str_unansweredTitle = java.net.URLDecoder.decode(makeKOR(request.getParameter("str_unansweredTitle")));
	String 		str_unansweredIdx 	= java.net.URLDecoder.decode(makeKOR(request.getParameter("str_unansweredIdx")));
	String [] 	unansweredTitles	= new String[5];
	String [] 	unansweredIdxs 		= new String[5];
				unansweredTitles 	=str_unansweredTitle.split(";");
				unansweredIdxs 		= str_unansweredIdx.split(";");
	/*------------------------------------------------------------------------------------------------------
	+	DB 
	-------------------------------------------------------------------------------------------------------*/
	PreparedStatement 	pstmt	= null;
	Connection 			con 	= null;
	Statement 			stmt 	= null;
	ResultSet 			rs 		= null;
	String 				sql		= null;
	int 				ret 	= -1;	
	/*------------------------------------------------------------------------------------------------------
	 +	init parameter of current page
	 -------------------------------------------------------------------------------------------------------*/
	List 		answeredtitleList 	= null;
	List 		answeredIdxList 	= null;
	List 		hostAnswerList 		= null;
	String[] 	guestAnswers		= null;
	List 		unansweredTitleList = null;
	List 		unansweredIdxList 	= null;
	double 		allCount			= 0.0;
	double 		answeredCount 		= 0.0;
	double 		answeredRightCount 	= 0.0;
	int 		unansweredCount 	= 0;
	int 		matchPoint			=0;
	int 		knowPoint			=0;
	String 		riqi 				= null;
	int 		intRiqi 			= 0;
	
	Date 		regdater 			= new Date();
	SimpleDateFormat sf 			= new SimpleDateFormat("yyyy-MM-dd");
				riqi 				= sf.format(regdater);
				intRiqi 			= Integer.parseInt(riqi.replace("-",""));			
	boolean 	haveDate 			= true;
	boolean 	haveDateOne 		= true;
	try
	{
	/*------------------------------------------------------------------------------------------------
	 *		DB 目池记
	 -------------------------------------------------------------------------------------------------*/
	%><%@ include file="../getConnection.jsp"%><%   
    /**************************************
			胶鸥客 嘎苗焊绰 矾宏款技!
	***************************************/
	/*-------------------------------------------------------------------------------------------------------
		insert multi guest's answers 
	-------------------------------------------------------------------------------------------------------*/
	answeredtitleList = new ArrayList();
	answeredIdxList = new ArrayList();
	hostAnswerList = new ArrayList();
	guestAnswers=new String[unansweredTitles.length-1];
	if(status.equals("insertMulti")){		
		for(int i=0;i<unansweredTitles.length-1;i++){			
			String	quiz_idx_unanswered = "";
			guestAnswers[i]= request.getParameter("ox"+i);
			sql = "select * from gt_lucky_quiz_mylog WITH (READUNCOMMITTED) where quiz_idx=? and phonenum=? and guest_phone=?";
			pstmt = con.prepareStatement(sql);
			pstmt.setString(1,unansweredIdxs[i+1]);
			pstmt.setLong(2,Long.parseLong(gphone));
			pstmt.setLong(3,Long.parseLong(mphone));
			rs = pstmt.executeQuery();
			if(rs.next()){
			}else{
				if(guestAnswers[i]!=null){
					sql="insert into gt_lucky_quiz_mylog (quiz_idx,title,answer,phonenum,guest_phone,regdate,nregdate) values (?,?,?,?,?,?,?)";				
					pstmt = con.prepareStatement(sql);	
					pstmt.setString(1,unansweredIdxs[i+1]);	
					pstmt.setString(2,unansweredTitles[i+1]);		
					pstmt.setString(3,guestAnswers[i]);	
					pstmt.setString(4,gphone);	
					pstmt.setString(5,mphone);
					pstmt.setString(6,riqi);	
					pstmt.setInt(7,intRiqi);
					ret = pstmt.executeUpdate();
					if(ret==-1){		
						//return;
					}
					pstmt.close();
					// answered titles 
					answeredtitleList.add(unansweredTitles[i+1]);
					answeredIdxList.add(unansweredIdxs[i+1]);
					//the host's answers of the titles
					sql=" select distinct a.*  from gt_lucky_quiz_mylog a WITH (READUNCOMMITTED),gt_lucky_quiz b WITH (READUNCOMMITTED)"+
						" where  a.quiz_idx = b.idx and b.flag=1  "+
						" and a.phonenum =? and a.guest_phone =? and a.title=?";
					pstmt = con.prepareStatement(sql); 
					pstmt.setLong(1,Long.parseLong(gphone));
					pstmt.setLong(2,Long.parseLong(gphone));
					pstmt.setString(3,unansweredTitles[i+1]);
					rs=pstmt.executeQuery();
					while(rs.next()){		
						hostAnswerList.add(rs.getString("answer"));		
					}
					rs.close();
					pstmt.close();
				}
			}
			rs.close();
			pstmt.close();
		}				
	}
	/*-------------------------------------------------------------------------------------------------------
		get the unanswered title
	-------------------------------------------------------------------------------------------------------*/
	unansweredTitleList = new ArrayList();
	unansweredIdxList = new ArrayList();
	sql = " select top 5 a.* from gt_lucky_quiz_mylog a WITH (READUNCOMMITTED),gt_lucky_quiz b WITH (READUNCOMMITTED)"+
		  " where a.quiz_idx = b.idx and b.flag=1 "+
		  " and a.phonenum =? and a.guest_phone= ?" +
		  " and a.quiz_idx not in"+
		  " (select distinct a.quiz_idx from gt_lucky_quiz_mylog a WITH (READUNCOMMITTED),gt_lucky_quiz b WITH (READUNCOMMITTED)"+
		  " where  a.quiz_idx = b.idx and b.flag=1 "+
		  " and a.phonenum =? and a.guest_phone = ?" +
		  " )order by a.idx desc";
	pstmt = con.prepareStatement(sql);
	pstmt.setLong(1,Long.parseLong(gphone));
	pstmt.setLong(2,Long.parseLong(gphone));
	pstmt.setLong(3,Long.parseLong(gphone));
	pstmt.setLong(4,Long.parseLong(mphone));
	rs=pstmt.executeQuery();
	while(rs.next()){
		unansweredTitleList.add(rs.getString("title"));
		unansweredIdxList.add(rs.getString("quiz_idx"));
	}
	rs.close();
	pstmt.close();
	/*-------------------------------------------------------------------------------------------------------
		get the count of all title which the host have answered
	-------------------------------------------------------------------------------------------------------*/
	sql = " select  count(1) allcount from gt_lucky_quiz_mylog a WITH (READUNCOMMITTED),gt_lucky_quiz b WITH (READUNCOMMITTED)"+
		  " where a.quiz_idx = b.idx and b.flag=1 "+
		  " and a.phonenum =? and a.guest_phone=? ";
	pstmt = con.prepareStatement(sql);
	pstmt.setLong(1,Long.parseLong(gphone));
	pstmt.setLong(2,Long.parseLong(gphone));
	rs=pstmt.executeQuery();
	if(rs.next()){
		allCount = rs.getDouble("allcount");
	}
	rs.close();
	pstmt.close();
	/*-------------------------------------------------------------------------------------------------------
		get the count of guest answered title
	-------------------------------------------------------------------------------------------------------*/
	sql = " select count(distinct a.idx) answeredcount from gt_lucky_quiz_mylog a WITH (READUNCOMMITTED),gt_lucky_quiz b WITH (READUNCOMMITTED)"+
		  " where  a.quiz_idx = b.idx and b.flag=1  "+
		  " and a.phonenum =?  and a.guest_phone =?";
	pstmt = con.prepareStatement(sql);
	pstmt.setLong(1,Long.parseLong(gphone));
	pstmt.setLong(2,Long.parseLong(mphone));
	rs=pstmt.executeQuery();
	if(rs.next()){
		answeredCount = rs.getDouble("answeredcount");
	}
	rs.close();
	pstmt.close();
	/*-------------------------------------------------------------------------------------------------------
		get the count of guest answered right title
	-------------------------------------------------------------------------------------------------------*/
	sql = " select count(a.idx) answeredrightcount from gt_lucky_quiz_mylog a WITH (READUNCOMMITTED),gt_lucky_quiz b WITH (READUNCOMMITTED),gt_lucky_quiz_mylog c WITH (READUNCOMMITTED)"+
		  " where a.quiz_idx = b.idx and b.flag=1 and a.quiz_idx=c.quiz_idx and a.answer = c.answer"+
		  " and a.phonenum =? and a.guest_phone =? " +
		  " and c.phonenum =? and c.guest_phone =? ";
	pstmt = con.prepareStatement(sql);
	pstmt.setLong(1,Long.parseLong(gphone));
	pstmt.setLong(2,Long.parseLong(gphone));
	pstmt.setLong(3,Long.parseLong(gphone));
	pstmt.setLong(4,Long.parseLong(mphone));
	rs=pstmt.executeQuery();
	if(rs.next()){
		answeredRightCount = rs.getDouble("answeredrightcount");
	}
	rs.close();
	pstmt.close();
	/*-------------------------------------------------------------------------------------------------------
		get the count of guest unanswered title
	-------------------------------------------------------------------------------------------------------*/
	sql = " select  count(a.idx) answeredcount from gt_lucky_quiz_mylog a WITH (READUNCOMMITTED),gt_lucky_quiz b WITH (READUNCOMMITTED)"+
		  " where a.quiz_idx = b.idx and b.flag=1 "+
		  " and a.phonenum =? and a.guest_phone=? " +
		  " and a.quiz_idx not in"+
		  " (select distinct a.quiz_idx from gt_lucky_quiz_mylog a WITH (READUNCOMMITTED),gt_lucky_quiz b WITH (READUNCOMMITTED)"+
		  " where  a.quiz_idx = b.idx and b.flag=1 "+
		  " and a.phonenum =? and a.guest_phone =? )";	
	pstmt = con.prepareStatement(sql);
	pstmt.setLong(1,Long.parseLong(gphone));
	pstmt.setLong(2,Long.parseLong(gphone));
	pstmt.setLong(3,Long.parseLong(gphone));
	pstmt.setLong(4,Long.parseLong(mphone));
	rs=pstmt.executeQuery();
	if(rs.next()){
		unansweredCount = rs.getInt("answeredcount");
	}
	rs.close();
	pstmt.close();	
	/*-------------------------------------------------------------------------------------------------------
		update attention point when the guest answer the question at the first time
	-------------------------------------------------------------------------------------------------------*/
	sql = "SELECT * FROM GT_LUCK_POINT_DATE WHERE mphone = ? and gphone = ?";
	pstmt = con.prepareStatement(sql);
	pstmt.setLong(1,Long.parseLong(mphone));
	pstmt.setLong(2,Long.parseLong(gphone));
	rs=pstmt.executeQuery();
	if(rs.next()){

	}else{
		haveDateOne = false;
	}
	rs.close();
	pstmt.close();
	if(haveDateOne){
		sql = "SELECT * FROM GT_LUCK_POINT_DATE WHERE mphone = ? and gphone = ? and left(answer_point_date,10) > left(getdate()-2,10)";
		pstmt = con.prepareStatement(sql);
		pstmt.setLong(1,Long.parseLong(mphone));
		pstmt.setLong(2,Long.parseLong(gphone));
		rs=pstmt.executeQuery();
		if(rs.next()){
			haveDate = false;
		}
		rs.close();
		pstmt.close();
		if(haveDate){
			sql = "UPDATE GT_LUCK_POINT_DATE SET answer_point_date = getdate() WHERE gphone = ? and mphone = ?";
			pstmt = con.prepareStatement(sql);
			pstmt.setLong(1,Long.parseLong(gphone));
			pstmt.setLong(2,Long.parseLong(mphone));
			ret = pstmt.executeUpdate();
			pstmt.close();
		}
	}else{
		sql = "insert into gt_luck_point_date (mphone,gphone,answer_point_date) values (?,?,getdate())";
		pstmt = con.prepareStatement(sql);
		pstmt.setLong(1,Long.parseLong(mphone));
		pstmt.setLong(2,Long.parseLong(gphone));
		ret = pstmt.executeUpdate();
		pstmt.close();
	}
	if(haveDate){
		sql = "select * from gt_lucky_attention_point WITH (READUNCOMMITTED) where phonenum=? and guest_phone=? ";
		pstmt = con.prepareStatement(sql);
		pstmt.setLong(1,Long.parseLong(gphone));
		pstmt.setLong(2,Long.parseLong(mphone));
		rs=pstmt.executeQuery();
		if(rs.next()){
			sql = "update gt_lucky_attention_point set attention_point=attention_point+1 where phonenum=? and guest_phone=?";
			pstmt = con.prepareStatement(sql);
			pstmt.setLong(1,Long.parseLong(gphone));
			pstmt.setLong(2,Long.parseLong(mphone));
			ret = pstmt.executeUpdate();
			pstmt.close();
		}else{
			sql = "insert into gt_lucky_attention_point (phonenum,guest_phone,attention_point,attention_point_old,regdate) values (?,?,?,?,?)";
			pstmt = con.prepareStatement(sql);
			pstmt.setLong(1,Long.parseLong(gphone));
			pstmt.setLong(2,Long.parseLong(mphone));
			pstmt.setLong(3,1);
			pstmt.setLong(4,0);
			pstmt.setString(5,riqi);
			ret = pstmt.executeUpdate();
			pstmt.close();
		}
		rs.close();
	}
	/*-------------------------------------------------------------------------------------------------------
		概莫档 捞秦档 insert,update
	-------------------------------------------------------------------------------------------------------*/
	matchPoint = (int)(answeredRightCount/answeredCount*100);
	knowPoint = (int)(answeredRightCount/allCount*100);
	if(matchPoint>100){
		matchPoint = 100;
	}
	if(knowPoint>100){
		knowPoint = 100;
	}
	sql = "select * from gt_lucky_match_point WITH (READUNCOMMITTED) where phonenum=? and guest_phone=? ";
		pstmt = con.prepareStatement(sql);
		pstmt.setLong(1,Long.parseLong(gphone));
		pstmt.setLong(2,Long.parseLong(mphone));
		rs=pstmt.executeQuery();
		if(rs.next()){
			sql = "update gt_lucky_match_point set match_point=?,know_point = ? where phonenum=? and guest_phone=?";
			pstmt = con.prepareStatement(sql);
			pstmt.setLong(1,matchPoint);
			pstmt.setLong(2,knowPoint);
			pstmt.setLong(3,Long.parseLong(gphone));
			pstmt.setLong(4,Long.parseLong(mphone));
			ret = pstmt.executeUpdate();
			pstmt.close();
		}else{
			sql = "insert into gt_lucky_match_point (phonenum,guest_phone,match_point,know_point,regdate) values (?,?,?,?,?)";
			pstmt = con.prepareStatement(sql);
			pstmt.setLong(1,Long.parseLong(gphone));
			pstmt.setLong(2,Long.parseLong(mphone));
			pstmt.setLong(3,matchPoint);
			pstmt.setLong(4,knowPoint);
			pstmt.setString(5,riqi);
			ret = pstmt.executeUpdate();
			pstmt.close();
		}
		rs.close();	
 %>
<html>
<head>
	<link href="http://entaz.mugeta.com/client/mugeta_v2_test/web/user/mobile.css" rel="stylesheet" type="text/css">
	<title>权> 酒捞叼咯几磊丛俊 措秦 舅扁</title>
</head>
<body>
<form name="form1" action="knowmate_k.jsp" method="post">
<input type="hidden" name="mphone" value="<%=mphone%>">
<input type="hidden" name="gphone" value="<%=gphone%>">
<input type="hidden" name="nickname" value="<%=nickname%>">

⌨️ 快捷键说明

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