<!--#include file="inc/const.asp"-->
<!--#include file="inc/check.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../api/cls_api.asp"-->
<!--#include file="inc/head.inc"-->
<%
Call InnerLocation("修改会员密码")

If CInt(GroupSetting(0)) = 0 Then
	ErrMsg = ErrMsg + "<li>对不起！您没有修改密码的权限，如有什么问题请联系管理员。</li>"
	Founderr = True
ElseIf LCase(Request("action")) = "save" Then
	Call ChangePassword
Else
%>
<script language="JavaScript">
<!--
function CheckForm() {
	if (document.myform.password.value.length == 0) {
		alert("请输入您的原始密码!");
		document.myform.password.focus();
		return false;
	}
	if (document.myform.password1.value.length == 0) {
		alert("请输入您的新密码!");
		document.myform.password1.focus();
		return false;
	}
	if (document.myform.codestr.value.length != 4) {
		alert("验证码输入有误!");
		document.myform.codestr.focus();
		return false;
	}
	if (document.myform.password2.value.length == 0) {
		alert("请输入您的确认密码");
		document.myform.password2.focus();
		return false;
	}
		return true;
}
//-->
</script>
<form action="?action=save" method="post" onsubmit="return CheckForm();" name="myform">
    <table cellspacing="0" cellpadding="0" width="98%" align="center" border="0">
		<tr>
			<td>
			<table class="Usertableborder" cellspacing="1" cellpadding="2" align="center" bgcolor="#cccccc" border="0">
				<tr>
					<th colspan="2">修改密码</th>
				</tr>
				<tr>
					<td class="Usertablerow1" align="right" width="38%" height="28">用户名：</td>
					<td class="Usertablerow1" width="62%"><strong class="userfont1"><%=MemberName%></strong><input type="hidden" name="username" value="<%=MemberName%>" /><input type="hidden" name="userid" value="<%=memberid%>" /></td>
				</tr>
				<tr>
					<td class="Usertablerow2" align="right" height="28">原始密码(<font color="#ff6600">*</font>)：</td>
					<td class="Usertablerow2"><input class="inputbody" type="password" name="password" /></td>
				</tr>
				<tr>
					<td class="Usertablerow1" align="right" height="28">新密码(<font color="#ff6600">*</font>)：</td>
					<td class="Usertablerow1"><input class="inputbody" type="password" name="password1" /></td>
				</tr>
				<tr bgcolor="#ffffff">
					<td class="Usertablerow2" align="right" height="28">&nbsp;确认新密码(<font color="#ff6600">*</font>)：</td>
					<td class="Usertablerow2"><input class="inputbody" type="password" name="password2" /></td>
				</tr>
				<tr>
					<td class="Usertablerow1" align="right" height="28">验 证 码：</td>
					<td class="Usertablerow1"><input name="checkcode" type="text" class="logininput" id="checkcode" size="5" maxlength="4" onfocus="get_checkcode();this.onfocus=null;" onkeyup="ajaxcheckcode('check_code','checkcode');" />
				<span id="img_checkcode"><label style="cursor:pointer;" onclick="get_checkcode();">点击获取验证码</label></span><span id="isok_checkcode"></span> <font color="#ff0000">*</font></td>
				</tr>
				<tr>
					<td class="Usertablerow2" align="center" height="28">&nbsp;</td>
					<td class="Usertablerow2" align="center"><input class="button" type="submit" name="submit_button" value=" 确 认 " /></td>
				</tr>
			</table>
			</td>
		</tr>
    </table>
</form>
<table cellspacing="3" cellpadding="0" width="98%" align="center" border="0">
	<tr>
		<td width="15">&nbsp;</td>
		<td><strong class="userfont2">注意事项：</strong></td>
	</tr>
	<tr>
	</tr>
	<tr>
		<td><img height="10" width="10" align="absMiddle" alt="" src="images/sword03.gif" /></td>
		<td>用户密码为您管理您的帐号网站的钥匙，请妥善保管好。</td>
	</tr>
	<tr>
		<td><img height="10" width="10" align="absMiddle" alt="" src="images/sword03.gif" /></td>
		<td>密码最好包括数字,字母和符号。只有数字的密码容易被猜破,不安全。</td>
	</tr>
	<tr>
		<td><img height="10" width="10" align="absMiddle" alt="" src="images/sword03.gif" /></td>
		<td>只有旧密码正确才能修改成功!</td>
	</tr>
	<tr>
		<td><img height="10" width="10" align="absMiddle" alt="" src="images/sword03.gif" /></td>
		<td>带&ldquo;<font color="#ff6600">*</font>&rdquo;号必填。</td>
	</tr>
