会员登陆

<% sub box(B_text,B_url,B_type) response.Write "
" if B_url="back" then response.Write "
" else response.Write "
" end if response.end() end sub Function URLDecode(enStr) dim deStr dim c,i,v deStr="" for i=1 to len(enStr) c=Mid(enStr,i,1) if c="%" then v=eval("&h"+Mid(enStr,i+1,2)) if v<128 then deStr=deStr&chr(v) i=i+2 else if isvalidhex(mid(enstr,i,3)) then if isvalidhex(mid(enstr,i+3,3)) then v=eval("&h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2)) deStr=deStr&chr(v) i=i+5 else v=eval("&h"+Mid(enStr,i+1,2)+cstr(hex(asc(Mid(enStr,i+3,1))))) deStr=deStr&chr(v) i=i+3 end if else destr=destr&c end if end if else if c="+" then deStr=deStr&" " else deStr=deStr&c end if end if next URLDecode=deStr end function if session("from")="" then from="../member/index.asp" else from=session("from") end if genkey=Trim(Request.QueryString("genkey")) Code = Trim(Request.QueryString("code")) If Code = "" Then response.Redirect "https://open.weixin.qq.com/connect/oauth2/authorize?appid="&APPID&"&redirect_uri="&server.URLEncode("http://"&request.ServerVariables("HTTP_HOST")&request.ServerVariables("URL")&"?genkey="&genkey)&"&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect" Else set xmlhttp=server.createobject("microsoft.XMLHTTP") If Err Then Err.Clear set xmlhttp=server.createobject("MSXML2.XMLHTTP") end if xmlhttp.open "Post","https://api.weixin.qq.com/sns/oauth2/access_token?appid="&APPID&"&secret="&APPSECRET&"&code="&Trim(Request.QueryString("code"))&"&grant_type=authorization_code",false xmlhttp.send xmlpass=xmlhttp.responsetext set xmlhttp=nothing C_config=xmlpass openid=split(split(C_config,"openid"":""")(1),"""")(0) access_token=split(split(C_config,"access_token"":""")(1),"""")(0) End If set xmlhttp=server.createobject("microsoft.XMLHTTP") If Err Then Err.Clear set xmlhttp=server.createobject("MSXML2.XMLHTTP") end if xmlhttp.open "Get","https://api.weixin.qq.com/sns/userinfo?access_token="&access_token&"&openid="&openid&"&lang=zh_CN",false xmlhttp.send xmlpass=xmlhttp.responsetext set xmlhttp=nothing C_config=xmlpass nickname=split(split(C_config,"nickname"":""")(1),"""")(0) headimgurl=split(split(C_config,"headimgurl"":""")(1),"""")(0) country=split(split(C_config,"country"":""")(1),"""")(0) province=split(split(C_config,"province"":""")(1),"""")(0) city=split(split(C_config,"city"":""")(1),"""")(0) if nickname="" then call box("授权失败，请重新登录！","../member/member_login.asp","error") else set rs=server.createobject("ADODB.Recordset") sql="select * from SL_member where M_qqid='"&openid&"'" rs.open sql,conn,1,1 if not rs.eof then M_login=rs("M_login") M_id=rs("M_id") session("M_login")=M_login session("M_id")=M_id session("M_pwd")=openid conn.execute("update SL_member set M_genkey='"&genkey&"' where M_qqid='"&openid&"'") call box("欢迎回来！"&M_login&"",URLdecode(from),"success") else sql="insert into SL_member(M_login,M_pwd,M_email,M_fen,M_pic,M_regtime,M_qqid,M_genkey,M_add) values('W_"&nickname&"','"&openid&"','@qq.com',0,'"& replace(headimgurl,"\","") &"','"&now()&"','"&openid&"','"&genkey&"','"&country&province&city&"')" conn.execute(sql) session("M_login")="W_"&nickname session("M_pwd")=openid set rs=server.createobject("ADODB.Recordset") sql="select top 1 * from SL_Member order by M_id desc" rs.open sql,conn,1,1 if not rs.eof then session("M_id")=rs("M_id") end if rs.close set rs=nothing call box("登陆成功！W_"&nickname&"",URLdecode(from),"success") end if rs.close set rs=nothing end if %>