<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../inc/function.asp"-->
<%
On error resume next
url=Request("url")
act=cint(Request("action"))
Select Case act
  Case 1
     Call Cw_login()
  Case 2
     Call Cw_loginout()
End Select

Function Cw_login()
    Call Cw_yzm()'验证码
    user=login_check(trim(request("user")))'过滤危险字符
    pass=md5(trim(request("pass"))) 'MD5加密
    set rs=server.CreateObject("adodb.recordset")
    sq="select * from cw_user where [user]='"&user&"'"
    rs.open sq,conn,1,3
    if rs.recordcount=0 then
      response.Write("<script>alert('用户名或密码错误!');history.back();</script>")
      response.End()
    else
      pwd2=rs("pass")
	  jf=rs("jf")
      if pass<>pwd2 then
        response.Write("<script>alert('用户名或密码错误!');history.back();</script>")
        response.End()
      end if	  
	  session("user")=rs("user")
	  session("userid")=rs("id")
	  session("utype")=rs("type")
	  session("names")=rs("names")
	  session("tel")=rs("tel")
	  session("address")=rs("address")
    end if
	rs("logindate")=now()
	rs.update
    rs.close
    set rs=nothing
	Call Cw_jf("+",1)
	Call Cw_gr(jf)
	If url<>"" then
	   If instr(url,"reg.asp")>0 or instr(url,"user/")>0 then
	      Response.Redirect "index.asp"
	   Else
	      Response.Redirect url
	   End if
	Else
	   response.Redirect"Index.asp"
	End if
	response.End()
End Function
Function Cw_loginout()
  url=Request.ServerVariables("HTTP_REFERER")
  session("user")=""
  session("userid")=""
  session("utype")=""
  session("names")=""
  session("tel")=""
  session("address")=""
  Response.Write("<script>alert('您己安全退出用户中心！')</script>")
  if instr(url,"/user/")>0 then
    Response.Redirect cf_root
  else
    Response.Redirect url
  end if
End Function
If Session("user")<>"" and Session("userid")<>"" Then Response.Redirect"Index.asp"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用户登录 - <%=cf_name%></title>
<link rel="stylesheet" type="text/css" href="images/style.css" />
<script type="text/javascript" src="images/us.js"></script>
</head>

<body>
<!--#include file="top.asp"-->
<div class="login">   
   <div class="login_left">
      <div align="center"><img src="images/login_t.jpg" /></div>
      <form action="login.asp" method="post" onsubmit="return check_login(this)">
      <div class="login_box"><input name="user" type="text" id="user" tabindex="1" value="用户名" maxlength="20" onfocus="this.value='';this.className='login_input2';" onblur="if(this.value==''){this.value='用户名'};this.className='login_input'" class="login_input" /><label id="f_user"></label></div>
	  
	  <div class="login_box"><input name="pass" type="password" id="pass" tabindex="2" value="" maxlength="20" onfocus="this.className='login_input2';" onblur="this.className='login_input'" class="login_input" /><label id="f_pass"></label></div>
	  
	  <div class="login_box2"><input name="yzm" type="text" id="yzm" tabindex="2" value="验证码" maxlength="5"  onfocus="this.value='';this.className='login_input4';" onblur="if(this.value==''){this.value='验证码'};this.className='login_input3'" class="login_input3" />
	  <img src="../inc/code.asp" width="80" height="25" alt="看不清单击刷新" onclick="this.src='../inc/code.asp?' + Math.random();" style="cursor:pointer" align="absmiddle"/><input name="action" type="hidden" id="action" value="1" /><input name="url" type="hidden" id="url" value="<%=Request.ServerVariables("HTTP_REFERER")%>" /><label id="f_yzm"></label></div>
	  <div class="login_box"><input type="submit" name="sub" value="" class="login_submit" /></div>
	  <div class="login_line"><a href="reg.asp">免费注册</a> | <a href="cw_repass.asp">忘记密码</a></div>
	  <div class="login_qq"><a href="qq.asp"><img src="images/qq.png" align="absmiddle" />腾讯QQ账号登录</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=""><img src="images/weibo.png" />新浪微博登录</a></div>
     </form>
   </div>
   <div class="login_right">
      <div class="login_bg">
	      <p><b>还没有自己的帐户？</b><br />点此注册成为<%=cf_name%>的会员，免费发布二手信息，<br />生活服务信息，招聘求职信息，免费加入企业黄页等。<br /><a href="reg.asp"><img src="images/reg.jpg" alt="用户注册" /></a></p>
	  </div>
   </div>
   <div class="clear"></div>
</div>
</body>
</html>