</table>
<br style="overflow: hidden; line-height: 5px">
<%
End If
If Founderr = True Then
	Call ToErrors(ErrMsg)
End If
Sub ChangePassword()
	On Error Resume Next
	Dim Rs,SQL,username, password,userid,newPassWord
	password = md5(Request.Form("password"),15)
	username = NewAsp.CheckBadstr(MemberName)
	userid = CLng(memberid)
	If NewAsp.IsValidStr(Request.Form("password1")) = False Then
		ErrMsg = ErrMsg + "<li>密码中含有非法字符！</li>"
		Founderr = True
		Exit Sub
	End If
	If Trim(Request.Form("username")) <> username Then
		ErrMsg = ErrMsg + "<li>非法操作！</li>"
		Founderr = True
	End If
	If NewAsp.IsValidStr(username) = False Then
		ErrMsg = ErrMsg + "<li>用户中含有非法字符！</li>"
		Founderr = True
		Exit Sub
	End If
	If Trim(Request.Form("password")) = "" Then
		ErrMsg = ErrMsg + "<li>您还没有输入原始密码！</li>"
		Founderr = True
		Exit Sub
	End If
	If Trim(Request.Form("password1")) = "" And Trim(Request.Form("password2")) = "" Then
		ErrMsg = ErrMsg + "<li>您的密码不能为空！</li>"
		Founderr = True
		Exit Sub
	End If
	If Trim(Request.Form("password1")) <> Trim(Request.Form("password2")) Then
		ErrMsg = ErrMsg + "<li>您输入的密码和确认密码不一致！</li>"
		Founderr = True
		Exit Sub
	End If
	If Not NewAsp.CodeIsTrue() Then
		ErrMsg = ErrMsg + "<meta http-equiv=""refresh"" content=""2;URL=changepsw.asp""><li>验证码校验失败，请返回刷新页面再试。两秒后自动返回</li>"
		Founderr = True
		Exit Sub
	End If
	
	newPassWord = md5(Trim(Request.Form("password1")),16)
	Set Rs = NewAsp.Execute("SELECT * FROM [NC_User] WHERE username='" & username & "' And userid=" & userid)
	If Rs.bof And Rs.EOF Then
		ErrMsg = ErrMsg + "<li>Sorry！没有找到此用户信息信息！</li>"
		Founderr = True
		Exit Sub
	Else
		If password <> Rs("password") Then
			ErrMsg = ErrMsg + "<li>您输入的原始密码错误！</li>"
			Founderr = True
			Exit Sub
		End If
	End If
	Rs.Close:Set Rs = Nothing
	If Founderr = False Then
		'-----------------------------------------------------------------
		'系统整合
		'-----------------------------------------------------------------
		Dim API_NewAsp,API_SaveCookie,SysKey
		If API_Enable Then
			Set API_Newasp = New API_Conformity
			API_NewAsp.NodeValue "action","update",0,False
			API_NewAsp.NodeValue "username",UserName,1,False
			Md5OLD = 1
			SysKey = Md5(API_NewAsp.XmlNode("username") & API_ConformKey,16)
			Md5OLD = 0
			API_NewAsp.NodeValue "syskey",SysKey,0,False
			API_NewAsp.NodeValue "password",Trim(Request.form("password1")),1,False
			API_NewAsp.SendHttpData
			If API_NewAsp.Status = "1" Then
				Founderr = True
				ErrMsg = API_NewAsp.Message
			End If
			Set API_Newasp = Nothing
		End If
		'-----------------------------------------------------------------
	End If
	If Founderr = True Then Exit Sub
	Set Rs = NewAsp.CreateAXObject("ADODB.RecordSet")
	SQL = "SELECT password FROM [NC_user] WHERE username='" & username & "' and userid=" & userid
	Rs.Open SQL, Conn, 1, 3
	Rs("password") = newPassWord
	Rs.Update
	Rs.Close
	Set Rs = Nothing
	Response.Cookies(NewAsp.CookiesName)("password") = newPassWord
	Call ToSucceed("<li>恭喜您！密码修改成功。</li><li>请记住您的新密码：<font color=""red"">" & Request.Form("password2") & "</font></li>")
End Sub
%>
<!--#include file="inc/foot.inc"-->