<!--#include file="include/conn.asp"-->
<%
Dim useripp
useripp = Request.ServerVariables("REMOTE_ADDR")
Dim zRs,zConn,zSql
Select Case a
	Case "clear"		'清空所有session
		Session.Abandon
		w.r "/"
		w.e
	Case "lut"		'退出会员登录
		session("userid")=""
		w.r "/"
		w.e
	Case "usercode"		'手机验证码
		If o.t("usertel")="" Then w.w "codeerrtel":w.e
		Set oRs=server.createobject("adodb.recordset")
		sSql="Select * from [LstUser] where UserTel='"&o.t("usertel")&"'"
		oRs.open sSql,oconn,1,3
		If not oRs.eof Then w.w "codecftel":w.e
		If sSms("APPSTATE")=1 Then
			Call SendSMSsmscn(""&o.t("usertel")&"","验证码:["&session("firstecode")&"] 5分钟内有效，请您不要泄漏.")
		Else 
			w.w "codeoff":w.e
		End If
		w.w "codeok":w.e
	Case "login"		'会员登录
		If o.t("usertel")="" Then w.w "errusertel":w.e
		If o.t("Userpass")="" Then w.w "errUserpass":w.e
		If o.t("llummm")<>Session("firstecode") Then  w.w "errcode":w.e
		Set oRs=server.createobject("adodb.recordset")
		sSql="select top 1 * from [LstUser] where UserTel='"&o.t("usertel")&"' "
		oRs.open sSql,oconn,1,1
		If not oRs.eof then
			If oRs("UserPass") <> MD5(o.t("Userpass"),32) then
				w.w "errpassno"
				w.e
			Else
				session("userid")=oRs("Id")
				session("username")=oRs("UserName")
				w.w "ok"
				w.e
			End If
		Else
			w.w "errno"
			w.e
		End If
	Case "reg"		'会员注册
	''''''''''''''''''''''''''''''''''''''''''''''''
		If o.t("usertel")="" Then w.w "errusertel":w.e
		If o.t("llummm")="" Then w.w "errllummm":w.e
		If o.t("llummm")<>Session("firstecode") Then  w.w "errcode":w.e
		If o.t("Userpass")="" Then w.w "errUserpass":w.e
		If o.t("Userpass")<>o.t("Userpassok") Then w.w "errUserpassok":w.e
		If o.t("UserName")="" Then w.w "errUserName":w.e
		If o.t("UserQQ")="" Then w.w "errUserQQ":w.e
		Set oRs=server.createobject("adodb.recordset")
		sSql="Select * from [LstUser] where usertel='"&o.t("usertel")&"' "
		oRs.open sSql,oconn,1,3
		If not oRs.eof then
			w.w "cfusertel"
			w.e
		Else 
			Dim oRsu
			Set oRsu=server.createobject("adodb.recordset")
			sSql="Select * from [LstUser]"
			oRsu.open sSql,oconn,1,3
				oRsu.addnew
				oRsu("usertel")=o.t("usertel")
				oRsu("Userpass")=md5(o.t("Userpass"),32)
				'oRsu("UserCom")=o.t("UserCom")
				oRsu("UserName")=o.t("UserName")
				oRsu("UserAddress")=o.t("UserAddress")
				oRsu("UserQQ")=o.t("UserQQ")
				oRsu("UserQQ")=o.t("UserQQ")
				oRsu("UserAddtime")=now()
				oRsu.update
				session("userid")=oRsu("Id")
				session("username")=oRsu("UserName")
				oRsu.close
			Set oRsu = Nothing			
			w.w "ok"
			w.e
		End If
		Set oRs = Nothing
	Case "edit"		'基本资料编辑
	''''''''''''''''''''''''''''''''''''''''''''''''
		If o.t("usertel")="" Then w.w "errusertel":w.e
		If o.t("llummm")="" Then w.w "errllummm":w.e
		If o.t("llummm")<>Session("firstecode") Then  w.w "errcode":w.e
		If o.t("UserCom")="" Then w.w "errUserCom":w.e
		If o.t("UserName")="" Then w.w "errUserName":w.e
		If o.t("UserAddress")="" Then w.w "errUserAddress":w.e
		If o.t("UserQQ")="" Then w.w "errUserQQ":w.e
			Set oRsu=server.createobject("adodb.recordset")
			sSql="Select * from [LstUser] where Id="&session("userid")
			oRsu.open sSql,oconn,1,3
				oRsu("usertel")=o.t("usertel")
				oRsu("UserCom")=o.t("UserCom")
				oRsu("UserName")=o.t("UserName")
				oRsu("UserEmail")=o.t("UserEmail")
				oRsu("UserAddress")=o.t("UserAddress")
				oRsu("UserEmail")=o.t("UserEmail")
				oRsu("UsrIP")=MYIP
				oRsu.update
				oRsu.close
			Set oRsu = Nothing			
			w.w "ok"
			w.e
		Set oRs = Nothing
	Case "editpass"		'密码修改
	''''''''''''''''''''''''''''''''''''''''''''''''
		If o.t("oldpass")="" Then w.w "erroldpass":w.e
		If o.t("newpass")="" Then w.w "errnewpass":w.e
		If o.t("newpass")<>o.t("newpassok") Then w.w "errnewpassok":w.e
		If o.t("llummm")<>Session("firstecode") Then  w.w "errcode":w.e
		Set oRs=server.createobject("adodb.recordset")
		sSql="Select * from [LstUser] where id="&session("userid")
		oRs.open sSql,oconn,1,3
		If oRs("Userpass") <> md5(o.t("oldpass"),32) Then
			w.w "errpass":w.e
		Else
			oConn.execute("update [lstuser] set Userpass = '"&md5(o.t("newpass"),32)&"' where Id="&session("userid"))
			w.w "ok"
			w.e
		End If
		Set oRs = Nothing
	Case "suborder"		'提交订单
	''''''''''''''''''''''''''''''''''''''''''''''''
		If session("userid")="" Then w.w "nologin":w.e
		If o.t("OrderMoney")="" Then w.w "errOrderMoney":w.e
		If o.t("OrderKtime")="" Then  w.w "errOrderKtime":w.e
		If dateDiff("d",now(),o.t("OrderKtime"))<0 Then w.w "errKTime":w.e
		If o.t("OrderJtime")="" Then w.w "errOrderJtime":w.e
		If dateDiff("d",o.t("OrderJtime"),o.t("OrderKtime"))>0 Then w.w "errTime":w.e
		If o.t("OrderRen")="" Then w.w "errOrderRen":w.e
		If o.t("OrderTel")="" Then w.w "errOrderTel":w.e
		If o.t("OrderName")="" Then w.w "errOrderName":w.e
		If o.t("OrderAddress")="" Then w.w "errOrderAddress":w.e
		If o.t("OrderQQ")="" Then w.w "errOrderQQ":w.e
		oConn.Execute("INSERT INTO [LstOrder] (OrderNo,RoadId,OrderMoney,OrderKtime,OrderJtime,OrderRen,OrderZmoney,OrderTel,OrderName,OrderAddress,OrderQQ,OUserId,OAddtime) VALUES ('"&OrderNumber&"',"&o.t("OrderId")&",'"&o.t("OrderMoney")&"','"&o.t("OrderKtime")&"','"&o.t("OrderJtime")&"',"&o.t("OrderRen")&",'"&o.t("OrderZmoney")&"','"&o.t("OrderTel")&"','"&o.t("OrderName")&"','"&o.t("OrderAddress")&"','"&o.t("OrderQQ")&"',"&session("userid")&",now())")
		w.w "ok"
		w.e
	Case "subcarorder"		'提交订单
	''''''''''''''''''''''''''''''''''''''''''''''''
		If session("userid")="" Then w.w "nologin":w.e
		If o.t("OrderMoney")="" Then w.w "errOrderMoney":w.e
		If o.t("OrderKtime")="" Then  w.w "errOrderKtime":w.e
		If dateDiff("d",now(),o.t("OrderKtime"))<0 Then w.w "errKTime":w.e
		If o.t("OrderJtime")="" Then w.w "errOrderJtime":w.e
		If dateDiff("d",o.t("OrderJtime"),o.t("OrderKtime"))>0 Then w.w "errTime":w.e
		If o.t("OrderRen")="" Then w.w "errOrderRen":w.e
		If o.t("OrderTel")="" Then w.w "errOrderTel":w.e
		If o.t("OrderName")="" Then w.w "errOrderName":w.e
		If o.t("OrderAddress")="" Then w.w "errOrderAddress":w.e
		If o.t("OrderQQ")="" Then w.w "errOrderQQ":w.e
		oConn.Execute("INSERT INTO [LstOrder] (OrderNo,CarId,OrderMoney,OrderKtime,OrderJtime,OrderRen,OrderZmoney,OrderTel,OrderName,OrderAddress,OrderQQ,OUserId,OAddtime) VALUES ('"&OrderNumber&"',"&o.t("OrderId")&","&o.t("OrderMoney")&",'"&o.t("OrderKtime")&"','"&o.t("OrderJtime")&"',"&o.t("OrderRen")&","&o.t("OrderZmoney")&",'"&o.t("OrderTel")&"','"&o.t("OrderName")&"','"&o.t("OrderAddress")&"','"&o.t("OrderQQ")&"',"&session("userid")&",now())")
		w.w "ok"
		w.e
	Case "subjingorder"		'提交景点订单
	''''''''''''''''''''''''''''''''''''''''''''''''
		If session("userid")="" Then w.w "nologin":w.e
		If o.t("OrderMoney")="" Then w.w "errOrderMoney":w.e
		If o.t("OrderKtime")="" Then  w.w "errOrderKtime":w.e
		If dateDiff("d",now(),o.t("OrderKtime"))<0 Then w.w "errKTime":w.e
		If o.t("OrderJtime")="" Then w.w "errOrderJtime":w.e
		If dateDiff("d",o.t("OrderJtime"),o.t("OrderKtime"))>0 Then w.w "errTime":w.e
		If o.t("OrderRen")="" Then w.w "errOrderRen":w.e
		If o.t("OrderTel")="" Then w.w "errOrderTel":w.e
		If o.t("OrderName")="" Then w.w "errOrderName":w.e
		If o.t("OrderAddress")="" Then w.w "errOrderAddress":w.e
		If o.t("OrderQQ")="" Then w.w "errOrderQQ":w.e
		oConn.Execute("INSERT INTO [LstOrder] (OrderNo,JingId,OrderMoney,OrderKtime,OrderJtime,OrderRen,OrderZmoney,OrderTel,OrderName,OrderAddress,OrderQQ,OUserId,OAddtime) VALUES ('"&OrderNumber&"',"&o.t("OrderId")&","&o.t("OrderMoney")&",'"&o.t("OrderKtime")&"','"&o.t("OrderJtime")&"',"&o.t("OrderRen")&","&o.t("OrderZmoney")&",'"&o.t("OrderTel")&"','"&o.t("OrderName")&"','"&o.t("OrderAddress")&"','"&o.t("OrderQQ")&"',"&session("userid")&",now())")
		w.w "ok"
		w.e
	Case "subfangorder"		'提交房间订单
	''''''''''''''''''''''''''''''''''''''''''''''''
		If session("userid")="" Then w.w "nologin":w.e
		If o.t("OrderMoney")="" Then w.w "errOrderMoney":w.e
		If o.t("OrderKtime")="" Then  w.w "errOrderKtime":w.e
		If dateDiff("d",now(),o.t("OrderKtime"))<0 Then w.w "errKTime":w.e
		If o.t("OrderJtime")="" Then w.w "errOrderJtime":w.e
		If dateDiff("d",o.t("OrderJtime"),o.t("OrderKtime"))>0 Then w.w "errTime":w.e
		If o.t("OrderRen")="" Then w.w "errOrderRen":w.e
		If o.t("OrderTel")="" Then w.w "errOrderTel":w.e
		If o.t("OrderName")="" Then w.w "errOrderName":w.e
		If o.t("OrderAddress")="" Then w.w "errOrderAddress":w.e
		If o.t("OrderQQ")="" Then w.w "errOrderQQ":w.e
		oConn.Execute("INSERT INTO [LstOrder] (OrderNo,RoadId,FangId,OrderMoney,OrderKtime,OrderJtime,OrderRen,OrderZmoney,OrderTel,OrderName,OrderAddress,OrderQQ,OUserId,OAddtime) VALUES ('"&OrderNumber&"',"&o.t("OrderId")&","&o.t("OrderFangId")&","&o.t("OrderMoney")&",'"&o.t("OrderKtime")&"','"&o.t("OrderJtime")&"',"&o.t("OrderRen")&","&o.t("OrderZmoney")&",'"&o.t("OrderTel")&"','"&o.t("OrderName")&"','"&o.t("OrderAddress")&"','"&o.t("OrderQQ")&"',"&session("userid")&",now())")
		w.w "ok"
		w.e
	Case "subbook"		'留言板
	''''''''''''''''''''''''''''''''''''''''''''''''
		If o.t("sj")="" Then w.w "errsj":w.e
		If o.t("xm")="" Then  w.w "errxm":w.e
		If o.t("dz")="" Then w.w "errdz":w.e
		If o.t("qq")="" Then w.w "errqq":w.e
		If o.t("email")="" Then w.w "erremail":w.e
		If o.t("ly")="" Then w.w "errly":w.e
		oConn.Execute("INSERT INTO [LstBook] (sj,xm,dz,qq,email,ly,[time]) VALUES ('"&o.t("sj")&"','"&o.t("xm")&"','"&o.t("dz")&"','"&o.t("qq")&"','"&o.t("email")&"','"&o.t("ly")&"',now())")
		w.w "ok"
		w.e
	Case "fav"		'收藏夹
		If o.t("ProId")="" Then w.w "errid":w.e
		Set oRs=server.createobject("adodb.recordset")
		sSql="Select * from [LstFav] where UserId="&session("userid")&" and ProId="&ProId
		oRs.open sSql,oconn,1,3
		If not oRs.eof Then w.w "cfid":w.e
		oConn.Execute("INSERT INTO [LstFav] (UserId,ProId,Saddtime) VALUES ("&session("userid")&","&o.t("ProId")&",now())")
		w.w "ok":w.e
	Case "delfav"		'删除收藏夹
		Set zRs = Server.CreateObject("ADODB.Recordset")
		zSql = "Select * From LstFav Where UserId="&session("userid")&" and id="&id
		zRs.Open zSql,oConn,3,3
		If zRs.Eof And zRs.Bof Then
			w.w "nodel":w.e
		Else 
			oConn.Execute("delete from LstFav Where UserId="&session("userid")&" and id="&id)
		End If
		zRs.Update
			w.w "okdel"
		zRs.Close
		Set zRs = Nothing
	Case "delorderuser"		'取消订单
		If Id="" Then w.w "errcanshu":w.e
		If oConn.execute("Select top 1 OState from [LstOrder] where Id = "&Id)(0)>0 Then w.w "errno":w.e
		oconn.execute("update [LstOrder] set Omoney = 2,OState=2 where  Id = "&Id)
		w.w "ok":w.e
End Select
%>