<%
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
%>
<!--#include file="inc/config.asp"-->
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="uc_api/uc_client/client.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>用户登录</title>
<link href="style/global.css" rel="stylesheet" type="text/css" />
<link href="member/style/member.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/common.js"></script>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>
<body>
<!--#include file="templet/head.htm" -->
<%
function addusermember(user_id,user_pass,user_mail)
	dim rs
	''''''''''''''
	'insert t_member
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from t_member where 1=0",conn,3,3
	rs.addnew
	rs("UserType")=0
	rs("UserId")=user_id
	rs("UserPass")=user_pass			
	rs("PassAsk")=""
	rs("PassAnswer")=""	
	rs("Email")=user_mail		
	rs("RegIp")=ip
	rs("RegDate")=now()			
	rs("LoginNum")=0
	rs("LastLoginIp")=ip
	rs("LastLoginDate")=now()
	rs("IsLocked")=0
	rs("GoldMoney")=0.00
	rs("Score")=100
	rs("IsCheck")=1
	rs("UserLevel")=0
	rs.update
	rs.close
	set rs=nothing
	''''''''''''''''''''
	'insert t_member_p
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from t_member_p where 1=0",conn,3,3
	rs.addnew
	rs("UserId")=user_id
	rs("Email")=user_mail
	rs("UserName")=user_id
	rs("IdCard")=""
	rs("BornDate")=""
	rs("Sex")=Sex
	rs("Age")=0
	rs("Province")=""
	rs("City")=""
	rs("Education")=""
	rs("Profession")=""
	rs("InCome")=""
	rs("Tel")=""
	rs("Mobile")=""
	rs("QQ")=""
	rs("MSN")=""
	rs("HomePage")=""
	rs("Address")=""
	rs("PostCode")=""
	rs("Photo")="/images/nophoto.gif"
	rs("Demons")=""
	rs.update
	rs.close
	set rs=nothing

end function
dim act,directurl,rs,uc_uid
uc_uid=empty
act=request.QueryString("act")
if(request.QueryString("directurl")<>"") then
	directurl=request.QueryString("directurl")
else
	directurl=request.ServerVariables("HTTP_REFERER")
end if
if(directurl="") then
	directurl=SiteUrl&"/member/"
