<!--#INCLUDE FILE="conn.asp" -->
<!--#INCLUDE FILE="Class_Checkuser.asp" -->
<!--#INCLUDE FILE="Class_Top.asp" -->
<!--#INCLUDE FILE="inc/char.asp" -->
<%
Dim Locate,Act
locat="个人资料修改"
Dim ErrMsg

if membername="" Then
  	ErrMsg=ErrMsg+"<br>"+"<li>您还没有<a href=Class_Login.asp><font color=red>登录或注册校友录</font></a>。"
	Call top(1,1)
	Call Error("Information",ErrMsg)
	
	call footer()
Else
	Select Case Request("action")
	Case "update"
		Dim userpwd,question,answer
		Dim homepage,birthday
		%>
		<!--#INCLUDE FILE="inc/chkmodinfo.asp"-->
		<%
		Call update()
		Call footer()
	Case "MakeWish"
		act="修改生日愿望"
		Call pagehead()
		Call modiform()
	Case "Modiwish"
		act="修改生日愿望"
		Call pagehead()
		Call modiwish()
	Case Else
		Call top(1,1)
		Call userinfo()
		Call footer()
	End Select
End if


Sub userinfo()

Dim Rs
Dim hp

Set Rs=Conn.Execute("Select * from student where userid='"&membername&"'")

hp=Rs("homepage")
if Rs("homepage")="" or isnull(Rs("homepage")) Then hp="http://"

%>
<script language=javascript>
function ShowPreview()
{
var selobj=document.userform.face;
var imgobj=document.images['face'];

if(selobj.selectedIndex==0)
	{parent.document.userform.userface.value='';
	imgobj.style.visibility="hidden";
	 }
else
	{imgobj.style.visibility="visible";
	imgobj.src="face\/image"+selobj.options[selobj.selectedIndex].value+".gif";
	parent.document.userform.userface.value='face/image'+selobj.options[selobj.selectedIndex].value+'.gif';}
	
}
</SCRIPT>
<BR>
<FORM action="Class_Modify.asp" method=post name="userform" onSubmit="return submitonce(this);">
<input type=hidden name=action value=update>
<table cellpadding=0 cellspacing=0 border=0 width="100%" Class=TableBorder align=center>
        <tr>
            <td>
                <table cellpadding=4 cellspacing=1 border=0 width=100% Class=TableBorder>
  <TBODY>
  <TR align=middle >
    <Th colSpan=2 height=24>修改 <%=htmlencode(membername)%> 的个人资料</Th></TR>
     <TR>
    <TD colSpan=2 height=24 Class=DarkTableBody>&nbsp;<IMG SRC="images/2.gif" WIDTH="60" HEIGHT="9" BORDER=0 ALT="">::: 个人帐号信息 :::</TD></TR>  
  <TR Class=LightTableBody>
    <TD width=150> &nbsp;密&nbsp;&nbsp;&nbsp;&nbsp;码 **</TD>
    <TD><INPUT type="password" maxLength="12" size="27" name="userpwd"> 如不修改，请留空！</TD></TR>
  <TR Class=LightTableBody>
    <TD width=150> &nbsp;密码确认 **</TD>
    <TD><INPUT type="password" maxLength="12" size="27" name="userpwd1"> 如不修改，请留空！
    </TD></TR>
  <TR Class=LightTableBody>
    <TD width=150 height=32> &nbsp;密码提示</TD>
    <TD height=32><INPUT maxLength=50 size=27 name=question value="<%=Rs("question")%>" <%if sysadmin then response.write "disabled title=系统管理员不能使用此项功能"%>> 
      </TD></TR>
<TR Class=LightTableBody>
    <TD width=150 height=32> &nbsp;问题答案</TD>
    <TD height=32><INPUT maxLength=50 size=27 name=answer value="<%=Rs("answer")%>" <%if sysadmin then response.write "disabled title=系统管理员不能使用此项功能"%>><INPUT type=hidden name=oldanswer value="<%=Rs("answer")%>" > &nbsp;取回密码答案采用了MD5加密，如要修改可直接填写。
      </TD></TR>
  <TR>
    <TD colSpan=2 height=24 Class=DarkTableBody>&nbsp;<IMG SRC="images/2.gif" WIDTH="60" HEIGHT="9" BORDER=0 ALT="">::: 个人基本信息 :::</TD></TR>
  <TR Class=LightTableBody>
    <TD width=150> &nbsp;真实姓名 **</TD>
    <TD><INPUT type=text maxLength=4 size=27 name=realname value="<%=Rs("realname")%>"> 
    </TD></TR>
	<TR Class=LightTableBody>
    <TD width=150> &nbsp;性&nbsp;&nbsp;&nbsp;&nbsp;别</TD>
    <TD>			<input type="radio" name="sex" value=0 <% if Rs("sex")=0 Then Response.write "checked" %> >
			男孩 
			<input type="radio" name="sex" value=1 <% if Rs("sex")=1 Then Response.write "checked" %> >
			女孩
