
<!--#include file="../inc/Conn.asp"-->
<!--#include file="Inc/Admin.Asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="Inc/Function.asp"-->
<%

dim UserID,Action
dim rsUser,sqlUser
Action=trim(request("Action"))
UserID=trim(request("UserID"))
if UserID="" then
	FoundErr=True
	ErrMsg=ErrMsg & "<br><li>参数不足！</li>"
	call WriteErrMsg()
else
	Set rsUser=Server.CreateObject("Adodb.RecordSet")
	sqlUser="select * from [User] where UserID=" & Clng(UserID)
	rsUser.Open sqlUser,conn,1,3
	if rsUser.bof and rsUser.eof then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>找不到指定的用户！</li>"
	else
		if Action="Modify" then
			dim UserName,Password,Question,Answer,Sex,Email,Homepage,VIPUser,Comane,Add,Somane,Zip,Phone,Fox
			UserName=trim(request("UserName"))
			Password=trim(request("Password"))
			Question=trim(request("Question"))
			Answer=trim(request("Answer"))
			Sex=trim(Request("Sex"))
			Email=trim(request("Email"))
			Homepage=trim(request("Homepage"))
			CompanyName=trim(request("CompanyName"))
			Add=trim(request("Add"))
			Receiver=trim(request("Receiver"))
			Postcode=trim(request("Postcode"))
			Phone=trim(request("Phone"))
			Mobile=trim(request("Mobile"))
			Fax=trim(request("Fax"))
			LockUser=trim(request("LockUser"))
			VIPUser=trim(request("VIPUser"))
			if UserName="" or strLength(UserName)>14 or strLength(UserName)<4 then
				founderr=true
				errmsg=errmsg & "<br><li>请输入用户名(不能大于14小于4)</li>"
			else
  				if Instr(UserName,"=")>0 or Instr(UserName,"%")>0 or Instr(UserName,chr(32))>0 or Instr(UserName,"?")>0 or Instr(UserName,"&")>0 or Instr(UserName,";")>0 or Instr(UserName,",")>0 or Instr(UserName,"'")>0 or Instr(UserName,",")>0 or Instr(UserName,chr(34))>0 or Instr(UserName,chr(9))>0 or Instr(UserName,"")>0 or Instr(UserName,"$")>0 then
					errmsg=errmsg+"<br><li>用户名中含有非法字符</li>"
					founderr=true
				else
					dim sqlReg,rsReg
					sqlReg="select * from [User] where UserName='" & Username & "' and UserID<>" & UserID
					set rsReg=server.createobject("adodb.recordset")
					rsReg.open sqlReg,conn,1,1
					if not(rsReg.bof and rsReg.eof) then
						founderr=true
						errmsg=errmsg & "<br><li>用户名已经存在！请换一个用户名再试试！</li>"
					end if
					rsReg.Close
					set rsReg=nothing
				end if
			end if
			if Password<>"" then
				if strLength(Password)>12 or strLength(Password)<6 then
					founderr=true
					errmsg=errmsg & "<br><li>请输入密码(不能大于12小于6)。如不想修改，请留空！</li>"
				else
					if Instr(Password,"=")>0 or Instr(Password,"%")>0 or Instr(Password,chr(32))>0 or Instr(Password,"?")>0 or Instr(Password,"&")>0 or Instr(Password,";")>0 or Instr(Password,",")>0 or Instr(Password,"'")>0 or Instr(Password,",")>0 or Instr(Password,chr(34))>0 or Instr(Password,chr(9))>0 or Instr(Password,"")>0 or Instr(Password,"$")>0 then
						errmsg=errmsg+"<br><li>密码中含有非法字符</li>"
						founderr=true
					end if
				end if
			end if
			if Question="" then
				founderr=true
				errmsg=errmsg & "<br><li>密码提示问题不能为空</li>"
			end if
			if Sex="" then
				founderr=true
				errmsg=errmsg & "<br><li>性别不能为空</li>"
			else
				sex=cint(sex)
				if Sex<>0 and Sex<>1 then
					Sex=1
				end if
			end if
			if Email="" then
				founderr=true
				errmsg=errmsg & "<br><li>Email不能为空</li>"
			else
				if IsValidEmail(Email)=false then
					errmsg=errmsg & "<br><li>您的Email有错误</li>"
			   		founderr=true
				end if
			end if
			if LockUser="" then
				FoundErr=True
				ErrMsg=ErrMsg & "<br><li>用户状态不能为空！</li>"
			end if
			if FoundErr<>true then
				rsUser("UserName")=UserName
				if Password<>"" then
					rsUser("Password")=md5(Password)
				end if
				rsUser("Question")=Question
				if Answer<>"" then
					rsUser("Answer")=md5(Answer)
				end if
				rsUser("Sex")=Sex
				rsUser("Email")=Email
				rsUser("HomePage")=HomePage
				rsUser("CompanyName")=CompanyName
				rsUser("Add")=Add
				rsUser("Receiver")=Receiver
				rsUser("Postcode")=Postcode
				rsUser("Phone")=Phone
				rsUser("Mobile")=Mobile
				rsUser("Fax")=Fax
				rsUser("LockUser")=LockUser
				rsUser("VIPUser")=VIPUser
				rsUser.update
				rsUser.Close
				set rsUser=nothing
				call CloseConn() 
				response.redirect "UserManage.asp"
			end if
		end if
	end if
	if FoundErr=True then
		call WriteErrMsg()
	else
