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

Dim Rs,SQL
If CInt(GroupSetting(1)) = 0 Then
	ErrMsg = ErrMsg + "<li>对不起！您没有修改用户资料的权限，如有什么问题请联系管理员。</li>"
	Founderr = True
ElseIf LCase(Request("action")) = "save" Then
	Call ChangeUserInfo
Else
	Set Rs = NewAsp.Execute("SELECT * FROM [NC_User] WHERE username='" & NewAsp.membername & "' And userid=" & NewAsp.memberid)
	If (Rs.bof And Rs.EOF) Then
		ErrMsg = ErrMsg + "<li>Sorry！错误的系统参数！</li>"
		Founderr = True
	Else
%>
<script language="JavaScript">
<!--
function checkForm() {
	if (document.myform.password.value.length == 0) {
		alert("请输入您的用户密码!");
		document.myform.password.focus();
		return false;
	}
	if (document.myform.nickname.value.length == 0) {
		alert("请输入您的用户昵称!");
		document.myform.nickname.focus();
		return false;
	}
	if (document.myform.codestr.value.length != 4) {
		alert("验证码输入有误!");
		document.myform.codestr.focus();
		return false;
	}
	if (document.myform.usermail.value.length == 0) {
		alert("请输入您的E-mail");
		document.myform.usermail.focus();
		return false;
	}
		return true;
}
//-->
</script>
<form action="?action=save" method="post" onsubmit="return checkForm();" name="myform">
    <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="25%" height="25">用户名：</td>
			<td class="Usertablerow1" width="75%"><strong class="userfont1"><%=NewAsp.membername%></strong><input type="hidden" name="username" value="<%=Server.HTMLEncode(Rs("username"))%>" /><input type="hidden" name="userid" value="<%=NewAsp.memberid%>" /></td>
		</tr>
		<tr>
			<td class="Usertablerow2" align="right" height="25">用户昵称(<span class="userfont1">*</span>)：</td>
			<td class="Usertablerow2"><input class="inputbody" maxlength="15" name="nickname" value="<%=NewAsp.HTMLEncodes(Rs("nickname"))%>" type="text" /></td>
		</tr>
		<tr>
			<td class="Usertablerow1" align="right" height="25">真实姓名(<span class="userfont1">*</span>)：</td>
			<td class="Usertablerow1"><input class="inputbody" maxlength="15" name="TrueName" value="<%=NewAsp.HTMLEncodes(Rs("TrueName"))%>" type="text" /></td>
		</tr>
		<tr bgcolor="#ffffff">
			<td class="Usertablerow2" align="right" height="25">&nbsp;用户邮箱(<span class="userfont1">*</span>)：</td>
			<td class="Usertablerow2"><input class="inputbody" maxlength="50" size="30" name="usermail" value="<%=NewAsp.HTMLEncodes(Rs("usermail"))%>" type="text" /> <span class="userfont1">注意：</span><font color="#808080">请填写你常用的邮箱</font></td>
		</tr>
		<tr>
			<td class="Usertablerow1" align="right" height="25">性别：</td>
			<td class="Usertablerow1"><input type="radio" name="usersex" value="男"<%If Trim(Rs("usersex")) = "男" Then Response.Write " checked"%> /> 男&nbsp;&nbsp;
			<input type="radio" name="usersex" value="女"<%If Trim(Rs("usersex")) = "女" Then Response.Write " checked"%> /> 女&nbsp;&nbsp;
			<input type="radio" name="usersex" value="保密"<%If Trim(Rs("usersex")) = "保密" Then Response.Write " checked"%> /> 保密</td>
		</tr>
		<tr>
			<td class="Usertablerow2" align="right" height="25">密码提示问题(<span class="userfont1">*</span>)：</td>
			<td class="Usertablerow2"><input class="inputbody" maxlength="35" size="30" name="question" value="<%=NewAsp.HTMLEncodes(Rs("question"))%>" type="text" /> <select onChange="question.value=this.value;">
			<option value="" selected="selected">[请选择]</option>
			<option value="最喜欢的宠物？">最喜欢的宠物？</option>
			<option value="最喜爱的电影？">最喜爱的电影？</option>
			<option value="周年纪念日 [年/月/日]？">周年纪念日 [年/月/日]？</option>
			<option value="父亲的名字？">父亲的名字？</option>
			<option value="配偶的名字？">配偶的名字？</option>
			<option value="第一个孩子的爱称？">第一个孩子的爱称？</option>
			<option value="中学的校名？">中学的校名？</option>
			<option value="最尊敬的老师？">最尊敬的老师？</option>
			<option value="最喜欢的运行队？">最喜欢的运行队？</option>
			</select></td>
		</tr>
		<tr>
			<td class="Usertablerow1" align="right" height="25">密码问题答案：</td>
			<td class="Usertablerow1"><input class="inputbody" maxlength="35" size="30" name="answer" type="text" /> <font color="#808080">忘记密码的提示问题答案，用于取回密码</font></td>
		</tr>
		<tr bgcolor="#ffffff">
			<td class="Usertablerow2" align="right" height="25">联系电话：</td>
			<td class="Usertablerow2"><input class="inputbody" maxlength="20" name="phone" value="<%=NewAsp.HTMLEncodes(Rs("phone"))%>" type="text" /> <font color="#808080">如：+86-27-85188888</font></td>
		</tr>
		<tr>
			<td class="Usertablerow1" align="right" height="25">你的OICQ：</td>
			<td class="Usertablerow1"><input class="inputbody" maxlength="20" name="oicq" value="<%=NewAsp.HTMLEncodes(Rs("oicq"))%>" type="text" /></td>
		</tr>
		<tr bgcolor="#ffffff">
			<td class="Usertablerow2" align="right" height="25">邮政编码：</td>
			<td class="Usertablerow2"><input class="inputbody" maxlength="20" name="postcode" value="<%=NewAsp.HTMLEncodes(Rs("postcode"))%>" type="text" /></td>
		</tr>
		<tr>
			<td class="Usertablerow1" align="right" height="25">身份证：</td>
			<td class="Usertablerow1"><input class="inputbody" maxlength="35" size="30" name="UserIDCard" value="<%=NewAsp.HTMLEncodes(Rs("UserIDCard"))%>" type="text" /></td>
		</tr>
		<tr bgcolor="#ffffff">
			<td class="Usertablerow2" align="right" height="25">联系地址：</td>
			<td class="Usertablerow2"><input class="inputbody" maxlength="50" size="50" name="address" value="<%=NewAsp.HTMLEncodes(Rs("address"))%>" type="text" /></td>
		</tr>
		<tr>
			<td class="Usertablerow1" align="right" height="25">交易密码：</td>
			<td class="Usertablerow1"><input class="inputbody" maxlength="35" size="30" name="BuyCode" type="text" /> <font color="#808080">站内支付所用的交易密码</font></td>
		</tr>
		<tr>
			<td class="Usertablerow2" align="right" height="25">个人主页：</td>
			<td class="Usertablerow2"><input class="inputbody" maxlength="35" size="30" name="HomePage" value="<%=NewAsp.HTMLEncodes(Rs("HomePage"))%>" type="text" /> <font color="#808080">以&ldquo;http://&rdquo;开头</font></td>
		</tr>
		<tr>
			<td class="Usertablerow1" align="right" height="25">用户密码：</td>
			<td class="Usertablerow1"><input class="inputbody" type="password" maxlength="50" size="30" name="password" /> <span class="userfont1">输入正确的密码才能修改用户资料</span></td>
		</tr>
		<tr>
			<td class="Usertablerow2" align="right" height="28">验 证 码：</td>
			<td class="Usertablerow2"><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="Usertablerow1" align="center" height="28">&nbsp;</td>
			<td class="Usertablerow1" align="center"><input class="button" type="submit" name="submit_button" value=" 确 认 " /></td>
		</tr>
    </table>