</TD></TR>
  <TR Class=LightTableBody>
    <TD width=150> &nbsp;生&nbsp;&nbsp;&nbsp;&nbsp;日 **</TD>
    <td nowrap height="26"><input maxLength="4" name="year" size="4"  value=<%=year(Rs("birthday"))%>>&nbsp;年&nbsp;<input maxLength="2" name="month" size="2"  value=<%=month(Rs("birthday"))%>>&nbsp;月&nbsp;<input maxLength="2" name="day" size="2"  value=<%=day(Rs("birthday"))%>>&nbsp;日
    </TD></TR>

  <TR Class=LightTableBody>
    <TD width=150 height=32> &nbsp;形&nbsp;&nbsp;&nbsp;&nbsp;象&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%
	  response.write "<img id=face "
	  if rs("imageid")<>"" then
	  response.write "src="&rs("imageid")&""
	  else
	  response.write "style=""visibility:hidden"""
	  end if
	  response.write " alt=个人形象代表 width=64 height=64 align=absmiddle>"%></TD>
    <TD height=32>
	
<Select name=face size=1 onChange="ShowPreview();">
<option value=0>不使用</option>
<%for i=1 to 440
	response.write "<option value="&i
	response.write ">Face"&i&"</option>"
next%>

      </Select>&nbsp;[<a href="javascript:openScript('Class_Help.asp?About=portrait',500,500)">头像列表</a>]
	  <%if BoolVar(10) then%>
	  <br> <iframe src=Class_Uploadface.asp width=315 frameborder=0 height=23 scrolling=no></iframe>
	  <%end if%>
	  <br><input name=userface type="text"  size="50" value="<%=rs("imageid")%>">&nbsp;&nbsp;只可以使用本站头像或上传</td>
  </TR>
  <TR>
    <TD colSpan=2 height=24 Class=DarkTableBody>&nbsp;<IMG SRC="images/2.gif" WIDTH="60" HEIGHT="9" BORDER=0 ALT="">::: 个人联系信息 :::</TD></TR>
  <TR Class=LightTableBody>
    <TD width=150 height=32> &nbsp;电子邮件 **</TD>
    <TD height=32><INPUT maxLength=50 size=27 name=email value="<%=htmlencode(Rs("email"))%>">&nbsp;<input type="checkbox" name="isemailshow" value="0" <%if Rs("isemailshow")=0 Then Response.write "checked"%>>保密
      </TD></TR>
  <TR Class=LightTableBody>
    <TD width=150> &nbsp;QQ号码</TD>
    <TD><INPUT maxLength=20 size=27 name=oicq value="<%=Rs("oicq")%>">&nbsp;<input type="checkbox" name="isoicqshow" value="0" <%if Rs("isoicqshow")=0 Then Response.write "checked"%>>保密</TD></TR>
  <TR Class=LightTableBody>
    <TD width=150> &nbsp;MSN</TD>
    <TD><input type="text" name="msn" size="27"  value="<%=Rs("msn")%>">&nbsp;<input type="checkbox" name="ismsnshow" value="0" <%if Rs("ismsnshow")=0 Then Response.write "checked"%>>保密</TD></TR>
  <TR Class=LightTableBody>
    <TD width=150> &nbsp;主页地址</TD>
    <TD><input name="homepage" size="55" value="<%=hp%>">&nbsp;<input type="checkbox" name="ishomepageshow" value="0" <%if Rs("ishomepageshow")=0 Then Response.write "checked"%>>保密</td>
    </TR>
	<TR Class=LightTableBody>
    <TD width=150> &nbsp;联系电话</TD>
    <TD><INPUT maxLength=20 size=27 name=telephone value="<%=Rs("telephone")%>"> 只能用数字和"-"</TD></TR>
	<TR Class=LightTableBody>
    <TD width=150> &nbsp;移动电话</TD>
    <TD><INPUT maxLength=11 size=27 name=mobilephone value="<%=Rs("mobilephone")%>"> </TD></TR>
	<TR Class=LightTableBody>
    <TD width=150> &nbsp;所在班级</TD>
    <TD><INPUT maxLength=20 size=55 name=class value="<%=Rs("class")%>"> </TD></TR>

	<TR Class=LightTableBody>
    <TD width=150> &nbsp;工作单位</TD>
    <TD><INPUT maxLength=20 size=55 name=workshop value="<%=Rs("workshop")%>"> </TD></TR>

	<TR Class=LightTableBody>
    <TD width=150> &nbsp;邮政编码</TD>
    <TD><INPUT maxLength=6 size=27 name=zipcode value="<%=Rs("zipcode")%>"> </TD></TR>
	<TR Class=LightTableBody>
    <TD width=150> &nbsp;通信地址</TD>
    <TD><INPUT maxLength=20 size=55 name=address value="<%=Rs("address")%>"> </TD></TR>
  <TR>
    <TD colSpan=2 height=24 Class=DarkTableBody>&nbsp;<IMG SRC="images/2.gif" WIDTH="60" HEIGHT="9" BORDER=0 ALT="">::: 其它个人选项 :::</TD></TR>  

  <TR Class=LightTableBody>
    <TD width=150> &nbsp;个性签名<BR><BR>不能超过8行，<br>支持<a href="javascript:openScript('Class_Help.asp?about=ubb',670,500)"  style="cursor:help;color:brown"> UBB </a>标签，<br>
