<!--#include file="conn.asp"-->
<!--#include file="chkadmin.asp"-->
<!--#include file="inc/char.asp"-->
<%dim id,utype,usr,pwd,pwd2,email,qq,icq,msn,homepage
dim power1,power2,power3,power4,power5,power6
id=Cint(Trim(Request.Form("id")))
utype=Trim(Request.Form("type"))
usr=Trim(Request.Form("usr"))
pwd=Trim(Request.Form("pwd"))
pwd2=Trim(Request.Form("pwd2"))
email=Trim(Request.Form("email"))
qq=Trim(Request.Form("qq"))
icq=Trim(Request.Form("icq"))
msn=Trim(Request.Form("msn"))
homepage=Trim(Request.Form("homepage"))
power1=Trim(Request.Form("power1"))
power2=Trim(Request.Form("power2"))
power3=Trim(Request.Form("power3"))
power4=Trim(Request.Form("power4"))
power5=Trim(Request.Form("power5"))
power6=Trim(Request.Form("power6"))

dim errmsg,founderr
founderr=false

if chkadmin=false or power(5)="0" then
	founderr=true
	errmsg=errmsg+"<li>您没有修改用户信息的权限</li>"
end if

if pwd="" or pwd2="" then
	founderr=true
	errmsg=errmsg+"<li>密码不能为空</li>"
elseif strlen(pwd)<4 or strlen(pwd)>20 then
	founderr=true
	errmsg=errmsg+"<li>密码长度应为4～20个字符</li>"
elseif pwd<>pwd2 then
	founderr=true
	errmsg=errmsg+"<li>两次输入的密码不一致</li>"
end if

if Email="" then
	founderr=true
	errmsg=errmsg+"<li>E-mail不能为空</li>"
elseif IsValidEmail(Email)=false then
	founderr=true
	errmsg=errmsg+"<li>E-mail地址格式不正确</li>"
end if

if qq<>"" and isInteger(qq)=false then
	founderr=true
	errmsg=errmsg+"<li>QQ号码必须是数字</li>"
end if

if icq<>"" and isInteger(icq)=false then
	founderr=true
	errmsg=errmsg+"<li>ICQ号码必须是数字</li>"
end if

if msn<>"" and IsValidEmail(msn)=false then
	founderr=true
	errmsg=errmsg+"<li>MSN格式不正确</li>"
end if

if power1="" then power1="0" end if
if power2="" then power2="0" end if
if power3="" then power3="0" end if
if power4="" then power4="0" end if
if power5="" then power5="0" end if
if power6="" then power6="0" end if
dim powers
powers=power1&","&power2&","&power3&","&power4&","&power5&","&power6

if founderr=false then
	conn.execute("update UserInfo set PWD='"&pwd&"',Email='"&email&"',QQ='"&qq&"',ICQ='"&icq&"',MSN='"&msn&"',Homepage='"&homepage&"',Power='"&powers&"' where ID="&id)
	dim gourl,msg
	gourl="user_list.asp?type="&utype&""
	msg="用户资料修改成功！"
	call ok()
else
	call error()
end if

conn.close
set conn=nothing
%>