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

📄 knowmate_k1.jsp.svn-base

📁 用手机浏览的一个类似于聊天室 博克 homepage 等 对这方面有 兴趣的朋友 有所帮助的
💻 SVN-BASE
📖 第 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(",");
	//for(int i=0;i<unansweredTitles.length;i++){
		//System.out.println(unansweredTitles[i]+"===unansweredTitles1234===");
	
	//}
	/*------------------------------------------------------------------------------------------------------
	+	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("-",""));
	
		
	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 quiz_idx from gt_lucky_quiz_mylog where title=? and phonenum=?";
			//pstmt = con.prepareStatement(sql);
			//pstmt.setString(1,unansweredTitles[i+1]);
			//pstmt.setLong(2,Long.parseLong(gphone));
			//rs = pstmt.executeQuery();
			//if(rs.next()){
				//quiz_idx_unanswered = rs.getString("quiz_idx");
				//System.out.println(quiz_idx_unanswered+"===quiz_idx_unanswered===0612==1==");
				//System.out.println(unansweredIdxs[i+1]+"===unansweredIdxs[i]===0612==1==");
			//}
			//rs.close();
			//pstmt.close();
			//System.out.println(quiz_idx_unanswered+"===quiz_idx_unanswered=======0612");
			sql = "select * from gt_lucky_quiz_mylog 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{
				System.out.println((guestAnswers[i]!=null)+"---------------true?------------------");
				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,gt_lucky_quiz b"+
						" 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,gt_lucky_quiz b"+
		  " 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,gt_lucky_quiz b"+
		  " 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();
	//System.out.println(unansweredTitleList+"===unansweredTitles===");

	/*-------------------------------------------------------------------------------------------------------
		insert guest's answers 
	-------------------------------------------------------------------------------------------------------*/
	
	/*-------------------------------------------------------------------------------------------------------
		get the count of all title which the host have answered
	-------------------------------------------------------------------------------------------------------*/
	
	
	sql = " select  count(1) allcount from gt_lucky_quiz_mylog a,gt_lucky_quiz b "+
		  " 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");
	}
	//System.out.println(allCount+"===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,gt_lucky_quiz b"+
		  " 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");
	}
	//System.out.println(answeredCount+"===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,gt_lucky_quiz b,gt_lucky_quiz_mylog c"+
		  " 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");
	}
	//System.out.println(answeredRightCount+"===answeredRightCount");
	rs.close();
	pstmt.close();
	/*-------------------------------------------------------------------------------------------------------
		get the count of guest unanswered title
	-------------------------------------------------------------------------------------------------------*/
	
	
	sql = " select  count(a.idx) answeredcount from gt_lucky_quiz_mylog a,gt_lucky_quiz b"+
		  " 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,gt_lucky_quiz b"+
		  " 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");
	}
		//System.out.println(unansweredCount+"===unansweredCount");
	rs.close();
	pstmt.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 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) 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);
			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%>">
<input type="hidden" name="status" value="insertMulti">
<table width="176" border="0" cellspacing="0" cellpadding="0">
	<!--鸥捞撇 矫累-->
	<tr>
		<td>
			<table width="176" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td colspan="2" height="2" bgcolor="#c789ff"></td>
				</tr>
				<tr>
					<td width="6" height="14" bgcolor="#9819e9"></td>
					<td height="14" bgcolor="#9819e9"><font color="#ffffff"><%=nickname %>丛俊 措秦 舅扁</font></td>
				</tr>
				<tr>
					<td colspan="2" height="2" bgcolor="#c789ff"></td>
				</tr>
				<tr>
					<td colspan="2" height="1" bgcolor="#9819e9"></td>
				</tr>
			</table>
		</td>
	</tr>
	<!--鸥捞撇 场-->

⌨️ 快捷键说明

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