else
end if
if(act="do") then
	dim flag,username,userpass,userpass2,email,ip,loginok,expire,usertype,uid,msg,uscheck
	loginok=false
	if(isSelfRefer()) then
		if(request.Form("username")<>"") then
			Session("GetCode")=""
			username=request.Form("username")
			username=replace(username,"'","")
			expire=Cint(request.Form("expire"))			
			userpass=request.Form("userpass")
						
			ip=GetIp()
			''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
			'结合判断开始
			''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
			if(BindUc=true) then
				XML_login = uc_user_login(username,userpass) ' 需要xml转化提取数组出来
				'response.write XML_login
				arr_login =  xml2array(XML_login)		
				uc_uid = Clng(arr_login(0))
				username= arr_login(1)
				password= arr_login(2)
				email = arr_login(3)
			
				If (uc_uid >0) Then 
					'用户登陆成功，设置登陆成功的标志，您可以采用Cookies保存登陆信息
					'生成同步登录的代码
					ucsynlogin = uc_user_synlogin(uc_uid) '返回javascript分别调用各个应用进行登陆				
				 elseif(uc_uid = "-1") Then 
					call alertstr("用户不存在,或者被删除",1)
				 elseif(uc_uid = "-2") Then 
					call alertstr("密码错",1)
				 else 
					call alertstr("未定义",1)
				End If 
			end if
			'''''''''''''''''''''''''''''''
			'Cms判断开始
			'''''''''''''''''''''''''''''''
			'response.Write("test---------------------<br>"&totcms&"--------------------")
			userpass=Php_MD5(userpass)
			set rs=server.CreateObject("adodb.recordset") 
			rs.open "select * from t_member where UserId='"&username&"' and UserPass='"&userpass&"' order by id desc",conn,3,3
			if rs.eof or rs.bof then
				if(uc_uid>0) then
					call addusermember(username,userpass,email)
				else
					loginok=false		
					msg="用户名或密码错误"
				end if
			else
				usertype=rs("UserType")
				uid=rs("id")
				if(rs("IsCheck")=0) then
					loginok=false
					msg="暂时没有通过审核"
				elseif(rs("IsLocked")=1) then
					loginok=false
					msg="帐户已锁定"
				else
					loginok=true
					rs("LastLoginIp")=ip
					rs("LastLoginDate")=now()
					rs("LoginNum")=rs("LoginNum")+1
					rs.update
				end if
			end if
			rs.close
			set rs=nothing
			if(loginok=true and uid>0) then
				'conn.execute("update t_member set LoginNum=LoginNum+1 where UserId='"&username&"'")
				''''''''''''''''''''''设置Cookie''''''''''''''''''''''
				'Response.Cookies("TotCms_Cookie")("UserName")=php_Base64Encode(username)
				'Response.Cookies("TotCms_Cookie")("UserType")=php_Base64Encode(usertype)
				'Response.Cookies("TotCms_Cookie")("UserPass")=userpass	
				'Response.Cookies("TotCms_Cookie")("LastVisite")=now()			
        'Response.Cookies("TotCms_Cookie").path="/"
				'Response.Cookies("TotCms_Cookie").Domain=CookieUrl
        'Response.Cookies("TotCms_Cookie").Expires=Date()+expire
				session("TotCms_UserName")=username
				session("TotCms_RealName")=username
				session("TotCms_UserType")=usertype
				session("TotCms_UserId")=uid
				response.Write(ucsynlogin)
				response.Write("<meta http-equiv=""Refresh"" content=""1;URL="&directurl&""" />"&Chr(10))
				response.Write("<p align=""center"">成功登录，正在转向上一页面.....</p>")
				Session("GetCode")=""
			else
				call alertstr(msg,1)
			end if
		end if
	else
		call alertstr("请从本站登录",1)
	end if
else
%>
<script type="text/javascript">
function check(obj){
	with(obj){
		if(username.value==""){
			alert("用户名不能空为!");
			username.focus();
			username.select();
			return false;
		}
		if(userpass.value==""){
			alert("密码不能空为!");
			userpass.focus();
			userpass.select();
			return false;
		}		
		if(checkcode.value==""){
			alert("验证码不能空为!");
			checkcode.focus();
			checkcode.select();
			return false;
		}
		return true;
	}
}
function checkemail(obj){
	var pattern = /^([\.a-zA-Z0-9_-]){3,}@([\.a-zA-Z0-9_-]){2,}(\.([a-zA-Z0-9]){2,4}){1,2}$/; 
	if(!pattern.test(obj.value)){
		alert("请输入您正确的邮箱格式!");
		obj.focus();
	}
}
function checkblur(obj){
	if(/[^\u4e00-\u9fa50-9a-zA-Z_]/g.test(obj.value)){
		alert('只限英文字母、数字和下划线!');
		obj.focus();
		obj.select();
	}
}
</script>
<table width="960" border="0" align="center" cellpadding="0" cellspacing="0" class="body_bg">
  <tr>
    <td width="27" valign="top">&nbsp;</td>
    <td width="769"><div align="center"><img src="images/login_01.gif" alt="会员注册" width="651" height="89" /></div></td>
  </tr>
</table>
<form id="form1" name="form1" method="post" action="?act=do&directurl=<%=directurl%>" onsubmit="return check(this)">
  <table width="960" border="0" align="center" cellpadding="0" cellspacing="0" class="body_bg">
    <tr>
      <td height="35" colspan="2"><div align="center"><strong>会员登录</strong> <a href="reg.asp?gourl=<%=server.URLEncode(directurl)%>">还没有注册？</a> </div></td>
    </tr>
    <tr>
      <td width="344" height="35"><div align="right">用户名：</div></td>
      <td width="452"><div align="left">
          <input name="username" type="text" id="username" onblur="checkblur(this)" />
      (<span class="style1">*</span>)</div></td>
    </tr>
    <tr>
      <td height="35"><div align="right">密码：</div></td>
      <td><div align="left">
          <input name="userpass" type="password" id="userpass" />
      (<span class="style1">*</span>)</div></td>
    </tr>
    <tr>
      <td height="50" colspan="2"><div align="center">
        <input type="submit" name="Submit" value="登  录" />&nbsp;&nbsp;
        <input type="reset" name="Submit2" value="重  写" />
        <a href="findpass.asp">忘记密码？</a></div></td>
    </tr>
  </table>
</form>
<%end if%>
<!--#include file="templet/root.htm" -->
</body>
</html>
<%
call connclose()
%>