<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*"%>
<%@ page import="java.sql.*"%> 
<%@ page import="java.util.*"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.*"%>
<%@ include file="../inc/conn.jsp"%>
<%
  String username = new String(request.getParameter("bbsuser").getBytes("iso-8859-1"));
  String pass = new String(request.getParameter("password").getBytes("iso-8859-1"));
  String rand = (String)session.getAttribute("rand");
  String useryz = request.getParameter("useryz");
  if (rand.equals(useryz))
     {
    String sql="select * from clubuser where clubuser_name='"+username+"' and clubuser_password='"+pass+"'";
    ResultSet rs=stmt.executeQuery(sql);
     //rs.next();
	 if (rs.next())
	    {
		String bbsuser=rs.getString("clubuser_nickname");
		String name=rs.getString("clubuser_name");
		String bz=rs.getString("bbsmanager");
		String bbsadmin=rs.getString("bbsadmin");
		String payuser=rs.getString("payuser");
	    if (rs.getString("payuser").equals("3"))
	       {
           out.print("<script language='javascript'>");
           out.print("alert('对不起,你的用户名被管理员封锁了!');");
           out.print("history.go(-1);");
           out.print("</script>");
           out.close();
		   }
		else
		  {
     //Cookie c=new Cookie("clubusername",username);
     //response.addCookie(c);
	 //Cookie d=new Cookie("pass",pass);
     //response.addCookie(d);
	 session.setAttribute("bbsuser",bbsuser);
	 session.setAttribute("name",name);
	 session.setAttribute("bz",bz);
	 session.setAttribute("bbsadmin",bbsadmin);
	 session.setAttribute("payuser",payuser);
	 
	 String sqlstr="update clubuser set clubuser_lasttime=getdate(),tili=tili+100 where clubuser_name='"+(String)session.getAttribute("name")+"'";
     stmt.executeUpdate(sqlstr);
	 
     out.print("<script language='javascript'>");
     out.print("window.location.href='main.jsp';");
     out.print("parent.left.document.location.reload();");
	 //out.print("history.go(-1);");
     out.print("</script>");
     out.close();
	      }
	    }
	 else
	   {
  	     out.print("<script>");
         out.print("alert('用户名或密码错误');");
         out.print("window.location.href='userlogin.jsp';");
         out.print("</script>");		   
		}
	 stmt.close(); 
     conn.close();
	}
  else
	{
  	     out.print("<script>");
         out.print("alert('验证码输入有误!请核对!');");
         out.print("window.location.href='userlogin.jsp';");
         out.print("</script>");	
	}
%>