不能多于320个字符。 </TD>
    <TD><TEXTAREA name=maxim rows=5 wrap=PHYSICAL cols=55 value=""><%=Rs("maxim")%></TEXTAREA> 
    </TD></TR>
	<TR Class=LightTableBody>
    <TD width=150> &nbsp;邮件通知</TD>
    <TD><%
	response.write "<input type=checkbox name=NewMemberFlag value=1"
	if Rs("NewMemberFlag")=1 Then response.write " checked"
	if IntVar(5)="0" then Response.write " disabled"
	response.write ">"
	if IntVar(5)="0" then 
		response.write "<a disabled>新同学加入提醒</a>"
	else
		response.write "新同学加入提醒"
	end if
	response.write "&nbsp;&nbsp;<input type=checkbox name=NewAnnounceFlag value=1"
	if Rs("NewAnnounceFlag")=1 Then Response.write " checked"
	if IntVar(5)="0" then Response.write " disabled"
	response.write ">"
	if IntVar(5)="0" then 
		response.write "<a disabled>新学校帖子提醒</a>"
	else
		response.write "新学校帖子提醒"
	end if
	response.write "&nbsp;&nbsp;<input type=checkbox name=NewFotoFlag value=1"
	if Rs("NewFotoFlag")=1 Then Response.write " checked"
	if IntVar(5)="0" then Response.write " disabled"
	response.write ">"
	if IntVar(5)="0" then 
		response.write "<a disabled>新学校相片提醒</a>"
	else
		response.write "新学校相片提醒"
	end if

	%>

</TD></TR>

  <TR align=middle Class=DarkTableBody>
    <TD colSpan=2><DIV align=center><INPUT value="更新资料(U)" name=Submit type=submit accesskey="u" class=button>&nbsp;&nbsp;&nbsp;&nbsp; <INPUT type=reset value="重写(R)" name=Submit2 accesskey="r" class=button> 
</DIV></TD></TR>


</TBODY></TABLE></td></tr></table>
</FORM>
<%
End Sub



Sub update()
	
	Dim Rs,sql
	Dim ErrMsg
	if chkinput=False Then	
		Exit Sub
	End if

	Set Rs = Server.CreateObject("ADODB.Recordset")

	sql = "Select * from student where userid='"&membername&"'"
	Rs.open sql,Conn,1,3

	if Rs.eof and Rs.bof Then
		ErrMsg=ErrMsg+"<br>"+"<li>该用户名不存在！"
		Call top(1,1)
		Call Error("Exclamation",ErrMsg)
		Exit Sub
	End if
	if trim(request.form("userface"))<>"" then
	if left(trim(request.form("userface")),22)<>"UploadFiles/UserFaces/" and left(trim(request.form("userface")),5)<>"face/" then
	ErrMsg=ErrMsg+"<br>"+"<li>本站头像不允许使用外部连接！"
		Call top(1,1)
		Call Error("Exclamation",ErrMsg)
		Exit Sub
	end if
	end if

	Rs("birthday")=birthday
	if userpwd<>"" Then Rs("userpwd")=userpwd
	if not sysadmin then 
		Rs("question")=question
		Rs("answer")=answer
	end if
	Rs("homepage")=homepage
	if request("ishomepageshow")<>"0" Then
	Rs("ishomepageshow")=1
	else
	Rs("ishomepageshow")=0
	end if
	Rs("realname")=trim(request.Form("realname"))
	Rs("imageid")=trim(request.form("userface"))
	Rs("email")=trim(request.Form("email"))
	if request("isemailshow")<>"0" Then
	Rs("isemailshow")=1
	else
	Rs("isemailshow")=0
	end if
	Rs("oicq")=trim(request.Form("oicq"))
	if request("isoicqshow")<>"0" Then
	Rs("isoicqshow")=1
	else
	Rs("isoicqshow")=0
	end if
	Rs("msn")=trim(request.Form("msn"))
	if request("ismsnshow")<>"0" Then
	Rs("ismsnshow")=1
	else
	Rs("ismsnshow")=0
	end if
	Rs("telephone")=trim(request.Form("telephone"))
	Rs("mobilephone")=trim(request.form("mobilephone"))
	Rs("workshop")=trim(Request.form("workshop"))
	Rs("class")=Trim(Request.Form("class"))
	Rs("zipcode")=trim(request.Form("zipcode"))
	Rs("maxim")=request.Form("maxim")
	Rs("address")=trim(request.Form("address"))
	
	if IntVar(5)<>"0" then
	Rs("NewMemberFlag")=cint(request("NewMemberFlag"))
	Rs("NewAnnounceFlag")=cint(request("NewAnnounceFlag"))
	Rs("NewFotoFlag")=cint(request("NewFotoFlag"))
	end if
	Rs("sex")=cint(Request.form("sex"))
	Rs("point")=Rs("point")+PointSet(14)
	Rs.Update

	Rs.close
	Set Rs=Nothing
	if userpwd<>"" Then Response.cookies("fenglingtxl_520")("password")=userpwd
	Call top(1,1)
	success "修改资料","您已经成功的修改了您的个人信息和个人选项。<a href=Class_Modify.asp><font color=red>返回查看</font></a>"

