<!--#include file="Inc.asp"-->
<!--#include file="Inc/md5.asp"-->
<%
Dim Action
Action=Lcase(Request.Querystring("Action"))
If Len(Action)>15 Then BBS94KK.GoteErr(1)
BBS94KK.CheckMake
if Action<>"getpassword" and Action<>"forgetpassword" Then
	BBS94KK.Position=BBS94KK.Position&" → <a href=""UserInfo.asp"">用户控制面版<a>"
	If Not BBS94KK.FoundUser Then BBS94KK.GotoErr(4)
End If

Select Case Action
Case"myinfo"
	MyInfo()
Case"savemyinfo"
	SaveMyInfo
Case"mypassword"
	MyPassword
Case"savemypassword"
	SaveMyPassword
Case"forgetpassword"
	forgetpassword
Case"getpassword"
	GetPassword
Case else
	BBS94KK.GoToErr(1)
End Select
BBS94KK.Footer()
Set BBS94KK=Nothing
Sub MyManager()
	Response.Write BBS94KK.ReadSkins("用户控制面版")
End Sub

Sub Myinfo()
	Dim Rs,S,temp,Temp1
	BBS94KK.Head "修改个人资料"
	MyManager()
	SET RS=BBS94KK.Execute("Select Name,Sex,Birthday,Mail,Home,IsQQpic,QQ,Pic,Pich,Picw,IsSign,Sign,Honor,GradeID From[KK_user]where ID="&BBS94KK.MyID&" And Isdel=False")
	IF Rs.eof Then BBS94KK.MakeCookiesEmpty():BBS94KK.GotoErr(100)
	S="<form style='margin:0' method='POST' action='?action=SaveMyInfo'  name='form'>"
	S=S&"<div style='text-align:left;border-bottom:1px solid "&BBS94KK.SkinsPIC(0)&";padding:3px;font-weight:bold;BACKGROUND: "&BBS94KK.SkinsPIC(2)&";'><img src='Images/inn.gif' align='absmiddle' atl='必填资料' /> 必填资料</div>"
	S=S&BBS94KK.Row("<b>用户名称</b>：<br>此为论坛ID帐号，自己不能修改","<br /><b>"&Rs("Name")&"</b>","65%","45px")
	If Rs("Sex")=1 Then Temp=" checked" Else Temp=""
	If Rs("Sex")=0 Then Temp1=" checked" Else Temp1=""
	S=S&BBS94KK.Row("<b>您的性别：</b>","<input name='sex' type='radio' value='1' "&Temp&" /><img src='Images/male.gif' align='absmiddle' atl='帅哥' /> 帅哥&nbsp;&nbsp;<input type='radio' name='sex' value='0' "&Temp1&" /><img src='Images/female.gif' align='absmiddle' atl='靓女' /> 靓女","65%","")
	S=S&BBS94KK.Row("<b>Email地址</b>：<br>请输入有效的邮件地址","<input type='text' class='text' name='mail' style='margin-top:8px' size='30' maxlength='30' value='"&Rs("Mail")&"' />","65%","44px")
	S=S&"<div style='text-align:left;border-bottom:1px solid "&BBS94KK.SkinsPIC(0)&";padding:3px;font-weight:bold;BACKGROUND: "&BBS94KK.SkinsPIC(2)&";'><img src='Images/inn.gif' align='absmiddle' atl='选填资料' /> 选填资料</div>"
	S=S&"<div id='Rowhow' display='none'>"
	S=S&BBS94KK.Row("<b>生日：</b>","<input  type='text' class='text' name='birthday' id='birthday' size='10' maxlength='10' readonly='true' onfocus=""show_cele_date('birthday','','',this)"" value='"&Rs("Birthday")&"' />","65%","20px")
	S=S&BBS94KK.Row("<b>主页：</b><br />填写你的个人主页，让大家见识见识！","<input type='text' class='text' name='home' size='30' maxlength='200'  style='margin-top:8px' value='"&Rs("Home")&"' />","65%","44px")
	If Rs("IsQQPic") Then
	Temp=" checked"
	Else
	Temp=""
	End If
	S=S&BBS94KK.Row("<b>OICQ号码：</b><br />填写您的QQ地址，方便与他人的联系","<input type='text' class='text'  style='margin-top:8px' value='"&Rs("QQ")&"'name='QQ'  maxlength='15'> <input type='checkbox' onclick='QQpic()' name='isqqpic' id='isqqpic' value='1' "&Temp&" />启用QQ形象作为头像","65%","44px")
	S=S&"<div id='showpic'>"
	S=S&BBS94KK.Row("<b>选择论坛头像：</b><br />使用论坛自带的图像",HeadPicOpt() &"<img src='"&Rs("Pic")&"' id='pic' name='pic' /> <input onclick=""openwin('See.asp?Action=HeadPic',680,400,'yes')"" type='button' class='button' value='全部头像' />","65%","50")
	If SESSION(CacheName& "MyGradeInfo")(14)="1" then
	Temp="<input type=button value='上传头像图片' class='button' onclick=""javascript:up.style.display='block';upf.location.href='UploadFile.asp?Flag=1';this.style.display='none'""><div id='up' style='display:none'><iframe id='upf' scrolling='no' frameborder='0' height='22' width='100%'></iframe></div><br>"
	Else
	Temp=""
	End if
	S=S&BBS94KK.Row("<b>自定义头像：</b><br />如果图像位置中有连接图片将以自定义的为主",Temp&"<input id='picurl' name='picurl' size='40' maxlength='100'  value='"&Rs("Pic")&"' /> 完整Url地址<br />图像宽度：<input type='text' class='text' name='picw' id='picw'  size='6' value='"&Rs("PicW")&"' /> 高度：<input type=text name='pich' id='pich' size='6'  value='"&Rs("PicH")&"' />(最大限度:120)","65%","")
	S=S&"</div>"
	If SESSION(CacheName& "MyGradeInfo")(8)="0" then
		 Temp="您还没达到可以自定头衔称号的等级权限<input type='hidden' value='"&Rs("Honor")&"' name='Honor'>"
	Else
		 Temp="<input style='margin-top:8px' type='text' value='"&Rs("Honor")&"' name='Honor'>"
	End If
	S=S&BBS94KK.Row("<b>自定义头衔称号：</b><br />最多8个汉字",Temp,"65%","40px")
	S=S&BBS94KK.Row("<b>个性签名：</b><br />文字将出现在您发表的文章的结尾处<br />体现您的个性(最多255个字符)","<TEXTAREA name='sign' rows='4' style='width: 98%;'>"&Rs("Sign")&"</textarea>","65%","")
	S=S&"</div><div style=""padding:5px;BACKGROUND: "&BBS94KK.SkinsPIC(2)&";""  align='center'><input type='submit' value='确定修改！' class='button' />&nbsp;&nbsp; <input type='reset' class='button' value='取消重写！'  /></div></form>"
	BBS94KK.ShowTable"修改我的资料",S