</form>
<%
	End If
	Rs.Close:Set Rs = Nothing
End If
If Founderr = True Then
	Call ToErrors(ErrMsg)
End If
Sub ChangeUserInfo()
	On Error Resume Next
	Dim username, password,userid
	Dim usersex,sex
	username = NewAsp.CheckBadstr(NewAsp.membername)
	userid = NewAsp.ChkNumeric(memberid)
	If NewAsp.CheckPost=False Then
		ErrMsg = ErrMsg + Postmsg
		FoundErr = True
		Exit Sub
	End If
	If NewAsp.IsValidStr(Request.Form("answer")) = False And Trim(Request.Form("answer")) <> "" Then
		ErrMsg = ErrMsg + "<li>密码问题答案中含有非法字符！</li>"
		Founderr = True
	End If
	If Trim(Request.Form("username")) <> username Then
		ErrMsg = ErrMsg + "<li>非法操作！</li>"
		Founderr = True
	End If
	If Trim(Request.Form("password")) = "" Then
		ErrMsg = ErrMsg + "<li>请输入用户密码！</li>"
		Founderr = True
	Else
		password = md5(Request.Form("password"),16)
	End If
	If userid = 0 Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>Sorry！您选择了错误的系统参数。</li>"
		Exit Sub
	End If
	
	If Trim(Request.Form("nickname")) = "" Then
		ErrMsg = ErrMsg + "<li>用户昵称不能为空！</li>"
		Founderr = True
	End If
	If NewAsp.IsValidStr(Request.Form("nickname")) = False Then
		ErrMsg = ErrMsg + "<li>用户昵称中含有非法字符！</li>"
		Founderr = True
	End If
	If Trim(Request.Form("TrueName")) = "" Then
		ErrMsg = ErrMsg + "<li>真实姓名不能为空！</li>"
		Founderr = True
	End If
	If NewAsp.IsValidStr(Request.Form("TrueName")) = False Then
		ErrMsg = ErrMsg + "<li>真实姓名中含有非法字符！</li>"
		Founderr = True
	End If
	If Trim(Request.Form("usermail")) = "" Then
		ErrMsg = ErrMsg + "<li>您的Email不能为空！</li>"
		Founderr = True
	End If
	If IsValidEmail(Request.Form("usermail")) = False Then
		ErrMsg = ErrMsg + "<li>您的Email有错误！</li>"
		Founderr = True
	End If
	If Not IsNumeric(Request.Form("oicq")) And Trim(Request.Form("oicq")) <> "" Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>QQ号码请用数字填写。</li>"
	End If
	If Trim(Request.Form("HomePage")) <> "" And Left(Request.Form("HomePage"),7) <> "http://" Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>个人主页地址输入有误，请以“http://”开头。</li>"
	End If
	If Not NewAsp.CodeIsTrue() Then
		ErrMsg = ErrMsg + "<meta http-equiv=""refresh"" content=""2;URL=changeinfo.asp""><li>验证码校验失败，请返回刷新页面再试。两秒后自动返回</li>"
		Founderr = True
		Exit Sub
	End If
	If Trim(Request.Form("usersex")) = "" Then
		ErrMsg = ErrMsg + "<li>您的姓别不能为空！</li>"
		Founderr = True
	Else
		usersex = NewAsp.CheckBadstr(Request.Form("usersex"))
	End If
	If usersex = "女" Then
		sex = 0
	Else
		sex = 1
	End If
	
	If Founderr = True Then Exit Sub
	Set Rs = NewAsp.CreateAXObject("ADODB.RecordSet")
	SQL = "SELECT * FROM [NC_user] WHERE username='" & username & "' And userid=" & CLng(userid)
	Rs.Open SQL, Conn, 1, 3
	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
		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","",1,False
				API_NewAsp.NodeValue "answer",Request.Form("answer"),1,False
				API_NewAsp.NodeValue "question",Request.Form("question"),1,False
				API_NewAsp.NodeValue "email",Request.Form("usermail"),1,False
				API_NewAsp.NodeValue "gender",sex,0,False
				API_NewAsp.SendHttpData
				If API_NewAsp.Status = "1" Then
					Founderr = True
					ErrMsg = API_NewAsp.Message
					Exit Sub
				End If
				Set API_Newasp = Nothing
			End If
			'-----------------------------------------------------------------
		End If
		Rs("nickname") = NewAsp.CheckBadstr(Request.Form("nickname"))
		Rs("TrueName") = NewAsp.CheckBadstr(Request.Form("TrueName"))
		Rs("usermail") = Trim(Request.Form("usermail"))
		If Trim(Request.Form("HomePage")) <> "" Then Rs("HomePage") = NewAsp.RequestForm(Request.Form("HomePage"),100)
		If Trim(Request.Form("usersex")) <> "" Then Rs("usersex") = usersex
		If Trim(Request.Form("question")) <> "" Then Rs("question") = NewAsp.RequestForm(Request.Form("question"),50)
		If Trim(Request.Form("answer")) <> "" Then Rs("answer") = md5(Trim(Request.Form("answer")),16)
		If Trim(Request.Form("phone")) <> "" Then Rs("phone") = NewAsp.RequestForm(Request.Form("phone"),50)
		If Trim(Request.Form("oicq")) <> "" Then Rs("oicq") = NewAsp.RequestForm(Request.Form("oicq"),50)
		If Trim(Request.Form("postcode")) <> "" Then Rs("postcode") = NewAsp.RequestForm(Request.Form("postcode"),50)
		If Trim(Request.Form("UserIDCard")) <> "" Then Rs("UserIDCard") = NewAsp.RequestForm(Request.Form("UserIDCard"),50)
		If Trim(Request.Form("address")) <> "" Then Rs("address") = NewAsp.RequestForm(Request.Form("address"),200)
		If Trim(Request.Form("BuyCode")) <> "" Then Rs("BuyCode") = md5(Trim(Request.Form("BuyCode")),16)
		Rs.Update
	End If
	Rs.Close
	Set Rs = Nothing
	Call ToSucceed("<li>恭喜您！用户资料修改成功。</li>")
End Sub
%>
<!--#include file="inc/foot.inc"-->