End Sub


Sub modiform()

	Dim BirRs
	Set BirRs=Conn.Execute("Select birthday,wish from student where userid='"&membername&"'")
	%>
	<table width=100% height=100% bgcolor=<%=BodyColor%>><tr><td valign=top>
	<FORM action="Class_Modify.asp" method=post name="wishform">
	<input type=hidden name=action value=Modiwish>
	<TABLE border=0 Class=TableBorder cellspacing=1 cellpadding=5>
	<TR>
		<TD colspan=2><IMG SRC="images/wish.gif" WIDTH="27" HEIGHT="30" BORDER=0 Align=absmiddle>我的生日愿望</TD>
	</TR>
	  <TR Class=DarkTableBody>
		<TD align=left colspan=2>嗨！你可以修改你的生日和生日愿望，让大家知道你的Birthday Wish,让大家一起来分享你的快乐！</TD>
	</TR>
	  <TR Class=LightTableBody>
		<TD align=center>生日：</td><td><input maxLength="4" name="year" size="4" value=<%=year(BirRs(0))%>>&nbsp;年&nbsp;<input maxLength="2" name="month" size="2"  value=<%=month(BirRs(0))%>>&nbsp;月&nbsp;<input maxLength="2" name="day" size="2"  value=<%=day(BirRs(0))%>>&nbsp;日</TD>
	</TR>
	  <TR Class=LightTableBody>
		<TD align=center>愿望：</td><td><TEXTAREA name=wish rows=5 cols=35><%=BirRs(1)%></TEXTAREA> </TD>
	</TR>
	  <TR Class=DarkTableBody>
		<TD align=center colspan=2><INPUT type=submit value=修改 name=Submit class=button>&nbsp;&nbsp;&nbsp;&nbsp;<INPUT onclick=javascript:window.close(); type=reset value=取消 name=Submit2 class=button> </TD>
	</TR>
	</TABLE></form>
	<%
	Set BirRs=Nothing

End Sub


Sub modiwish()


	biryear=request.Form("year")
	If len(biryear)<>4 or not isInteger(biryear) then
		ErrMsg=ErrMsg+"<br>"+"<li>生日年份应为四位数字!"
		FoundErr=true
	Else
		biryear=cint(biryear)
		If biryear>cint(year(date)) or biryear<(cint(year(date))-60) then
			ErrMsg=ErrMsg+"<br>"+"<li>请输入正确的用户出生年份！"
			FoundErr=true
		End If
	End If

	birmonth=request.form("month")
	birday=request.form("day")
	birthday=biryear&"-"&birmonth&"-"&birday
	if not isdate(birthday) then
		errmsg=errmsg+"<br>"+"<li>生日输入有误！"
		founderr=true
	else
		birthday=cdate(birthday)
	end if


	wish=trim(checkstr(Request.form("wish")))
	if strlength(wish)>250 Then
		ErrMsg=ErrMsg+"<br>"+"<li>生日愿望不能超过250个字符!"
		founderr=True
	End if

	if founderr=True Then
		Call Error("Information",ErrMsg)
		Exit Sub
	End if

	Conn.Execute("update student Set birthday='"&birthday&"',wish='"&wish&"' where userid='"&membername&"'")
	response.write "<table width=100% height=100% bgcolor="&BodyColor&"><tr><td valign=top>"

	success "修改资料","成功修改生日愿望！"

End Sub
%>