<!--#include file="../inc/BLL.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../inc/UC_Config.asp"-->
<%
Dim tget, ttime, code, action
code = Request.QueryString("code")
code = uc_authcode(code,"DECODE",UC_KEY)

Set tget = parse_str(code)
If Len(code) < 5 Then
    Response.write "Invalid Request"
	Response.End()
End If
ttime = tget("time")
If Not IsNumeric(ttime) Or ttime = "" Then
    Response.write "Invalid Request"
	Response.End()
End If
ttime = DateAdd("s",ttime,"1970-01-01 08:00:00")
ttime = DateDiff("s",ttime,Now())
If CInt(ttime) > 60 Then '一分钟内有效，要求服务器上的时间相差不能超过1分钟
    Response.write "Authorization has expiried"
	Response.End()
End If
'验证部分，不用修改 结束
action = tget("action")
Dim ids, uid, oldusername, newusername, username, password, orgpassword, salt,t_UserName
Select Case action
    Case "test"
        Response.write 1
    Case "synlogin"  '登录
		Response.Addheader "P3P","CP=""CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"""
	    '以下可修改本应用的登录处理方式代码，获取到
		t_UserName = tget("username")
		RS_End
		RS.OPEN "select top 1 * from [i_User_Info] a join [i_Sys_Room] b on a.[i_User_ID]=b.[i_Sys_Room_AdminUserID] where a.[i_User_Name]='"&t_UserName&"'" , DB_CONN , 1 , 3
		if RS.recordcount>0 then
			if RS("i_User_IsLock")=0 then 
				'登录成功
				RS("i_User_Online")=1
				RS("i_User_LastLoginTime")=now()
				RS("i_User_LoginIP")=get_IP()
				RS.Update()
				Session(Session_UserID_Arg)=RS("i_User_ID")
				Session(Session_UserName_Arg)=RS("i_User_Name")
				Session(Session_UserNickName_Arg)=RS("i_User_NickName")
				Session(Session_UserSex_Arg)=RS("i_User_Sex")
				Session(Session_UserClass_Arg)=RS("i_User_Class")
				Session(Session_UserFace_Arg)=RS("i_User_Face")
				Session(Session_RoomID_Arg)=RS("i_Sys_Room_ID")
				Session(Session_LogIP_Arg)=get_IP()
				Session(Session_LogTime_Arg)=now()
				t_PayNum = RS("i_User_PayNum")
				t_IncomeNum = RS("i_User_IncomeNum")
				Session(Session_UserPaymentLevel_Arg)=GetUserPaymentLevelInfo(t_PayNum,"i_User_PaymentLevel_Style")
				Session(Session_UserIncomeLevel_Arg)=GetUserInComeLevelInfo(t_IncomeNum,"i_User_InComeLevel_Style")
				
				if t_AutoLogin="1" then 
					Response.Cookies("ishow")("iAutoLogin")="true":Response.Cookies("ishow")("iUserName")=t_UserName:Response.Cookies("ishow")("iUserPass")=t_UserPass:Response.Cookies("ishow").Expires= (now()+365)
				else
					Response.Cookies("ishow")("iAutoLogin")="false"
				end if
			end if
		end if
		RS_End
        Response.write 1  '最后返回 成功
	Case "synlogout" '退出
		Response.Addheader "P3P","CP=""CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"""
	    '以下可修改本应用的退出处理方式代码
		session.Abandon()
		Response.Cookies("ishow")("iUserName")=""
		Response.Cookies("ishow")("iUserPass")=""
		Response.Cookies("ishow").Expires= (now()-1)
        Response.write 1  '最后返回 成功
End Select


Function parse_str(str)
    Dim objData, aryData, i, aryT
    Set objData = Server.CreateObject("Scripting.Dictionary")
    aryData = Split(str,"&")
    For i = 0 To UBound(aryData)
        aryT = Split(aryData(i), "=")
        If UBound(aryT) > 0 Then
            objData.add aryT(0), aryT(1)
        Else
            objData.add aryT(0), ""
        End If
    Next
    Set parse_str = objData
    Set objData = Nothing
End Function

%>