<!-- #include file="include/con_user.asp" -->
<!-- #include file="include/jk_user.asp" -->
<%

dim default_w,default_h
max_w=dim_num(13)
max_h=dim_num(14)
default_w=90
default_h=90
tit="修改资料"

call web_head(2,0,0,0,0)
'----------------------------左边 开始----------------------------
call user_left("")
'----------------------------左边 结束----------------------------
call web_center(0)
'----------------------------中间 开始----------------------------
%>
<table cellspacing=1 cellpadding=4 class=table>
<tr><td class=td0 colspan=3>&nbsp;<%response.write img_skin("m_user")%>修改我（<%response.write login_username%>）的个人资料</td></tr>
<%
sql="select top 1 * from user_data where username='"&login_username&"'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if joekoe_cms.chk() then
  call user_edit_chk()
else
  call user_edit_main()
end if
rs.close
%>
</table>
<%
response.write ukong
'----------------------------中间 结束----------------------------
call web_end(0,0)

sub user_edit_chk()
  dim sex,birthday,face,face_w,face_h,qq,msn,phone,address,url,whe,remark,p45,popedom,p1,p2,found_err
  sex=trim(request.form("sex"))
  birthday=trim(request.form("b_year"))&"-"&trim(request.form("b_month"))&"-"&trim(request.form("b_day"))
  face=trim(request.form("face_pic"))
  if var_null(face)="" then
    face="images/face/0.gif"
  end if
  face_w=trim(request.form("face_w"))
  face_h=trim(request.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(max_w) or int(face_w)<10 then
    face_w=default_w
  end if
  if int(face_h)>int(max_h) or int(face_h)<10 then
    face_h=default_h
  end if
  qq=trim(request.form("qq"))
  msn=joekoe_cms.code_form(trim(request.form("msn")))
  phone=joekoe_cms.code_form(trim(request.form("phone")))
  address=joekoe_cms.code_form(trim(request.form("address")))
  url=joekoe_cms.code_form(trim(request.form("url")))
  whe=joekoe_cms.code_form(trim(request.form("whe")))
  remark=joekoe_cms.code_form(request.form("remark"))
  
  found_err=""
  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
    response.write vbcrlf&"<tr><td colspan=3 class=bg_td align=center height=200>" & _
		   found_error(found_err,280) & _
		   vbcrlf&"</td></tr>"
    exit sub
  end if
  'p45,popedom,p1,p2
  p45=1
  if trim(request.form("p45"))="yes" then p45=0
  popedom=rs("popedom")
  if len(popedom)<>50 then popedom="00000000000000000000000000000000000000000000000000"
  p1=left(popedom,44)
  p2=right(popedom,5)
  popedom=p1&p45&p2
  
  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("popedom")=popedom
  rs.update
  
  call web_js_msg(1,"您已成功修改了您的基本资料！","user_main.asp")
end sub

sub user_edit_main()
  dim seboy,segirl,uface,uid,nname,popedom,p45
  uface=rs("face")
  uid=rs("id")
  nname=rs("nname")
  popedom=rs("popedom")
  p45=joekoe_cms.popedom_p(popedom,45)
  if rs("sex")=false then
    segirl=" checked"
    seboy=""
  else
    seboy=" checked"
    segirl=""
  end if
%>
<script language=javascript>
function show_face()
{
  var nface=document.user_edit_frm.face.options[document.user_edit_frm.face.selectedIndex].value;
  document.images.face_img.src=nface;
  document.user_edit_frm.face_pic.value=nface;
}
function show_face2()
{
  document.images.face_img.src=document.user_edit_frm.face_pic.value;
}
</script>
<form name=user_edit_frm action='?' method=post onsubmit="javascript:frm_submitonce(this);">
<input type=hidden name=chk value='yes'>
<tr class=bg_tds><td colspan=3 height=30 align=center><font class=red><b>注意：</b></font>以下星号（<%response.write redx%>）标出的项目必需填写</td></tr>
<tr class=bg_td>
<td width='20%'>您的邮箱：</td>
<td width='45%'><font class=blue><%response.write rs("email")%></font></td>
<td width='35%' align=center rowspan=7><img border=0 src='<%response.write uface%>' name=face_img onload="javascript:if(this.width><%response.write max_w%>)this.width=<%response.write max_w%>;"></td>
</tr>
<tr class=bg_td>
<td>用户头衔：</td>
<td><%
  if nname="" then
    response.write "<font class=gray>无</font>"
  else
    response.write "<font class=red2>"&nname&"</font>"
  end if
%></td>
</tr>
<tr class=bg_td>
<td>您的性别：</td>
<td><input type=radio value=true name=sex<%response.write seboy%> class=bg_td>&nbsp;Boy　&nbsp;<input type=radio name=sex value=false<%response.write segirl%> class=bg_td>&nbsp;Girl<%response.write redx%></td>
</tr>
<tr class=bg_td>
<td>您的生日：</td>
<td><select name=b_year><%
  dim bires,birse
  bires=rs("birthday")
  if not(isdate(bires)) then
    bires=#1981/4/19#
  end if
  for i=1900 to year(now)
    birse=""
    if int(year(bires))=int(i) then
      birse=" selected"
    end if
    response.write vbcrlf&"<option value='"&i&"'"&birse&">"&i&"</option>"
  next
  response.write vbcrlf&"</select>年 <select name=b_month>"
  for i=1 to 12
    birse=""
    if int(month(bires))=int(i) then
      birse=" selected"
    end if
    response.write vbcrlf&"<option value='"&i&"'"&birse&">"&i&"</option>"
  next
  response.write vbcrlf&"</select>月 <select name=b_day>"
  for i=1 to 31
    birse=""
    if int(day(bires))=int(i) then
      birse=" selected"
    end if
    response.write vbcrlf&"<option value='"&i&"'"&birse&">"&i&"</option>"
  next
%></select>日<%response.write redx%></td>
</tr>
<tr class=bg_td>
<td>个性头像：</td>
<td><input type=text name=face_pic value='<%response.write uface%>' size=28 maxlength=200>&nbsp;<input type=button onclick="javascript:show_face2();" value='预览'><%response.write redx%></td>
</tr>
<tr class=bg_td><td class=gray>头像大小：</td><td>宽度：<input type=text name=face_w value='<%response.write rs("face_w")%>' size=5 maxlength=5>&nbsp;10-<%response.write max_w%>像素<%response.write redx%><br>高度：<input type=text name=face_h value='<%response.write rs("face_h")%>' size=5 maxlength=5>&nbsp;10-<%response.write max_h%>像素<%response.write redx%></td></tr>
<tr class=bg_td><td class=gray>选择头像：</td><td><select size=1 name=face style='width: 50;' onChange="javascript:show_face();"><%
  for i=0 to dim_num(5)
    response.write vbcrlf & "<option value='images/face/"&i&".gif'"
    if uface="images/face/"&i&".gif" then response.write " selected"
    response.write ">"&i&"</option>"
  next
%></select>&nbsp;&nbsp;<a href='user_face.asp' target=_blank>→查看所有头像</a></td></tr>
<tr class=bg_td><td class=gray>上传头像：</td><td colspan=2 class=bg><iframe frameborder=0 name=upload_frame width='99%' height=25 scrolling=no src='upload.asp?uppath=face&upname=face_<%response.write uid%>&uptext=face_pic'></iframe></td></tr>
<tr class=bg_td><td>来自哪里：</td><td colspan=2><input type=text name=whe value='<%response.write joekoe_cms.code_form(rs("whe"))%>' size=15 maxlength=20></td></tr>
<tr class=bg_td><td class=htd>个性签名：<br><%response.write web_frm_word%><br>长度<=250字节</td><td colspan=2><textarea name=remark cols=50 rows=7><%response.write joekoe_cms.code_html(rs("remark"),0,0)%></textarea></td></tr>
<tr class=bg_tds><td>开放联系信息：</td><td colspan=2><input type=checkbox name=p45 value='yes'<%if int(p45)=0 then response.write " checked"%> class=bg_tds>&nbsp;选择表示开放下面几项您的联系信息，在关闭时对于您的好友仍将为开放显示。</td></tr>
<tr class=bg_td><td>QQ：</td><td colspan=2><input type=text name=qq value='<%response.write rs("qq")%>' size=15 maxlength=15></td></tr>
<tr class=bg_td><td>MSN：</td><td colspan=2><input type=text name=msn value='<%response.write rs("msn")%>' size=30 maxlength=50></td></tr>
<tr class=bg_td><td>主页地址：</td><td colspan=2><input type=text name=url value='<%response.write joekoe_cms.code_form(rs("url"))%>' size=50 maxlength=100></td></tr>
<tr class=bg_td><td>联系电话：</td><td colspan=2><input type=text name=phone value='<%response.write rs("phone")%>' size=30 maxlength=20></td></tr>
<tr class=bg_td><td>联系地址：</td><td colspan=2><input type=text name=address value='<%response.write rs("address")%>' size=50 maxlength=100></td></tr>
<tr class=bg_tds><td></td><td height=50 colspan=2><input type=submit value=' 更 新 资 料 '>　　　<input type=reset value=' 重 新 修 改 '></td></tr>
</form>
<%
end sub
%>