<!-- #Include File="Con_User.asp" -->
<%
'=======================================================
' 欢迎使用《阿赛大型门户网站系统V3.0》，简称“AsaiMHV3”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================

dim default_w,default_h
default_w=Format_Mid_Num(20)
default_h=Format_Mid_Num(21)
tit="修改资料"
call DoWebHead(2,0)
'----------------------------左边 开始----------------------------
'----------------------------左边 结束----------------------------
'----------------------------中间 开始----------------------------
sql="select top 1 * from AsaiMHUserData where username='"&login_username&"'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if Cls.chk() then
  call user_edit_chk()
else
  call user_edit_main()
End If
rs.close
'----------------------------中间 结束----------------------------
call DoWebEnd()

sub user_edit_chk()
  dim email,nname,sex,birthday,face,face_w,face_h,qq,msn,phone,address,url,whe,remark,isopeninfo,found_err
  email=Cls.Code_Form("email")
  nname=Cls.Code_Form("nname")
  sex=Cls.Code_Form("sex")
  birthday=Cls.Code_Form("b_year")&"-"&Cls.Code_Form("b_month")&"-"&Cls.Code_Form("b_day")
  face=Cls.Code_Form("face_pic")
  if Cls.Is_Null(face)="" then
    face=""&Cls.Web_Dir&"Images/Face/0.gif"
  End If
  face_w=Cls.Code_Form("face_w")
  face_h=Cls.Code_Form("face_h")
  if not(isnumeric(face_w)) then
    face_w=default_w
  End If
  if not(isnumeric(face_h)) then
    face_h=default_h
  End If
  if int(face_w)>int(default_w) or int(face_w)<10 then
    face_w=default_w
  End If
  if int(face_h)>int(default_h) or int(face_h)<10 then
    face_h=default_h
  End If
  qq=Cls.Code_Form("qq")
  msn=Cls.Code_Form("msn")
  phone=Cls.Code_Form("phone")
  address=Cls.Code_Form("address")
  url=Cls.Code_Form("url")
  whe=Cls.Code_Form("whe")
  remark=Cls.Code_Form("remark")
  isopeninfo=false
  if Cls.Code_Form("isopeninfo")="yes" then isopeninfo=true
  Found_Err=""
  if int(UserGroup_Config(1))=1 then
    if Cls.Is_Email(email,50)=false then
      Found_Err=Found_Err&"+您输入的 电子邮件 为空或不符合规则！<br />"
    End If
  end if
  if not(isdate(birthday)) then
    Found_Err=Found_Err&"+您选择的 <font class=red>生日</font> 不是一个有效的日期格式！<br />"
  End If
  if qq<>"" and not isnull(qq) then
    if not(isnumeric(qq)) or len(qq)>15 then
      Found_Err=Found_Err&"+您输入的 <font class=red>QQ</font> 不是数字或长度超过15位！<br />"
    End If
  End If
  if len(remark)>250 then
    Found_Err=Found_Err&"+您输入的 <font class=red>个人介绍</font> 太多了！不能超过250个字符。<br />"
  End If
  If Found_Err<>"" Then
  Cls.HtmlRcod "body",Found_Error(Found_Err,460)
  Cls.OutPage
  exit sub
  End If
  
  if int(UserGroup_Config(1))=1 then
  rs("email")=email
  End If
  if int(UserGroup_Config(2))=1 then
  rs("nname")=nname
    End If
  rs("sex")=sex
  rs("birthday")=birthday
  rs("face")=face
  rs("face_w")=face_w
  rs("face_h")=face_h
  if qq<>"" and not isnull(qq) then
    rs("qq")=qq
  End If
  rs("msn")=msn
  rs("phone")=phone
  rs("address")=address
  rs("url")=url
  rs("whe")=whe
  rs("remark")=remark
  rs("isopen")=isopeninfo
  rs.update
  Call Cls.Out_Msg("您已成功修改了您的基本资料！","Index.asp")
End Sub

sub user_edit_main()
  dim seboy,segirl,uface,uid,user_nname,isopeninfo,user_email,n_isopeninfo
  uface=rs("face")
  uid=rs("id")
  isopeninfo=rs("isopen")
  if rs("sex")=false then
    segirl=" checked"
    seboy=""
  else
    seboy=" checked"
    segirl=""
  End If