%>
<script language="JavaScript" type="text/javascript" src="Inc/pswdplc.js"></script>
<script language="JavaScript" type="text/javascript" src="Inc/InputDate.js"></script>
<script type="text/javascript">
QQpic()
function QQpic(){
if (document.getElementById("isqqpic").checked == true){
	document.getElementById("showpic").style.display="none";
	}else{
	document.getElementById("showpic").style.display="block";
	}
	}
function ShowPic(){
document.getElementById("pic").src="pic/headpic/"+document.getElementById("headpicoption").options[document.getElementById("headpicoption").selectedIndex].value+".gif";
document.getElementById("picurl").value="pic/headpic/"+document.getElementById("headpicoption").options[document.getElementById("headpicoption").selectedIndex].value+".gif";
document.getElementById("pich").value='<%=BBS94KK.info(55)%>';
document.getElementById("picw").value='<%=BBS94KK.info(54)%>';
}
function Check(){
openwin("See.asp?Action=CheckName&name="+document.getElementById("name").value,300,30,"no");
}
</script>
<%
End Sub

	
Function HeadPicOpt()
	Dim Temp,i
	for i=2 to Int(BBS94KK.Info(53))
		Temp=Temp&"<option value='"&i&"'>"&i&"</option>"
	Next
	HeadPicOpt="<select name='headpicoption' id='headpicoption' onChange='ShowPic()'><option value='1' selected>1</option>"&Temp&"</select>"
