<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/chkinput.asp"-->
<!--#include file="inc/md5.asp"-->
<%
Dim DownloadClass_Ads
Dim Rs
Dim SQL
Dim ErrMsg
Dim Sucmsg
Dim Founderr
Dim NowStats
Dim HtmlTitle
Dim Style_CSS
Dim HtmlTempStr
Dim TempTopStr
Dim TempFootStr
Dim password,username,userid
UpdatePass
If IsObject(DownloadClass_Ads) Then
	Set DownloadClass_Ads = Nothing
End If
CloseConn
Public Sub UpdatePass()
	Response.Expires = 0
	Response.ExpiresAbsolute = Now() - 1
	Response.cachecontrol = "no-cache"
	Founderr = False
	DownsysClass.LoadTemplates ("")
	Set DownloadClass_Ads = New Adcolumn_Cls
	Set Rs = CreateObject("adodb.recordset")
	If DownsysClass.memberName = Empty Then
		Response.Write "<script>alert('" & DownsysClass.mainset(39) & "');location.replace('login.asp')</script>"
		Response.End
	End If
	If CInt(DownsysClass.Setting(42)) = 0 Then
		Response.Write "<script>alert('" & DownsysClass.mainset(37) & "');javascript:history.back(1)</script>"
		Response.End
	End If
	NowStats = "修改用户密码"
	HtmlTitle = "修改用户密码"
	TempTopStr = DownsysClass.mainhtml(0) & DownsysClass.mainhtml(1) & DownsysClass.mainhtml(2) & DownsysClass.mainhtml(3)
	TempFootStr = DownsysClass.mainhtml(4)
	Style_CSS = Replace(Replace(DownsysClass.Style_CSS, "{$SetupDir}", DownsysClass.SetupDir), "{$PicUrl}", DownsysClass.TempDir)
	HtmlTempStr = TempTopStr
	HtmlTempStr = Replace(HtmlTempStr, "{$NavMenu}", DownsysClass.SortingMenu)
	HtmlTempStr = Replace(HtmlTempStr, "{$Width}", DownsysClass.mainset(0))
	HtmlTempStr = Replace(HtmlTempStr, "{$Style_CSS}", Style_CSS)
	If CInt(DownsysClass.Setting(5)) = 0 Then
		HtmlTempStr = Replace(HtmlTempStr, "{$TopMeun}", DownsysClass.mainset(9))
	Else
		HtmlTempStr = Replace(HtmlTempStr, "{$TopMeun}", DownsysClass.mainset(10))
	End If
	HtmlTempStr = Replace(HtmlTempStr, "{$NowStats}", NowStats)
	HtmlTempStr = Replace(HtmlTempStr, "{$Title}", HtmlTitle)
	HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(0)}", DownloadClass_Ads.RunScriptAds(7))
	HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(1)}", DownloadClass_Ads.BannerAds(7))
	HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(2)}", DownloadClass_Ads.AdsColumn(7, 2))
	HtmlTempStr = Replace(HtmlTempStr, "{$Adcolumn(3)}", DownloadClass_Ads.AdsColumn(7, 3))
	Response.Write HtmlTempStr
	If CInt(DownsysClass.Setting(5)) = 1 Then
		TempFootStr = Replace(TempFootStr, "{$FootMeun}", DownsysClass.mainset(11))
	Else 
		TempFootStr = Replace(TempFootStr, "{$FootMeun}", DownsysClass.mainset(44))
	End If
	TempFootStr = Replace(TempFootStr, "{$Width}", DownsysClass.mainset(0))
	TempFootStr = Replace(TempFootStr, "{$Adcolumn(4)}", DownloadClass_Ads.ScriptFloatAds(7))
	TempFootStr = Replace(TempFootStr, "{$Adcolumn(5)}", DownloadClass_Ads.ScriptFixedAds(7))
	Response.Write "<TABLE width="""
	Response.Write DownsysClass.mainset(0)
	Response.Write """ class=TableBorder cellSpacing=0 cellPadding=0 align=center border=0>" & vbCrLf
	Response.Write " <TR vAlign=top>" & vbCrLf
	Response.Write " <TD class=Border2> <BR style=""OVERFLOW: hidden; LINE-HEIGHT: 5px"">" & vbCrLf
	Select Case Request("action")
		Case "save"
			Call modify
		Case Else
			Call main
	End Select
	If Founderr = True Then
		Response.Write "<script>alert('" & ErrMsg & "');javascript:history.back(1)</script>"
		Response.End
	End If
	Response.Write " </TD></TR></TABLE>" & vbCrLf
	Response.Write TempFootStr
End Sub


Private Sub main()
	Response.Write "<script language=""JavaScript"">" & vbCrLf
	Response.Write "<!--" & vbCrLf
	Response.Write "function CheckForm()" & vbCrLf
	Response.Write "{" & vbCrLf
	Response.Write Chr(9) & "if (document.myform.password.value.length == 0)" & vbCrLf
	Response.Write " {" & vbCrLf
	Response.Write Chr(9) & Chr(9) & "alert(""请输入您的原始密码!"");" & vbCrLf
	Response.Write Chr(9) & Chr(9) & "document.myform.password.focus();" & vbCrLf
	Response.Write Chr(9) & Chr(9) & "return false;" & vbCrLf
	Response.Write Chr(9) & "}" & vbCrLf
	Response.Write Chr(9) & "if (document.myform.password1.value.length == 0)" & vbCrLf
	Response.Write " {" & vbCrLf
	Response.Write Chr(9) & Chr(9) & "alert(""请输入您的新密码!"");" & vbCrLf
	Response.Write Chr(9) & Chr(9) & "document.myform.password1.focus();" & vbCrLf
	Response.Write Chr(9) & Chr(9) & "return false;" & vbCrLf
	Response.Write Chr(9) & "}" & vbCrLf
	Response.Write Chr(9) & "if (document.myform.password2.value.length == 0)" & vbCrLf
	Response.Write " {" & vbCrLf
	Response.Write Chr(9) & Chr(9) & "alert(""请输入您的确认密码"");" & vbCrLf
	Response.Write Chr(9) & Chr(9) & "document.myform.password2.focus();" & vbCrLf
	Response.Write Chr(9) & Chr(9) & "return false;" & vbCrLf
	Response.Write Chr(9) & "}" & vbCrLf
	Response.Write Chr(9) & Chr(9) & "return true;" & vbCrLf
	Response.Write "}" & vbCrLf
	Response.Write "//-->"
	Response.Write "</script>" & vbCrLf
	Response.Write " <TABLE align=center cellSpacing=0 cellPadding=5 width=""90%"" border=0>" & vbCrLf
	Response.Write " <TR bgColor=#F6F6F6>" & vbCrLf
	Response.Write " <TD height=24><IMG border=0 src=""images/sword_org.gif"" align=absMiddle> 修改用户密码　<a href=updateinfo.asp>修改用户资料</a>　<a href=logout.asp>退 出</a></TD></TR>" & vbCrLf
	Response.Write " <TR>" & vbCrLf
	Response.Write " <TD height=1 bgColor=#E6E6E6></TD>" & vbCrLf
	Response.Write " </TR></TABLE>" & vbCrLf
	Response.Write " <TABLE cellSpacing=0 align=center cellPadding=0 width=""90%"" border=0> " & vbCrLf
	Response.Write " <TR>" & vbCrLf
	Response.Write " <TD width=""50%"">&nbsp;</TD>" & vbCrLf
	Response.Write " <TD class=standard vAlign=top height=20><STRONG><FONT color=#6699ff>注意事项：</FONT></STRONG></TD></TR>" & vbCrLf
	Response.Write " <TR>" & vbCrLf
	Response.Write " <TD>" & vbCrLf
	Response.Write " <form method=""post"" name=myform action=""updatepass.asp?action=save"" onSubmit=""return CheckForm();"">" & vbCrLf
	Response.Write " <TABLE cellSpacing=1 cellPadding=2 width=""95%"" bgColor=#cccccc border=0>" & vbCrLf
	Response.Write " <TR>" & vbCrLf
	Response.Write " <TD align=right width=""38%"" bgColor=#f7f7f7 height=20>用户名：</TD>" & vbCrLf
	Response.Write " <TD width=""62%"" bgColor=#f7f7f7 height=20>&nbsp; <STRONG><FONT color=#cc0000>"
	Response.Write DownsysClass.memberName
	Response.Write "</FONT></STRONG>" & vbCrLf
	Response.Write " <INPUT type=hidden name=username value="""
	Response.Write DownsysClass.memberName
	Response.Write """><INPUT type=hidden name=userid value="""
	Response.Write DownsysClass.memberid
	Response.Write """></TD></TR>" & vbCrLf
	Response.Write " <TR bgColor=#ffffff>" & vbCrLf
	Response.Write " <TD align=right height=20>原始密码(<FONT color=#ff6600>*</FONT>)：</TD>" & vbCrLf
	Response.Write " <TD height=20>&nbsp; <INPUT class=inputbody type=password size=25 name=password></TD></TR>" & vbCrLf
	Response.Write " <TR bgColor=#ffffff>" & vbCrLf
	Response.Write " <TD align=right bgColor=#f7f7f7 height=20>新密码(<FONT color=#ff6600>*</FONT>)：</TD>" & vbCrLf
	Response.Write " <TD bgColor=#f7f7f7 height=20>&nbsp; <INPUT class=inputbody type=password size=25 name=password1> " & vbCrLf
	Response.Write " </TD></TR>" & vbCrLf
	Response.Write " <TR bgColor=#ffffff>" & vbCrLf
	Response.Write " <TD align=right height=21>&nbsp;确认新密码(<FONT color=#ff6600>*</FONT>)：</TD>" & vbCrLf
	Response.Write " <TD height=21>&nbsp; <INPUT type=password class=inputbody size=25 name=password2> </TD></TR>" & vbCrLf
	Response.Write " <TR>" & vbCrLf
	Response.Write " <TD align=middle bgColor=#ffffff height=25>&nbsp; </TD>" & vbCrLf
	Response.Write " <TD bgColor=#ffffff height=25 align=center><INPUT type=submit value="" 确 认 "" name=Submit class=button> " & vbCrLf
	Response.Write " </TD></TR></TABLE></form>" & vbCrLf
	Response.Write " </TD>" & vbCrLf
	Response.Write " <TD vAlign=top>" & vbCrLf
	Response.Write " <TABLE class=standard cellSpacing=3 cellPadding=0 width=""100%"" border=0>" & vbCrLf
	Response.Write " <TR>" & vbCrLf
	Response.Write " <TD width=15><IMG height=10 src=""images/sword03.gif"" width=10 border=0></TD>" & vbCrLf
	Response.Write " <TD height=20>用户密码为您管理您的帐号网站的钥匙，请妥善保管好。</TD></TR>" & vbCrLf
	Response.Write " <TR>" & vbCrLf
	Response.Write " <TD vAlign=top>" & vbCrLf
	Response.Write " <TABLE height=20 cellSpacing=0 cellPadding=0 width=""100%"" border=0> " & vbCrLf
	Response.Write " <TR>" & vbCrLf
	Response.Write " <TD height=20><IMG height=10 src=""images/sword03.gif"" width=10 border=0></TD></TR></TABLE></TD>" & vbCrLf
	Response.Write " <TD>密码最好包括数字,字母和符号。只有数字的密码容易被猜破,不安全。</TD></TR>" & vbCrLf
	Response.Write " <TR>" & vbCrLf
	Response.Write " <TD><IMG height=10 src=""images/sword03.gif"" width=10 border=0></TD>" & vbCrLf
	Response.Write " <TD height=20>只有旧密码正确才能修改成功!</TD></TR>" & vbCrLf
	Response.Write " <TR>" & vbCrLf
	Response.Write " <TD><IMG height=10 src=""images/sword03.gif"" width=10 border=0></TD>" & vbCrLf
	Response.Write " <TD height=20>带“<FONT color=#ff6600>*</FONT>”号必填。</TD></TR></TABLE></TD></TR></TABLE>" & vbCrLf
	Response.Write "<BR style=""OVERFLOW: hidden; LINE-HEIGHT: 5px"">" & vbCrLf
End Sub


Private Sub modify()
	Set Rs = Server.CreateObject("ADODB.RecordSet")
	password = md5(Request.Form("password"))
	username = Replace(Request.Form("username"),"'","''")
	userid = CLng(Request.Form("userid"))
	If DownsysClass.checkpost = False Then
		ErrMsg = ErrMsg + "您提交的数据不合法，请不要从外部提交注册。\n"
		Founderr = True
		Exit Sub
	End If
	If DownsysClass.IsValidPassword(Request.Form("password1")) = False Then
		ErrMsg = ErrMsg + "密码中含有非法字符 \n"
		Founderr = True
		Exit Sub
	End If
	If DownsysClass.IsValidStr(Request.Form("username")) = False Then
		ErrMsg = ErrMsg + "用户中含有非法字符 \n"
		Founderr = True
		Exit Sub
	End If
	If Request.Form("password") = "" Then
		ErrMsg = ErrMsg + "您还没有输入原始密码。\n"
		Founderr = True
		Exit Sub
	End If
	If Request.Form("password1") = "" And Request.Form("password2") = "" Then
		ErrMsg = ErrMsg + "您的密码不能为空。\n"
		Founderr = True
		Exit Sub
	End If
	If Request.Form("password1") <> Request.Form("password2") Then
		ErrMsg = ErrMsg + "您输入的密码和确认密码不一致。\n"
		Founderr = True
		Exit Sub
	End If
	Rs.Open "Select * from [NC_User] where username='" & username & "' and userid=" & userid & "", conn, 1, 1
	If Err.Number <> 0 Then Response.Write "数据库出错"
	If Rs.bof And Rs.EOF Then
		Response.Write "Sorry！没有找到此用户信息信息。"
		Exit Sub
	Else
		If password <> Rs("password") Then
			ErrMsg = ErrMsg + "您输入的原始密码错误。\n"
			Founderr = True
			Exit Sub
		End If
	End If
	Rs.Close
	If Founderr = False Then
		SQL = "select * from [NC_user] where username='" & username & "' and userid=" & userid
		Rs.Open SQL, conn, 1, 3
		Rs("password") = md5(Request.Form("password1"))
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		Response.Write ("<script>alert('您的密码修改成功!\n请记住您的新密码\n\n " & Request.Form("password1") & "');javascript:history.back(1)</script>")
		Response.End
	End If
End Sub
%>