%>
<!-- #include file="Inc/Head.asp" -->
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td  align="center" valign="top"> 
      <FORM name="Form1" action="UserModify.asp" method="post">
        <table width="560" border="0" cellpadding="0" cellspacing="1" class="border" >
          <TR align=center bgcolor="#FFFFFF" class='title'> 
            <TD height=25 colSpan=2 class="topbg"><b>修改注册用户信息</b></TD>
          </TR>
          <TR bgcolor="#FFFFFF" > 
            <TD width="120" align="right" class="tdbg">用 户 名：</TD>
            <TD class="tdbg"><input name=UserName value="<%=rsUser("UserName")%>" size=30   maxlength=14 /></TD>
          </TR>
          <TR bgcolor="#FFFFFF" class="tdbg" > 
            <TD width="120" align="right" class="tdbg">密码(至少6位)：</TD>
            <TD class="tdbg"> <INPUT   type=password maxLength=16 size=30 name=Password> <font color="#FF0000">如果不想修改，请留空</font>            </TD>
          </TR>
          <TR bgcolor="#FFFFFF" class="tdbg" > 
            <TD width="120" align="right" class="tdbg">密码问题：</TD>
            <TD class="tdbg"> <INPUT name="Question"   type=text value="<%=rsUser("Question")%>" size=30>            </TD>
          </TR>
          <TR bgcolor="#FFFFFF" class="tdbg" > 
            <TD width="120" align="right" class="tdbg">问题答案：</TD>
            <TD class="tdbg"> <INPUT   type=text size=30 name="Answer"> <font color="#FF0000">如果不想修改，请留空</font></TD>
          </TR>
          <TR bgcolor="#FFFFFF" class="tdbg" > 
            <TD width="120" align="right" class="tdbg">性别：</TD>
            <TD class="tdbg"> <INPUT type=radio value="1" name=sex <%if rsUser("Sex")=1 then response.write "CHECKED"%>>
              男 &nbsp;&nbsp; <INPUT type=radio value="0" name=sex <%if rsUser("Sex")=0 then response.write "CHECKED"%>>
              女</TD>
          </TR>
          <TR bgcolor="#FFFFFF" class="tdbg" > 
            <TD width="120" align="right" class="tdbg">Email地址：</TD>
            <TD class="tdbg"> <INPUT name=Email value="<%=rsUser("Email")%>" size=30   maxLength=50>            </TD>
          </TR>
          <TR bgcolor="#FFFFFF" class="tdbg" > 
            <TD width="120" align="right" class="tdbg">主页：</TD>
            <TD class="tdbg"> <INPUT   maxLength=100 size=30 name=HomePage value="<%=rsUser("HomePage")%>"></TD>
          </TR>
          <TR bgcolor="#FFFFFF" class="tdbg" > 
            <TD width="120" align="right" class="tdbg">公司名称：</TD>
            <TD class="tdbg"> <INPUT name=CompanyName value="<%=rsUser("CompanyName")%>" size=30 maxLength=20></TD>
          </TR>
          <TR bgcolor="#FFFFFF" class="tdbg" > 
            <TD width="120" align="right" class="tdbg">收货地址：</TD>
            <TD class="tdbg"> <INPUT name=Add value="<%=rsUser("Add")%>" size=30 maxLength=50></TD>
          </TR>
          <TR bgcolor="#FFFFFF" class="tdbg" > 
            <TD align="right" class="tdbg">收货人：</TD>
            <TD class="tdbg"> <INPUT name=Receiver value="<%=rsUser("Receiver")%>" size=30 maxLength=50></TD>
          </TR>
          <TR bgcolor="#FFFFFF" class="tdbg" > 
            <TD align="right" class="tdbg">邮政编码：</TD>
            <TD class="tdbg"> <INPUT name=Postcode value="<%=rsUser("Postcode")%>" size=30 maxLength=50></TD>
          </TR>
          <TR bgcolor="#FFFFFF" class="tdbg" > 
            <TD align="right" class="tdbg">联系电话：<br></TD>
            <TD class="tdbg"> <INPUT name=Phone value="<%=rsUser("Phone")%>" size=30 maxLength=50></TD>
          </TR>
          <TR bgcolor="#FFFFFF" class="tdbg" >
            <TD align="right" class="tdbg">手机：</TD>
            <TD class="tdbg"><INPUT name=Mobile value="<%=rsUser("Mobile")%>" size=30 maxLength=50></TD>
          </TR>
          <TR bgcolor="#FFFFFF" class="tdbg" > 
            <TD align="right" class="tdbg">传 真：</TD>
            <TD class="tdbg"> <INPUT name=Fax value="<%=rsUser("Fax")%>" size=30 maxLength=50></TD>
          </TR>
          <TR bgcolor="#FFFFFF" class="tdbg" > 
            <TD width="120" align="right" class="tdbg">用户状态：</TD>
            <TD class="tdbg"> <input type="radio" name="LockUser" value="False" <%if rsUser("LockUser")=False then response.write "checked"%>>
              正常&nbsp;&nbsp; <input type="radio" name="LockUser" value="True" <%if rsUser("LockUser")=True then response.write "checked"%>>
              锁定</TD>
          </TR>
          <TR bgcolor="#FFFFFF" class="tdbg" >
            <TD width="120" align="right" class="tdbg">是否为<font color="#FF0000">VIP</font>：</TD>
            <TD class="tdbg"><input type="radio" name="VIPUser" value="True" <%if rsUser("VIPUser")=True then response.write "checked"%> /> 
              是 
&nbsp;&nbsp;
<input type="radio" name="VIPUser" value="False" <%if rsUser("VIPUser")=False then response.write "checked"%> />
否 </TD>
          </TR>
          <TR align="center" bgcolor="#FFFFFF" class="tdbg" > 
            <TD height="40" colspan="2" class="tdbg"> <input name="Action" type="hidden" id="Action" value="Modify"> 
              <input name=Submit   type=submit id="Submit" value="保存修改结果"> <input name="UserID" type="hidden" id="UserID" value="<%=rsUser("UserID")%>"></TD>
          </TR>
        </TABLE>
      </form></td>
  </tr>
</table>
<!-- #include file="Inc/Foot.asp" -->
<%
	end if
	rsUser.close
	set rsUser=nothing
end if
call CloseConn()
%>