if int(UserGroup_Config(1))=1 then
user_email="<input type=text class=txt name=email value='"&Cls.Code_Var(rs("email"))&"' size=28 maxlength=50>"
  else
 user_email="<font class=blue>"&Cls.code_html(rs("email"),1,0)&"</font>"
  End If
  if int(UserGroup_Config(2))=1 then
   user_nname="<input type=text class=txt name=nname value='"&Cls.Code_Var(rs("nname"))&"' size=28 maxlength=20>"
  else
    if rs("nname")="" then
       user_nname="<font class=Gys>无</font>"
    else
       user_nname="<font class=red2>"&Cls.code_html(rs("nname"),1,0)&"</font>"
    End If
  End If
  n_isopeninfo=vbcrlf&"<tr class=trs><td>开放联系信息：</td><td colspan=2><input type=checkbox name=isopeninfo value='yes'"
  if isopeninfo =true then n_isopeninfo=n_isopeninfo&vbcrlf&" checked"
  n_isopeninfo=n_isopeninfo&vbcrlf&" >&nbsp;选择表示开放下面几项您的联系信息，在关闭时对于您的好友仍将为开放显示。</td></tr>"
  Cls.HtmlRcod "body",Cls.ReadTemplate ("user_Edit")
  Cls.HtmlRcod "login_username",login_username
  Cls.HtmlRcod "email",user_email
  Cls.HtmlRcod "uface",cls.ReWord(uface)
  Cls.HtmlRcod "pface",uface
  Cls.HtmlRcod "pic_w",default_w
  Cls.HtmlRcod "nname",user_nname
  Cls.HtmlRcod "seboy",seboy
  Cls.HtmlRcod "segirl",segirl
  Cls.HtmlRcod "p45",n_isopeninfo
  Cls.HtmlRcod "tit",tit
  Cls.HtmlRcod "year",yearl()
  Cls.HtmlRcod "whe",Cls.Code_Var(rs("whe"))
  Cls.HtmlRcod "face",face(uface)
  Cls.HtmlRcod "face_pic",face_pic(uid,uface)
  Cls.HtmlRcod "word",Cls.ReadSkin("web_frm_word")
  Cls.HtmlRcod "remark",Cls.code_html(rs("remark"),0,0)
  Cls.HtmlRcod "qq",Cls.Code_Var(rs("qq"))
  Cls.HtmlRcod "msn",Cls.Code_Var(rs("msn"))
  Cls.HtmlRcod "url",Cls.Code_Var(rs("url"))
  Cls.HtmlRcod "phone",Cls.Code_Var(rs("phone"))
  Cls.HtmlRcod "address",Cls.Code_Var(rs("address"))
  Cls.OutPage
End Sub

Function yearl()
dim sTmp,bires,birse
sTmp="<select name=b_year>"
  bires=rs("birthday")
  if not(isdate(bires)) then
    bires=#1982/6/16#
  End If
  for i=1900 to year(now)
    birse=""
    if int(year(bires))=int(i) then
      birse=" selected"
    End If
    sTmp=sTmp&"<option value='"&i&"'"&birse&">"&i&"</option>"
  next
  sTmp=sTmp&"</select>年 <select name=b_month>"
  for i=1 to 12
    birse=""
    if int(month(bires))=int(i) then
      birse=" selected"
    End If
    sTmp=sTmp&"<option value='"&i&"'"&birse&">"&i&"</option>"
  next
  sTmp=sTmp&"</select>月 <select name=b_day>"
  for i=1 to 31
    birse=""
    if int(day(bires))=int(i) then
      birse=" selected"
    End If
    sTmp=sTmp&"<option value='"&i&"'"&birse&">"&i&"</option>"
  next
sTmp=sTmp&"</select>"
yearl=sTmp
End Function

Function face(uface)
dim sTmp
sTmp="<select size=1 name=face style='width: 50;' onChange=""javascript:show_face();"">"
  for i=0 to Format_Mid_Num(19)
    sTmp=sTmp&"<option value='"&Cls.Web_Dir&"Images/Face/"&i&".gif'"
    if uface=""&Cls.Web_Dir&"Images/Face/"&i&".gif" then sTmp=sTmp&" selected"
    sTmp=sTmp&">"&i&"</option>"
  next
sTmp=sTmp&"</select>"
face=sTmp
End Function

Function face_pic(uid,uface)
dim sTmp
if int(UserGroup_Config(7))=1 then
sTmp="<tr class=tr><td class=Gys>上传头像：</td><td colspan=2 class=bg><iframe frameborder=0 name=upload_frame width='99%' height=25 scrolling=no src='"&Cls.Web_Dir&"Include/Upload.asp?ID="&ChannelIDs&"&Type=0&Obj=face_pic'></iframe></td></tr>" & _
vbcrlf&"<tr class=tr><td class=Gys>头像大小：</td><td colspan=2>宽度：<input type=text name=face_w value='"&rs("face_w")&"' size=5 maxlength=5>&nbsp;10-"&default_w&"像素"&redx&"<br />高度：<input type=text name=face_h value='"&rs("face_h")&"' size=5 maxlength=5>&nbsp;10-"&default_h&"像素"&redx&"</td></tr>"
End If
face_pic=sTmp
End Function
%>