End Function	


Sub SaveMyInfo()
With BBS94KK
	.Head"修改个人资料"
	MyManager()
	Dim Temp,Content,Rs,Sql,Name,Mail,PicUrl,HeadPic,PicW,PicH,Home,Sign,QQ,IsQQpic,Sex,Birthday,Honor
	Name=.Fun.GetStr("name")
	Mail=.Fun.GetStr("mail")
	Honor=.Fun.GetStr("Honor")
	If Mail="" Then .GoToErr(42)
	Mail=server.HTMLEncode(Mail)
	If Not .Fun.IsValidEmail(Mail) Then .GoToErr(42)
	'只允一个邮箱
	If .Info(42)="1" Then
		If Not .Execute("SELECT ID FROM [KK_user] where Mail='"&Mail&"' And ID<>"&.MyID).Eof Then .GoToErr(49)
	End If
	PicUrl=.Fun.HtmlCode(.Fun.GetStr("PicUrl"))
	HeadPic=.Fun.HtmlCode(.Fun.GetStr("HeadPic"))
	Home=.Fun.HtmlCode(.Fun.GetStr("Home"))
	Sex=.Fun.GetStr("Sex")
	Birthday=.Fun.GetStr("Birthday")
	QQ=.Fun.GetStr("QQ")
	IsQQpic=.Fun.GetStr("IsQQpic")
	If IsQQPic="" Then IsQQPic=0
	If Instr(Home,"://")=0 Then Home=.Info(1)
	If IsQQpic<>"1" Then IsQQpic="0"
	Sign=Replace(Left(.Fun.Replacehtml(.Fun.GetStr("Sign")),255),"{帖子内容}","")
	PicH=.Fun.GetStr("pich")
	PicW=.Fun.Getstr("picw")
	If .Info(57)="0" And Instr(PicUrl,"://")>0 Then .GotoErr(45)'禁止外部图片
	If PicUrl="" then
		PicUrl="Pic/headpic/"& HeadPic &".gif"
		PicW= .Info(54)
		PicH= .Info(55)
	End If
	If (QQ<>"" And not isnumeric(QQ)) Or (IsQQpic="1" and QQ="") then .GoToErr(46)
	If Len(Honor)>16 or Len(Mail)>50 or Len(HeadPic)>220 or Len(QQ)>20 or Len(Home)>250 Then .GoToErr(47)
	If Not isnumeric(PicW) or Not isnumeric(PicH) Then .GoToErr(48)
	If Int(PicW)>int(.Info(56)) or Int(PicH)>int(.Info(56)) then
		PicW=.Info(54)
		PicH=.Info(55)
	End If
	Birthday=Replace(Birthday,",","-")
	If Not isdate(Birthday) then
		Birthday="Birthday=Null"
	Else
		.Cache.clean("Birthday")
		Birthday="Birthday='"&Birthday&"'"
	End If
		.execute("update [KK_User] set "&Birthday&",Sex="&Sex&",PicW="&PicW&",PicH="&PicH&",Mail='"&Mail&"',QQ='"&QQ&"',Honor='"&Honor&"',Pic='"&PicUrl&"',Home='"&Home&"',Sign='"&Sign&"',IsQQpic="&IsQQpic&" where ID="&BBS94KK.MyID)
	Content="<div style='margin:15px;line-height: 150%'><li>资料修改成功！<li><a href=UserInfo.asp>返回我的用户控制面版</a><li><a href=index.asp>返回首页</a></div>"
	.ShowTable"修改成功",Content
	Session(CacheName & "MyInfo") = Empty
	End with
End Sub

Sub MyPassword
	Dim S
	BBS94KK.Head "修改密码"
	MyManager()
	S="<form style='margin:0' method='POST' action='?action=SaveMyPassword' name='form'>"
	S=S&BBS94KK.Row("<b>旧密码确认：</b><br />请输入旧密码进入确认","<input type='password' name='Password' size='30' maxlength='20' class='text' />","65%","44px")
	S=S&BBS94KK.Row("<b>新的密码(最多14位)：</b><br />请使用除“'”和“|”以及中文以外的字符","<input type='password' name='NewPassword' size='30' maxlength='20' class='text' />","65%","44px")
	S=S&BBS94KK.Row("<b>重复密码：</b><br />请再输一遍确认","<input type='password' name='RePassword' size='30' maxlength='20' class='text' />","65%","44px")
	S=S&BBS94KK.Row("<b>密码问题</b>：<br />忘记密码的提示问题","<input type='text' class='text' name='clue' size=30  maxlength='60' /> 如不改请不要填写","65%","40px")
	S=S&BBS94KK.Row("<b>问题答案</b>：<br />忘记密码的提示问题答案，用于取回论坛密码","<input type='text' class='text' name='answer' size=30  maxlength='60' /> 同上","65%","40px")
	S=S&"<div style=""padding:5px;BACKGROUND: "&BBS94KK.SkinsPIC(2)&";""  align='center'><input type='submit' value='确定修改！' class='button' />&nbsp;&nbsp; <input type='reset' class='button' value='取消重置！'  /></div></form>"
	BBS94KK.ShowTable "修改密码",S
End Sub

Sub SaveMyPassword
	Dim Password,NewPassword,RePassword,Caption,Content,Clue,Answer
	BBS94KK.CheckMake'禁止外部提交
	BBS94KK.Head"修改密码"
	MyManager()
	Password=BBS94KK.Fun.GetStr("Password")
	NewPassword=BBS94KK.Fun.GetStr("NewPassword")
	RePassword=BBS94KK.Fun.GetStr("RePassword")
	Clue=BBS94KK.Fun.GetStr("clue")
	Answer=BBS94KK.Fun.GetStr("answer")
	If Password="" or Repassword="" or NewPassword="" Then BBS94KK.GoToErr(36)	
	If Repassword<>NewPassword Then BBS94KK.GoToErr(41)
	If Not BBS94KK.Fun.CheckPassword(Password) Or Not BBS94KK.Fun.CheckPassword(NewPassword) Then BBS94KK.GoToErr(37)
	If BBS94KK.Fun.StrLength(NewPassword)>14 Then BBS94KK.GoToErr(38)
	If md5(Password)<>BBS94KK.MyPassword Then BBS94KK.GoToErr(56)
	IF instr("123456|1234567|12345678|123456789|1111111|222222|333333|888888|aaaaaaa","|"& NewPassword &"|")>0 or len(NewPassword)<5 Then BBS94KK.GoToErr(40)
	If Clue<>"" or Answer<>"" Then
		If Len(Clue)<3  or Len(Answer)<3 Then BBS94KK.GoToErr(43)
		If not BBS94KK.Fun.CheckIn(Clue) or not BBS94KK.Fun.CheckIn(Answer) Then BBS94KK.GoToErr(44)
		BBS94KK.execute("update [KK_user] set [Clue]='"&Clue&"',Answer='"&MD5(Answer)&"' where ID="&BBS94KK.MyID)
	End IF
	NewPassword=Md5(Newpassword)
	BBS94KK.execute("update [KK_user] set [password]='"&Newpassword&"' where name='"&BBS94KK.MyName&"' and ID="&BBS94KK.MyID)
	BBS94KK.LetMemor "","MyPassword",NewPassword
	Session(CacheName & "MyInfo") = Empty
	Content="<div style='margin:15px;line-height: 150%'><li>密码修改成功!</li><li><a href=UserInfo.asp>返回用户控制面版</a></li><li><a href=index.asp>返回首页</a></li></div>"
	BBS94KK.ShowTable "修改成功",Content
End Sub

Sub ForgetPassword
	Dim UserName,S
	BBS94KK.Head "找回密码"
	UserName=BBS94KK.Fun.GetStr("UserName")
	If UserName="" Then
	S="<form style='margin:0' method='POST'>"
	S=S&BBS94KK.Row("<b>您的用户名：</b><br>请输入注册的用户名称进入确认","<input type='text' name='UserName' size='30' maxlength='20' class='text' />","65%","44px")
	S=S&"<div style=""padding:5px;BACKGROUND: "&BBS94KK.SkinsPIC(2)&";""  align='center'><input type='submit' value='确定！' class='button' /></div></form>"
	Else
	BBS94KK.CheckMake'禁止外部提交
	If BBS94KK.SafeBuckler(UserName,BBS94KK.MyIP,0) Then BBS94KK.Alert"94KKBBS安全盾已启动！\n\n对不起，你尝试找回密码错误超过3次，今天不能再找回密码了。\n你的信息已被系统记录！","Index.asp"
	S="<form style='margin:0' method='POST' action='?Action=GetPassword'>"
	S=S&BBS94KK.Row("<b>用户名称：</b>","<input name='UserName' type='hidden' value='"&UserName&"'><b>"& UserName &"</b>","65%","22px")
	S=S&BBS94KK.Row("<b>密码问题：</b><br />请输入您在注册时填写的提示问题","<input type='text' name='Clue' size='30' maxlength='20' class='text' />","65%","44px")
	S=S&BBS94KK.Row("<b>问题答案：</b><br />请输入您在注册时填写的问题答案","<input type='text' name='Answer' size='30' maxlength='20' class='text' />","65%","44px")
	S=S&"<div style=""padding:5px;BACKGROUND: "&BBS94KK.SkinsPIC(2)&";""  align='center'><input type='submit' value='确定！' class='button' />&nbsp;&nbsp; <input type='reset' class='button' value='重置！'  /></div></form>"
	End If
	BBS94KK.ShowTable"找回密码",S
End Sub

Sub GetPassword
	Dim UserName,Clue,Answer,NewPassword,Content
	BBS94KK.Head"找回密码"
	UserName=BBS94KK.Fun.GetStr("UserName")
	If BBS94KK.SafeBuckler(UserName,BBS94KK.MyIP,0) Then BBS94KK.Alert"94KKBBS安全盾已启动！\n\n对不起，你尝试找回密码错误超过3次，今天不能再找回密码了。\n你的信息已被系统记录！","Index.asp"
	Clue=BBS94KK.Fun.GetStr("Clue")
	Answer=BBS94KK.Fun.GetStr("Answer")
	If UserName="" or Clue="" or Answer="" Then BBS94KK.GoToErr(36)
	If Not BBS94KK.Fun.CheckName(UserName) Then BBS94KK.GoToErr(37)
	If not BBS94KK.Fun.CheckIn(Clue) or not BBS94KK.Fun.CheckIn(Answer) Then BBS94KK.GoToErr(44)
	IF BBS94KK.execute("select name from [KK_User] where name='"&UserName&"' And Answer='"&Md5(Answer)&"' And Clue='"&Clue&"'").eof  Then
		BBS94KK.SafeBuckler UserName,BBS94KK.MyIP,1
		BBS94KK.GoToErr(57)
	Else
		Randomize
		NewPassword=int(900000*rnd)+100000
		BBS94KK.execute("update [KK_user] set [password]='"&Md5(NewPassword)&"' where name='"&UserName&"'")
		BBS94KK.execute("update [KK_admin] set [password]='"&Md5(NewPassword)&"' where name='"&UserName&"'")	
		Content="<div style='margin:15px;line-height: 150%'><li>您成功的通过密码保护的检验！</li><li>用户名称：<font color=red>"&UserName&"</font> &nbsp; 获得新密码：<font color=red>"&NewPassword&"</font></li><li>先记住新密码，请您马上登陆论坛，尽快修改密码！</li></div>"
		BBS94KK.ShowTable "成功通过验证",Content
	End If	
End Sub
%>
