<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="inc/conndb.asa"-->
<!--#include file="inc/function.asp"-->
<%
PageShowSize = 10            '每页显示多少个页
MyPageSize   = 20        '每页显示多少条
regtime=1800 '秒，这里设置多长时间后才能注册。
If Not IsNumeric(Request("Curpage")) Or IsEmpty(Request("Curpage")) Or Request("Curpage") <=0 Then
	MyPage=1
Else
	MyPage=Int(Abs(Request("Curpage")))
End If
webtitle="会员中心-"&bbsname
navdh="会员中心"
if dreamsun_name<>"" then 
	navright = "| <A href='user.asp?Action=modifypassword'>修改资料</A> "
	navright = navright & "| <A href='user.asp?Action=Mybbs'>我的帖子</A> "
	navright = navright & "| <A href='user.asp?Action=MyRebbs'>我的回复</A> "
	navright = navright & "| <A href='user.asp?Action=Account'>我的积分</A>"
	navright = navright & ""
end if

''IP所在地区查询
if Request.QueryString("Action") = "ipname" Then
	Dim url
	Dim ipaddr,ipresult
	if Request.QueryString("ip")="" then
		Response.Write("&nbsp;")
		Response.End()
	end if
	ipaddr = Request.QueryString("ip")
	Select Case CInt(isShowIpName)
		Case 0
		url = ""
		Case 1
		url = "http://www.91webs.com/?q="
		Case 2
		url = "http://www.cz88.net/ip/default.aspx?ip="
		Case Else
		url = ""
	End Select
	if url<>"" then
		Response.Write(GetIpLocation(ipaddr,url))
	else 
		Response.Write(" &nbsp;")
	end if
	Response.End()
End if


username=Request.QueryString("username")
Call showpage()'调用公用页面，显示界面

Function  pagecontent()
Dim Action
    Action=Request.QueryString("Action")
    Select Case Action
        Case "savepassword"
			Call checkuser()
            Call savepassword()
        Case "modifypassword"
			Call checkuser()
		    Call ModifyPassWord()
		Case "chklogin"
		    Call chklogin()
		Case "reg"
			Call tostopip(1)'判断是否开放注册
		    Call userreg()
		Case "restorePwd"
			'Add For V1.5 找回密码
			Call restorePwd()
		Case "SaveReg"
		    Call savereg()
		Case "Mybbs"
			Call checkuser()
		    Call Mybbs()
		Case "MyRebbs"
			Call checkuser()
		    Call MyRebbs()
		Case "exit"
		    Call userexit()
		Case "infoshow"'V1.3版本新增：必须登陆才能察看用户信息
			If isuserinfo=1 Then'1是任何人可以看，0为登陆察看。
				Call infoshow()
			Else 
				If Dreamsun_name<> "" Then 
					Call infoshow()
				Else
					Call backmsg("请登陆后察看用户信息！","")
				End If

			End If 
		Case "GM"
		    Call GM()
		Case "Account"
			Call Account()
		'Case "ipname"
			'Call IpName()
		Case Else 
			Call userlogin()
    End Select
End Function 
%>
<%
'-----------------------定义用户修改密码\个人信息界面
Sub ModifyPassWord()
	Set Rs_user=Server.CreateObject("ADODB.RecordSet")
    SQL_user="SELECT * FROM "& UserTable &" WHERE UserName='"&DreamSun_name&"'"
    Rs_user.Open SQL_user,Conn,1,3
	user_sex=Rs_user("user_sex")
	user_from=Rs_user("user_from")
	user_mail=Rs_user("user_mail")
	user_qq=Rs_user("user_qq")
	user_show=Rs_user("user_show")
	user_hompage=Rs_user("user_homepage")
	umoney=Rs_user("umoney")
	logintimes=Rs_user("logintimes")
	
	'user_ask 做一个Null判断，以兼容1.5以下的版本
	'1.5以下的版本数据库没有问题和答案这两个字段
	if IsNull(Rs_user("user_ask")) then
		user_ask = ""
	else
		user_ask = Rs_user("user_ask")
	end if
	
	Rs_user.Close
    Set Rs_user=Nothing
%>
<form name="save" method="post" action="user.asp?Action=savepassword" onSubmit="return regcheck(this);">
  <table width="600" align="center" cellSpacing=1 cellPadding=0  border=0>
  <tr>
    <td height="30" align="center" colspan=2><B>密码修改</B></td>
    </tr>
<tr>
    <td width="30%" height="30" align="right"><strong>帐  号：</strong></td>
    <td>&nbsp;<input name="username" type="text" id="username" size="20" maxlength="20" value="<%=DreamSun_name%>" disabled=true>
    </td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>旧 密 码：</strong></td>
    <td>&nbsp;<input name="pwd0" type="password" id="pwd0" size="20" maxlength="20"> <font color="#ff0000">如不修改，请留空</a></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>新 密 码：</strong></td>
    <td>&nbsp;<input name="pwd" type="password" id="pwd" size="20" maxlength="20"> <font color="#ff0000">如不修改，请留空</a></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>确认密码：</strong></td>
    <td>&nbsp;<input name="pwd1" type="password" id="pwd1" size="20" maxlength="20"> <font color="#ff0000">如不修改，请留空</a></td>
  </tr>
  <tr>
    <td height="30" align="center" colspan=2><B>个人信息查询</B></td>
  </tr>
  <%if Trim(user_ask)="" then%>
  <tr>
    <td height="30" align="right"><strong>预留的问题：</strong></td>
    <td>&nbsp;<input name="user_ask"> 
    ( * 添加后不可修改)</td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>预留的答案：</strong></td>
    <td>&nbsp;<input name="user_answer"> 
    ( * 添加后不可修改)</td>
    </tr>
  <%else%>
  <tr>
    <td height="30" align="right"><strong>预留的问题：</strong></td>
    <td>&nbsp;<%=user_ask%> (不可修改)</td>
    </tr>
  <%end if%>
  <tr>
    <td height="30" align="right"><strong>积分：</strong></td>
    <td>&nbsp;<%=umoney%></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>登录信息：</strong></td>
    <td>&nbsp;共登录<%=logintimes%>次</td>
    </tr>

  <tr>
    <td height="30" align="center" colspan=2><B>个人信息修改</B></td>
  </tr>
  <tr>
    <td height="30" align="right"><strong>性别：</strong></td>
    <td>&nbsp;
        <select name="user_sex">
            <option value="0" <% If user_sex=0 Then response.write "selected"%>>男</option>
            <Option value="1" <% If user_sex=1 Then response.write "selected"%>>女</option>
            <Option value="2" <% If user_sex=2 Then response.write "selected"%>>未指定</option>
        </select>
    </td>
  </tr>
  <tr>
    <td height="30" align="right"><strong>电子邮件：</strong></td>
    <td>&nbsp;<input name="user_mail" type="text" id="user_mail" size="40" maxlength="50" value="<%=user_mail%>"></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>QQ号码：</strong></td>
    <td>&nbsp;<input name="user_qq" type="text" id="user_qq" size="20" maxlength="12" value="<%=user_qq%>"></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>来自地区：</strong></td>
    <td>&nbsp;<input name="user_from" type="text" id="user_from" size="40" maxlength="40" value="<%=user_from%>"></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>个人主页：</strong></td>
    <td>&nbsp;<input name="user_hompage" type="text" id="user_hompage" size="40" maxlength="200" value="<%=user_hompage%>"></td>
  </tr>
  <tr>
    <td height="30" align="right"><strong>个性签名：</strong></td>
    <td>&nbsp;<input name="user_show" type="text" id="user_show" size="40" maxlength="100" value="<%=user_show%>"> 100中文字以内</td>
   </tr>

  <tr>
    <td height="30" align="right">　</td>
    <td><input name="submit" type="submit" id="submit" value="提  交">
      &nbsp;&nbsp;
      <input name="reset" type="reset" id="reset" value="重新填写"></td>
    </tr>
</table>
  <br><br>
</form>
<script language="JavaScript1.2">
function regcheck(formct){
	if (formct.username.value=='' ){
		alert('帐号不能为空,请填写');
		return false; 
	}
	if (formct.pwd0.value!='')
	{
		if (formct.pwd.value=='')
			{
				alert('新密码不能为空,请填写');
				return false; 
			}
		if (formct.pwd1.value=='' )
			{
				alert('确认密码不能为空,请填写');
				return false; 
			}
		if (formct.pwd1.value!=formct.pwd.value )
			{
				alert('两次输入密码不一致,请重新检查填写');
				return false; 
			}
	}
	formct.Submit.disabled=true;
}
</script>
<%End Sub
'-----------------------定义修改密码提交
Sub SavePassWord()
	Dim UserName,PassWord0,PassWord,PassWord1
	UserName=DreamSun_name
	PassWord0=Trim(Request.Form("pwd0"))
	PassWord=Trim(Request.Form("pwd"))
	PassWord1=Trim(Request.Form("pwd1"))
	
	user_sex=Int(Request.Form("user_sex"))
	user_from=Trim(Request.Form("user_from"))
	user_mail=Trim(Request.Form("user_mail"))
	user_qq=Trim(Request.Form("user_qq"))
	user_show=Trim(Request.Form("user_show"))
	user_hompage=Trim(Request.Form("user_hompage"))
	if IsNull(Request.Form("user_ask"))  then
		user_ask = ""
	else
		user_ask = Request.Form("user_ask")
		if user_ask <> "" then
			if Trim(Request.Form("user_answer"))="" then
				Response.Write(backMsg("请输入正确的提示问题答案",""))
			end if
		end if
	end if
	if IsNull(Request.Form("user_anser")) then
		user_answer = ""
	else
		user_answer = Md5(Request.Form("user_answer"))
	end if

	If PassWord0<>"" Then '修改密码前，必须输入旧密码
	If PassWord="" Then Response.Write backmsg("请输入新密码!","")
	If PassWord1="" Or PassWord1<>PassWord Then Response.Write backmsg("请检查确认密码!","")
	End If 

	Set Rs=Server.CreateObject("ADODB.RecordSet")
    SQL="SELECT * FROM "& UserTable &" WHERE UserName='"&UserName&"'"
    Rs.Open SQL,Conn,1,3
	If password<>"" Then
		If Rs("pwd")<>MD5(PassWord0) Then
			Response.Write backmsg("旧密码错误，请返回重新输入!","")
			response.End 
		Else
			Rs("PWD")=MD5(PassWord)
		End If 
		shuoming="用户密码"
	Else
		shuoming="用户信息"
	End If
	Rs("user_sex")=user_sex
	Rs("user_from")=user_from
	Rs("user_mail")=user_mail
	Rs("user_qq")=user_qq
	Rs("user_show")=user_show
	Rs("user_homepage")=user_hompage
	Rs("user_ask") = user_ask
	Rs("user_answer") = user_answer
    Rs.Update
    Rs.Close
    Set Rs=Nothing
	Response.Write backmsg("恭喜您，"&shuoming&"修改成功!","user.asp?Action=modifypassword")
End Sub
Sub userlogin()
'-----------------------定义用户登陆界面
if Dreamsun_name<> "" Then response.redirect "index.asp"
%>
<form name="save" method="post" action="user.asp?Action=chklogin" onSubmit="return regcheck(this);">
<br><br>
<table width="600" align="center" cellSpacing=1 cellPadding=0  border=0>
    <tr>
    <td height="30" align="center" colspan=2><strong>用户登录</strong></td>
    </tr>
<tr>
    <td width="30%" height="30" align="right"><strong>帐 号：</strong></td>
    <td>&nbsp;<input name="username" type="text" id="username" size="20" maxlength="20">
    </td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>密 码：</strong></td>
    <td>&nbsp;<input name="pwd" type="password" id="pwd" size="20" maxlength="20"></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>验证码：</strong></td>
    <td>&nbsp;<input name="zd_code" type="text" id="zd_code" size="4" maxlength="4" onKeyPress="if ((event.keyCode<48 &&event.keyCode!=13) || event.keyCode>57) event.returnValue=false">
      <img src="inc/GetCode.asp?a=login" alt= "验证码,看不清楚?请点击刷新验证码" style="cursor : pointer;" onClick="this.src='inc/GetCode.asp?a=login'" onKeyPress="if ((event.keyCode<48 &&event.keyCode!=13) || event.keyCode>57) event.returnValue=false"></td>
    </tr>
    <tr>
    <td height="30" align="right"><strong>保留登录：</strong></td>
    <td>&nbsp;<input type='radio' name='baoliu' value='' checked>否 <input type='radio' name='baoliu' value='365'>是</td>
    </tr>
<tr>
    <td height="30" align="right">　</td>
    <td><input name="submit3" type=button value='注册' onClick="window.location='user.asp?Action=reg'">
      &nbsp;&nbsp;<input name="comurl" type="hidden" id="comurl" value="<%=Cstr(Request.ServerVariables("HTTP_REFERER"))%>">
      <input type=submit name=login id=login value=登录>
    </tr>
</table>
  <br><br>
</form>
<script language="JavaScript1.2">
function regcheck(formct){
	if (formct.username.value=='' ){
		alert('帐号不能为空,请填写');
		return false; 
	}
		if (formct.pwd.value=='' ){
		alert('密码不能为空,请填写');
		return false; 
	}
	if (formct.zd_code.value=='' ){
		alert('验证码不能为空,请填写');
		return false; 
	}

	formct.login.disabled=true;
}
</script>
<%
End Sub 
'-----------------------定义用户登陆提交
Sub chklogin()
Dim username,pwd,code,comurl
	username=Trim(request.form("username"))
	pwd=Trim(request.form("pwd"))
	Code=trim(request.form("zd_code"))
	comurl=Trim(request.form("comurl"))
	baoliu=Trim(Request.Form("baoliu"))

	if InStr(username," or ")<>0 or InStr(username,"'")<>0 or InStr(username,"`")<>0 or InStr(username,"=")<>0 _
	 or InStr(username,"-")<>0 or InStr(username,",")<>0 or InStr(username," and ")<>0 then 
		Response.Write(BackMsg("用户名含有不可接受的字符",""))
	end if
	
	if cstr(session("GetCode_login"))<>cstr(Code) then
		Response.Write(BackMsg("验证码不正确",""))
	end if

	   set rs=server.createobject("adodb.recordset")
	   sql="select * from "& UserTable &" where username='"&username&"'"
	   rs.open sql,conn,3,3
		   if rs.eof then
				Call backmsg("用户名或者密码错误!","")
				Response.End
		   else 
				If rs("pwd")<>md5(pwd) Then
					Call backmsg("用户名 或者 密码错误!","")
				else
					'session("Dreamsun_name")=username
					userlogin_rnd=dreamsun_rnd(18)
					rs("LoginTimes")=rs("LoginTimes")+1
					rs("LastLogin")=Now()
					rs("CookRnd")=Left(md5(userlogin_rnd),5)&right(md5(userlogin_rnd),5)'给数据库一个登陆的随机码，用来验证登录信息。相当于Session
					rs("LoginIP")=reip()
					qian=rs("umoney")
					rs.update
					Response.Cookies("DreamSun_Post_"&webname)("username")=username
					Response.Cookies("DreamSun_Post_"&webname)("rnd")=userlogin_rnd
					if baoliu<>"" then Response.Cookies("DreamSun_Post_"&webname).expires=dateadd("d",baoliu,now())
					if comurl="" then comurl="index.asp"
					response.write backmsg("恭喜，登录成功！当前积分"&qian&"分",comurl)
				end if
		   end if
	rs.close
set rs=nothing

'清空验证码Session
session("GetCode_login") = ""
End Sub 
'-----------------------定义用户退出登陆
Sub userexit()
response.write Dreamsun_name
	sql="update "& UserTable &" set cookrnd='' where username='"&Dreamsun_name&"'"
	conn.execute(sql)
	Response.Cookies("DreamSun_Post_"&webname)=""
	conn.close
	set conn=nothing
	response.redirect "index.asp"
End Sub
'-----------------------定义用户注册界面
Sub UserReg()
if Dreamsun_name<> "" Then response.redirect "index.asp"

'这里设置同一个电脑不允许多长时间注册，如果不需要，可以去掉从if到end if之间的，也可以在上面顶部修改regtime参数，秒 
'（别忘记修改下面100行后的提交部分的这个参数）
If ISdate(Session("regtime")) Then
    If DateDiff("s",Session("regtime"),Now) < regtime Then
        Response.Write("<script>alert(""对不起，您注册速度太快...请半小时后再注册"");window.history.back();</script>")
        Response.End
    End If
End If
'设置结束
%>

<form name="save" method="post" action="user.asp?Action=SaveReg" onSubmit="return regcheck(this);">
  <br><br>
  <table width="600" align="center" cellSpacing=1 cellPadding=0  border=0>
   <tr>
    <td width="100%" height="30" align="center" colspan=2><B>新用户注册</B></td>
   </tr>
  <tr>
    <td width="30%" height="30" align="right"><strong>帐 号：</strong></td>
    <td>&nbsp;<input name="username" type="text" id="username" size="20" maxlength="10" onKeyPress="if ((event.keyCode<48 &&event.keyCode!=13) || ((event.keyCode>57 && event.keyCode<65) || (event.keyCode>90 && event.keyCode< 95) || event.keyCode>122)) event.returnValue=false"> *只能为中文、英文、数字、下划线_
    </td>
  </tr>
  <tr>
    <td height="30" align="right"><strong>密 码：</strong></td>
    <td>&nbsp;<input name="pwd" type="password" id="pwd" size="20" maxlength="20"></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>确认密码：</strong></td>
    <td>&nbsp;<input name="pwd1" type="password" id="pwd1" size="20" maxlength="20"></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>预留问题：</strong></td>
    <td>&nbsp;<input name="user_ask" type="text" id="user_ask" size="20" maxlength="20">* 用于找回密码,填写后不可修改</td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>问题答案：</strong></td>
    <td>&nbsp;<input name="user_answer" type="text" id="user_answer" size="20" maxlength="20">* 用于找回密码,填写后不可修改</td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>验证码：</strong></td>
    <td>&nbsp;<input name="verify_code" type="text" id="verify_code" size="4" maxlength="4" onKeyPress="if ((event.keyCode<48 &&event.keyCode!=13) || event.keyCode>57) event.returnValue=false">
      <img src="inc/GetCode.asp?a=reg" alt= "验证码,看不清楚?请点击刷新验证码" style="cursor : pointer;" onClick="this.src='inc/GetCode.asp?a=reg'"></td>
    </tr>
   <tr>
    <td width="100%" height="30" align="center" colspan=2>以下信息为选填，但是为了获得更好的服务，请认真填写。</td>
   </tr>
  <tr>
    <td height="30" align="right"><strong>性别：</strong></td>
    <td>&nbsp;<select name="user_sex">
<option value="2" selected>未指定</option>
<option value="0" >男</option>
<Option value="1">女</option></select></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>电子邮件：</strong></td>
    <td>&nbsp;<input name="user_mail" type="text" id="user_mail" size="40" maxlength="50"></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>QQ号码：</strong></td>
    <td>&nbsp;<input name="user_qq" type="text" id="user_qq" size="20" maxlength="12"></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>来自地区：</strong></td>
    <td>&nbsp;<input name="user_from" type="text" id="user_from" size="40" maxlength="40"></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>个人主页：</strong></td>
    <td>&nbsp;<input name="user_hompage" type="text" id="user_hompage" size="40" maxlength="200"></td>
  </tr>
  <tr>
    <td height="30" align="right"><strong>个性签名：</strong></td>
    <td>&nbsp;<input name="user_show" type="text" id="user_show" size="40" maxlength="100"> 100中文字以内</td>
   </tr>
  <tr>
    <td height="30" align="right">　</td>
    <td><input name="submit" type="submit" id="submit" value="提  交">
      &nbsp;&nbsp;
      <input name="reset" type="reset" id="reset" value="重新填写"></td>
    </tr>
</table>
  <br><br>
</form>
<script language="JavaScript1.2">
function regcheck(formct){
	if (formct.username.value=='' ){
		alert('帐号不能为空,请填写');
		return false; 
	}
	if (formct.username.value.length <3 ){
		alert('帐号长度请控制在3到10字符之间，中文请控制在2到5个字之间。');
		return false; 
	}
		if (formct.username.value.length >10 ){
		alert('帐号长度请控制在3到10字符之间，中文请控制在2到5个字之间。');
		return false; 
	}
	if (formct.pwd.value=='' ){
		alert('密码不能为空,请填写');
		return false; 
	}
	if (formct.pwd1.value=='' ){
		alert('重复密码不能为空,请填写');
		return false; 
	}
	if (formct.verify_code.value=='' ){
		alert('验证码不能为空,请填写');
		return false; 
	}
	if (formct.user_ask.value=='' ){
		alert('预留问题不能为空,请填写');
		return false; 
	}
	if (formct.user_answer.value=='' ){
		alert('预留问题答案不能为空,请填写');
		return false; 
	}

	formct.Submit.disabled=true;
}
</script>


<%
End Sub
'-----------------------定义用户注册提交
Sub savereg()
Dim username,pwd,pwd1,Code
'这里设置同一个电脑不允许多长时间注册，如果不需要，可以去掉从if到end if之间的，也可以在上面顶部修改regtime参数，秒 
'（别忘记修改上面100行前的填写部分的这个参数）
If ISdate(Session("regtime")) Then
    If DateDiff("s",Session("regtime"),Now) < regtime Then
        Response.Write("<script>alert(""对不起，您注册速度太快...请半小时后再注册"");window.history.back();</script>")
        Response.End
    End If
End If
'设置结束
	username=Trim(request.form("username"))
	pwd=Trim(request.form("pwd"))
	pwd1=Trim(request.form("pwd1"))
	Code=trim(request.form("verify_code"))

	user_sex=Int(Request.Form("user_sex"))
	user_from=Trim(Request.Form("user_from"))
	user_mail=Trim(Request.Form("user_mail"))
	user_qq=Trim(Request.Form("user_qq"))
	user_show=Trim(Request.Form("user_show"))
	user_hompage=Trim(Request.Form("user_hompage"))
	user_ask = Trim(Request.Form("user_ask"))
	user_answer = Md5(Trim(Trim(Request.Form("user_answer"))))



if InStr(username," or ")<>0 or InStr(username,"'")<>0 or InStr(username,"`")<>0 or InStr(username,"=")<>0 or InStr(username,"-")<>0 or InStr(username,",")<>0 or InStr(username," and ")<>0 or InStr(username,"%")<>0 or InStr(username,"<")<>0 or InStr(username,">")<>0 or InStr(username,"&")<>0 or InStr(username,"-")<>0 or InStr(username,"@")<>0 or InStr(username,"*")<>0 then 
	Response.Write BackMsg("用户名中有不可接受的字符","")
end if

if user_ask="" or user_answer ="" then Response.Write(BackMsg("预留问题或者答案不允许被留空",""))
if InStr(user_ask,"'")>0 then Response.Write(BackMsg("预留问题中有不可接受的字符",""))

if cstr(session("GetCode_reg"))<>cstr(Code) then
	Response.Write(backMsg("验证码不正确,请返回"))
end if

if pwd<>pwd1 then 
	response.write"<script>alert('两次密码不同!');history.back();</script>"
else

	' 判断是否为禁止使用的用户名 Add For V1.5
	If IsKeptUser(username)= True  Then
		'Response.Write(BackMsg("被禁止的用户名","")) '不这样写，减少被攻击可能
		Response.Write(BackMsg("该用户名已经存在.",""))
		Response.End()
	End if
	
	sql="select * from "& UserTable &"  where username='"&username&"'"
	Set rs = Server.CreateObject("ADODB.Recordset") 
		rs.open sql,conn,1,1 
			if not rs.eof then
				Response.write BackMsg("该用户名已经存在 .","")
				Response.End()
			Else
				rs.close
				userlogin_rnd=dreamsun_rnd(18)
				rs.open"select * from "& UserTable,conn,1,3
				rs.addnew
				rs("username")=username
				rs("pwd")=md5(pwd)

				Rs("user_sex")=user_sex
				Rs("user_from")=user_from
				Rs("user_mail")=user_mail
				Rs("user_qq")=user_qq
				Rs("user_show")=user_show
				Rs("user_homepage")=user_hompage

				rs("lastlogin")=Now()
				rs("logintimes")=0
				rs("loginip")=ReIP()
				rs("umoney")=first_money
				rs("CookRnd")=Left(md5(userlogin_rnd),5)&right(md5(userlogin_rnd),5)'给数据库一个登陆的随机码，用来验证登录信息。相当于Session
				rs("user_ask") = user_ask
				rs("user_answer") = user_answer
				rs.update
				Response.Cookies("DreamSun_Post_"&webname)("username")=username
				Response.Cookies("DreamSun_Post_"&webname)("rnd")=userlogin_rnd
				Session("regtime") = Now()
				
				' Add For V1.5 CHANG, ZIDONE '''''''''''''Begin
				' 注册成功后,给[ACCOUNT]表中插入积分记录
				OptTable("insert into [account] (accID,accValue,accFromUser,accToUser,accTime,accReason,accRemark) values("&CStr(GetMaxID("account","accid"))&","&CStr(first_money)&",'"&"系统"&"','"&username&"','"&CStr(Now())&"','注册 ','')")
				''''''''''''''''''''''''''''''''''''''''''End
				Call backmsg("用户注册成功!","index.asp")
			end if
		rs.close
end if
'清空验证码Session
session("GetCode_reg") = ""

End Sub 

Sub restorePwd()
	if Request.Form("ask_un")<>"" then
		'如果有用户名
		if Request.Form("ask_ans")<>"" then
			'输入了答案，则判断答案是否正确，若正确显示输入新密码页面
			'首先检查验证码
			'如果ask_upd = yes,说明提交了新密码，这一步就不需要验证码，否则说明是输入答案，需要验证码
			if Request.Form("ask_upd")="" then
				if Request.Form("zd_code")="" or cstr(session("GetCode_login"))<>cstr(Request.Form("zd_code")) then
					Response.Write(backMsg("验证码不正确,请返回","user.asp?Action=restorePwd"))
				end if
				'清空验证码Session
				session("GetCode_login") = ""
			end if
			'判断是否输入了答案
			ask_un = Trim(Request.Form("ask_un"))
			ask_ans = Request.Form("ask_ans")
			if ask_ans = "" then
				Response.Write(BackMsg("不接受空答案",""))
			end if
			sql = "select user_answer from "&usertable&" where [username]='"&ask_un&"'"
			ask_ans2 = OptTable(sql)
			if md5(ask_ans) = ask_ans2 then 
				'如果回答正确，则显示输入新密码的框
				if Request.Form("ask_upd")<>"" then
					'如果输入了新密码，则执行更新密码操作
					'判断密码是否为空
					ask_new_pwd = Request.Form("ask_new_pwd")
					ask_new_pwd2 = Request.Form("ask_new_pwd2")
					if ask_new_pwd = "" then
						Response.Write(BackMsg("不接受空密码",""))
					end if
					if ask_new_pwd <> ask_new_pwd2 then 
						Response.Write(BackMsg("两次密码不统一",""))
					end if
					sql = "update "&usertable&" set pwd='"&md5(ask_new_pwd)&"' where [username]='"&ask_un&"'"
					if CStr(OptTable(sql)) <>"0" then
						'如果修改密码成功，则跳到登录页面
						Response.Write(BackMsg("恭喜,您已经成功地更新了密码，请牢记并重新登录","user.asp"))
					else
						'如果返回值为0，证明没有修改成功
						Response.Write(BackMsg("无法更新您的密码，请联系管理员",""))
					end if
				else
					'如果没有输入新密码，显示密码输入框
%>
                    <p>&nbsp;
                    <table width="600" align="center" cellSpacing=1 cellPadding=0  border=0>
                        <form name="form_ask" method="post" action="user.asp?Action=restorePwd">
                        <tr>
                        <td height="30" align="center" colspan=2><strong>找回密码 - 输入新密码</strong></td>
                        </tr>
                        <tr>
                        <td width="30%" height="30" align="right"><strong>要找回的账号:</strong></td>
                        <td>&nbsp;<input name="ask_un" type="hidden" id="ask_un"value="<%=ask_un%>"><%=ask_un%>
                        <input name="ask_ans" type="hidden" id="ask_ans" value="<%=ask_ans%>">
                        <input name="ask_upd" type="hidden" value="yes">
                        </td>
                        </tr>
                        <tr>
                        <td width="30%" height="30" align="right"><strong>输入您的新密码:</strong></td>
                        <td>&nbsp;<input name="ask_new_pwd" type="password" id="ask_new_pwd">
                        </td>
                        </tr>
                        <tr>
                        <td width="30%" height="30" align="right"><strong>重复您的新密码:</strong></td>
                        <td>&nbsp;<input name="ask_new_pwd2" type="password" id="ask_new_pwd2">
                        </td>
                        </tr>
                        <tr>
                        <td height="30" align="right">　</td>
                        <td><input name="submit3" type=button value='提交' onClick="form_ask.submit();">
                          <input type=button name=login id=login value='取消' onclick="form_ask.reset();">
                        </tr>
                        </form>
                    </table>		
                    <p>&nbsp;

<%

				end if
			else
				'如果回答不正确，则返回回答问题框
				Response.Write(BackMsg("您的回答似乎并不准确",""))
			end if
			
		else
			'没有输入答案，则显示问题，要求用户输入答案
			'首先检查验证码
			if Request.Form("zd_code")="" or cstr(session("GetCode_login"))<>cstr(Request.Form("zd_code")) then
				Response.Write(backMsg("验证码不正确,请返回",""))
			end if
			'清空验证码Session
			'session("GetCode_login") = ""

			
			'检查用户名
			ask_un = Trim(Request.Form("ask_un"))
			if ask_un = "" or InStr(ask_un,"'")>0 or InStr(ask_un,"*")>0 or InStr(ask_un,"-")>0 then
				Response.Write(backMsg("无效的用户名",""))
			end if
			sql = "select count(*) from "&usertable&" where [username]='"&ask_un&"'"
			if CStr(OptTable(sql))<>"0" then
				'如果该用户存在
				sql = "select user_ask from "&usertable&" where [username]='"&ask_un&"'"
				user_ask = OptTable(sql)
				if user_ask<>"" then
					'如果存在用户问题，继续显示问题和回答框
%>
                    <p>&nbsp;
                    <table width="600" align="center" cellSpacing=1 cellPadding=0  border=0>
                        <form name="form_ask" method="post" action="user.asp?Action=restorePwd">
                        <tr>
                        <td height="30" align="center" colspan=2><strong>找回密码 - 回答您预留的问题</strong></td>
                        </tr>
                        <tr>
                        <td width="30%" height="30" align="right"><strong>要找回的账号:</strong></td>
                        <td>&nbsp;<input name="ask_un" type="hidden" id="ask_un"value="<%=ask_un%>"><%=ask_un%>
                        </td>
                        </tr>
                        <tr>
                        <td width="30%" height="30" align="right"><strong>您预留的问题:</strong></td>
                        <td>&nbsp;<input name="user_ask" type="hidden" id="user_ask" value="<%=user_ask%>"><%=user_ask%>
                        </td>
                        </tr>
                        <tr>
                        <td width="30%" height="30" align="right"><strong>输入您的答案:</strong></td>
                        <td>&nbsp;<input name="ask_ans" type="text" id="ask_ans" size="20" maxlength="20">
                        </td>
                        </tr>
                        <tr>
                        <td height="30" align="right"><strong>验证码：</strong></td>
                        <td>&nbsp;<input name="zd_code" type="text" id="zd_code" size="4" maxlength="4" onKeyPress="if ((event.keyCode<48 &&event.keyCode!=13) || event.keyCode>57) event.returnValue=false">
                          <img src="inc/GetCode.asp?a=login" alt= "验证码,看不清楚?请点击刷新验证码" style="cursor : pointer;" onClick="this.src='inc/GetCode.asp?a=login'" onKeyPress="if ((event.keyCode<48 &&event.keyCode!=13) || event.keyCode>57) event.returnValue=false"></td>
                        </tr>
                        <tr>
                        <td height="30" align="right">　</td>
                        <td><input name="submit3" type=button value='下一步' onClick="form_ask.submit();">
                          <input type=button name=login id=login value='取消' onclick="form_ask.reset();">
                        </tr>
                        </form>
                    </table>		
                    <p>&nbsp;
<%
				else
					'如果该用户没有留下问题，那么跳出
				Response.Write(backMsg("很抱歉，您注册时没有留下提示信息，密码将无法找回",""))
				end if
			else
				'如果不存在该用户，跳出
				Response.Write(backMsg("您输入的用户并不存在",""))
			end if
		end if
	else
		'显示输入您的用户名
		%>
        <p>&nbsp;
        <table width="600" align="center" cellSpacing=1 cellPadding=0  border=0>
            <form name="form_ask" method="post" action="user.asp?Action=restorePwd">
            <tr>
            <td height="30" align="center" colspan=2><strong>找回密码 - 输入您的用户名</strong></td>
            </tr>
        <tr>
            <td width="30%" height="30" align="right"><strong>要找回的账号:</strong></td>
            <td>&nbsp;<input name="ask_un" type="text" id="ask_un" size="20" maxlength="20">
            </td>
            </tr>
            <tr>
            <td height="30" align="right"><strong>验证码：</strong></td>
            <td>&nbsp;<input name="zd_code" type="text" id="zd_code" size="4" maxlength="4" onKeyPress="if ((event.keyCode<48 &&event.keyCode!=13) || event.keyCode>57) event.returnValue=false">
              <img src="inc/GetCode.asp?a=login" alt= "验证码,看不清楚?请点击刷新验证码" style="cursor : pointer;" onClick="this.src='inc/GetCode.asp?a=login'" onKeyPress="if ((event.keyCode<48 &&event.keyCode!=13) || event.keyCode>57) event.returnValue=false"></td>
            </tr>
            <tr>
            <td height="30" align="right">　</td>
            <td><input name="submit3" type=button value='下一步' onClick="form_ask.submit();">
              <input type=button name=login id=login value='取消' onclick="form_ask.reset();">
            </tr>
            </form>
        </table>		
        <p>&nbsp;
<%
	end if
	'Response.Write(BackMsg("该功能已经关闭……",""))
End sub

Sub Mybbs()
if Dreamsun_name="" Then response.redirect "index.asp"
sql7 = "SELECT top 100 id,title,addtime,hits,username,titlecolor,IsCheck FROM "&bbstable&" where username='"&Dreamsun_name&"' and IsCheck>-1 ORDER BY addtime DESC" 
Set rs7 = Server.CreateObject("ADODB.Recordset")
rs7.open sql7,conn,1,1
%>
  <br><br>
<table width="700" align="center" cellSpacing=1 cellPadding=0  border=0>
  <tr>
    <td height="30" align="center" colspan="4"><B>我所发表的帖子</B>(只显示最新100条)</td>
  </tr>
<%If rs7.eof and rs7.bof Then%>
  <tr bgcolor="#ffffff">
    <td height="80" align="center" colspan="4"><B>暂无我所发表的帖子</B></td>
  </tr>
<%Else
rs7.PageSize     = MyPageSize
MaxPages         = rs7.PageCount
rs7.absolutepage = MyPage
Totalcount            = rs7.RecordCount
for i=1 to rs7.PageSize
If not rs7.eof Then
		title=Rs7("title")
		if Rs7("TitleColor")<>"" Then title="<font color="&Rs7("TitleColor")&">"&title&"</font>"
%>
  <tr bgcolor="#ffffff">
    <td width="40" height="24" align="center"><%=rs7("hits")%></td>
    <td width="480">&nbsp;<A HREF="show.asp?id=<%=rs7("id")%>" target=_blank><%=title%></A></td>
	<td width="130" align="center"><%=rs7("addtime")%></td>
	<td width="50" align="center"><%If Dreamsun_name=rs7("username") Then 
response.write "<a href='edit.asp?tn=bbs&id="&rs7("id")&"'>编辑</a>"
End If %></td>
  </tr>
<%
rs7.MoveNext
end if
Next
response.write "<tr bgcolor=""#ffffff"">"
response.write "<td height=""80"" align=""center"" colspan=""4""><center>"& viewpage(Totalcount,MyPageSize,PageShowSize,MyPage,"Action=Mybbs","当前总数:","user.asp")&"</center></td>"
response.write "</tr>"

		End if
	rs7.close
	set rs7=Nothing
%>
</table>
  <br>
<%
End Sub 
Sub MyRebbs()
if Dreamsun_name="" Then response.redirect "index.asp"

sql7 = "SELECT top 200 id,title,addtime,re,username,IsCheck FROM "&rebbstable&" where username='"&Dreamsun_name&"' and IsCheck>0 ORDER BY addtime DESC" 
Set rs7 = Server.CreateObject("ADODB.Recordset")
rs7.open sql7,conn,1,1 %>
  <br><br>
<table width="700" align="center" cellSpacing=1 cellPadding=0  border=0>
  <tr>
    <td height="30" align="center" colspan="4"><B>我所参与回复的帖子</B>(只显示最新200条)</td>
  </tr>
<%If rs7.eof and rs7.bof Then%>
  <tr bgcolor="#ffffff">
    <td height="80" align="center" colspan="4"><B>暂无我所回复的帖子</B></td>
  </tr>
<%Else
rs7.PageSize     = MyPageSize
MaxPages         = rs7.PageCount
rs7.absolutepage = MyPage
Totalcount            = rs7.RecordCount
for i=1 to rs7.PageSize
If not rs7.eof Then %>
  <tr bgcolor="#ffffff">
    <td width="20" height="24" align="center">*</td>
    <td width="520">&nbsp;<A HREF="show.asp?id=<%=rs7("re")%>" target=_blank><%=rs7("title")%></A></td>
	<td width="130" align="center"><%=rs7("addtime")%></td>
	<td width="30" align="center"><%If Dreamsun_name=rs7("username") Then 
response.write "<a href='edit.asp?tn=rebbs&id="&rs7("id")&"'>编辑</a>"
End If %></td>
  </tr>
<%
rs7.MoveNext
end if
Next
response.write "<tr bgcolor=""#ffffff"">"
response.write "<td height=""80"" align=""center"" colspan=""4""><center>"& viewpage(Totalcount,MyPageSize,PageShowSize,MyPage,"Action=MyRebbs","当前总数:","user.asp")&"</center></td>"
response.write "</tr>"

		End if
	rs7.close
	set rs7=Nothing
%>
</table>
  <br>

<%
End Sub 
'定义用户信息察看界面
Sub infoshow()
	Response.Charset="gbk"
	Set Rs_user=Server.CreateObject("ADODB.RecordSet")
    SQL_user="SELECT * FROM "& UserTable &" WHERE [UserName]='"&username&"'"
    Rs_user.Open SQL_user,Conn,1,3
		If Rs_user.eof Then
			response.write backmsg("暂无此人信息","")
		Else
			user_sex=Rs_user("user_sex")
			user_from=Rs_user("user_from")
			user_mail=Rs_user("user_mail")
			user_qq=Rs_user("user_qq")
			user_show=Rs_user("user_show")
			user_hompage=Rs_user("user_homepage")
			umoney=Rs_user("umoney")
			logintimes=Rs_user("logintimes")
			regtime=Rs_user("regtime")
			lastlogin=Rs_user("lastlogin")
			loginip=Rs_user("loginip")
		End If 
	Rs_user.Close
    Set Rs_user=Nothing
%>
<script language="vbscript" src="images/vbs2js.vbs"></script>
<script type="text/javascript"  language="javascript" src="images/ClientAjaxWithVBS.js"></script>
    <br>
<table width="600" align="center" cellSpacing=1 cellPadding=0  border=0>
  <tr>
    <td height="30" align="center" colspan=2><B>个人信息查询</B></td>
  </tr>
    <tr >
    <td height="30" align="right" width="100"><strong>姓名：</strong></td>
    <td width="500">&nbsp;<%=username%> （<%level = AdminLevel(CStr(username))
	Select Case level
		Case 0
			mes = "<font style='cursor:wait;' title='普通会员'>普通会员</font>"
		Case 1
			mes = "<font style='cursor:crosshair;' title='分版主' color="&boardManagerColor&">分版主</font>"
		Case 9
			mes = "<font style='cursor:hand;' title='系统管理员' color="&superManagerColor&">系统管理员</font>"
	End Select
	response.write mes
%>）</td>
  <tr>
    <td height="30" align="right"><strong>积分：</strong></td>
    <td>&nbsp;<%=umoney%></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>注册日期：</strong></td>
    <td>&nbsp;<%=regtime%></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>最近登录：</strong></td>
    <td>&nbsp;<%=lastlogin%> 
    <%if isShowIpName>0 then%>
    <span id="spLastLogIP">Loading…<script language="javascript">showData("user.asp?Action=ipname&ip=<%=loginip%>","spLastLogIP");</script></span>
    <%end if%>
    </td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>登录次数：</strong></td>
    <td>&nbsp;共登录<%=logintimes%>次</td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>性别：</strong></td>
    <td>&nbsp;<% If user_sex=0 Then response.write "男"%>
<% If user_sex=1 Then response.write "女"%><% If user_sex=2 Then response.write "未指定"%></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>电子邮件：</strong></td>
    <td>&nbsp;<%If user_mail<>"" Then response.write "<a href=mailto:"&user_mail&">"&user_mail&"</a>"%></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>QQ号码：</strong></td>
    <td>&nbsp;<%=user_qq%></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>来自地区：</strong></td>
    <td>&nbsp;<%=user_from%></td>
    </tr>
  <tr>
    <td height="30" align="right"><strong>个人主页：</strong></td>
    <td>&nbsp;
	<%
		If user_hompage<>"" Or user_hompage<>"http://" Then 
			'格式化超级链接，防止缺少http://时无法打开网页 Edit For V1.5
			hp_link = user_hompage
			if Left(user_hompage,7) <> "http://" then hp_link= "http://" & user_hompage 
			response.write "<a href="""&hp_link&""" target=_blank>"&user_hompage&"</a>"
		End If
	%>
    </td>
  </tr>
  <tr>
    <td height="30" align="right"><strong>个性签名：</strong></td>
    <td>&nbsp;<%=DropFuckWords(ubbs(user_show))%></td>
   </tr>
     <tr>
    <td height="30" align="center" colspan=2><a href="javascript:history.back()">返回上页</a>&nbsp;&nbsp;<a href="usersms.asp?action=new&fa=<%=username%>&comurl=<%=Cstr(Request.ServerVariables("HTTP_REFERER"))%>">发站内消息</a></td>
  </tr>

</table>
  <br><br>
<%End Sub

'定义管理团队
Sub GM()
trAdmin =""
trBoard =""
'--------------------------------------显示超级管理员-----------------------------------
'--------------------------------------Add by zidone 2006/12/30 Begin--------------------
if Instr(bbsbanzhu,"|")>0 then
	groupAdmin = Split(bbsbanzhu,"|")
	groupAdminLen = Ubound(groupAdmin)
	rowSplit = 1
	for ui=0 to groupAdminLen
		if rowSplit = 1 then
			trAdmin = trAdmin & "<tr class=zd_td><td>&nbsp;"& groupAdmin(ui)&"</td>" & VbCrLf
		else
			trAdmin = trAdmin & "<td>&nbsp;"& groupAdmin(ui)&"</td></tr>" & VbCrLf
		end if
		rowSplit = rowSplit * -1
	next
else
	trAdmin ="<tr><td height=30 align=center colspan=2>暂时没有系统管理员</td></tr>"
end if
'--------------------------------------显示超级管理员-----------------------------------
'--------------------------------------Add by zidone 2006/12/30 End----------------------


'--------------------------------------显示版主管理员-----------------------------------
'--------------------------------------Add by zidone 2006/12/30 Begin--------------------
Set Rs_trBoard=Server.CreateObject("ADODB.RecordSet")
SQL_trBoard="SELECT * FROM "& boardtable 
Rs_trBoard.Open SQL_trBoard,Conn,1,3
if Rs_trBoard.recordCount>0 then
	while not Rs_trBoard.Eof 
		If InStr(Rs_trBoard("board_admin"),"|")>0 Then 
			trBoard = trBoard & "<tr class=zd_td><td  width=""50%""> &nbsp;" & Rs_trBoard("board_name")&"板块</td><td>&nbsp;"& Replace(Rs_trBoard("board_admin"),"|","&nbsp;") & "</td></tr>" & VbCrLf
		Else
			trBoard = trBoard & "<tr class=zd_td><td width=""50%""> &nbsp;" & Rs_trBoard("board_name")&"板块</td><td>&nbsp;"& Rs_trBoard("board_admin") & "</td></tr>" & VbCrLf
		End If 
		Rs_trBoard.MoveNext
	wend
else
		trBoard = "<tr><td height=30 align=center colspan=2>暂时没有分版主</td></tr>"
end if
'--------------------------------------显示版主管理员-----------------------------------
'--------------------------------------Add by zidone 2006/12/30 End----------------------

%>    <br>
<table width="600" align="center" cellSpacing=1 cellPadding=0  border=0>
  <tr>
    <td height="30" align="center" colspan=2><B>管理团队</B></td>
  </tr>
  <tr>
    <td height="30" align="left" colspan=2>&nbsp;<B>系统管理</B></td>
  </tr>
  <%=trAdmin%>
  <tr>
    <td height="30" align="left" colspan=2>&nbsp;<B>分版版主</B></td>
  </tr>
  <%=trBoard%>
    <tr>
    <td height="30" align="right"></td>
    <td></td>
  <tr>
    <td height="30" align="center" colspan=2><a href="javascript:history.back()">返回上页</a>&nbsp;&nbsp;</td>
  </tr>

</table>
  <br><br>
<%End Sub %>

<%Sub Account%>
 <%
	   ' 积分管理功能是V1.5版本增加的功能 Add For V1.5 2007-11-11 CHANG,ZIDONE
	   ' 取得总积分
	   myAccount = OptTable("select umoney from "& UserTable &" where username='"&Dreamsun_name&"'")
	   
	   ' 判断是否赠送积分页面被提交
	   if Request.QueryString("send")="yes" then
	   
	   	'首先取得用户提交的用户名和积分，并判断是否合法
		getErr = 0  ' 出现错误的个数
		getInfo= "" ' 具体的错误内容
	   	sendTo = ClearString(Request.Form("toUser")) '要接受积分的用户名
		
		'过滤空用户名
		if sendTo="" then
			getInfo= getInfo + "- 要赠送的用户名不得为空\n"
			getErr = getErr+1
		end if
		
		'过滤无效的用户名
		if OptTable("select * from bbsuser where [username]='"&sendTo&"'")= "" then
			getInfo= getInfo + "- 您填写的用户名无效\n"
			getErr = getErr+1
		end if
		
		'过滤积分接受者是自己的情况
		if Dreamsun_name = sendTo then
			getInfo = getInfo + "- 您不能给自己赠送积分\n"
			getErr = getErr + 1
		end if
		
		'判断用户输入的积分是否合法
		'1, 是否是数字
		'2, 是否小于等于0
		'3, 是否大于它自己本身的积分
		if IsNumeric(Request.Form("sendValue")) then
			sendValue=CInt(Request.Form("sendValue")) '要送出的积分数
			if sendValue<=0  or sendValue>myAccount then
				getInfo= getInfo + "- 请填写正确的积分数\n"
				getErr = getErr+1
			end if
		else 
				' 不是数字的情况
				getInfo= getInfo + "- 请填写正确的积分数\n"
				getErr = getErr+1
		end if
		
		'如果期间出现任何错误，则提示下面的Alert信息
		if getErr>0 then
			getInfo = "常网信息网提示: 请注意出现的"&CSTR(getErr)&"个提示:\n\n" & getInfo
			Response.Write(SetJSAlert(getInfo))
			Response.Write(SetJS("window.history.back();"))
			Response.End()
		end if
		
		'如果前面的过滤成功，开始插入数据
		'将赠送积分的行为插入到积分表[Account]中
		if OptTable("insert into [account] (accID,accValue,accFromUser,accToUser,accTime,accReason,accRemark) values("&CStr(GetMaxID("account","accid"))&","&CStr(sendValue)&",'"&Dreamsun_name&"','"&sendTo&"','"&CStr(Now())&"','赠送','')")=1 then
			
			'如果成功插入到积分表，则开始更新 赠送者和接受者在[用户表]的总积分
			if OptTable("update "&usertable&" set umoney=umoney-"&CStr(sendValue)&" where username='"&Dreamsun_name&"'") = 1 and OptTable("update "&usertable&" set umoney=umoney+"&sendValue&" where username='"&sendTo&"'")=1 then
				Response.Write(SetJSAlert(" - 积分成功送出"))
				Response.Write(SetJS("window.location='user.asp?Action=Account';"))
				Response.End()
			else
				'如果更新总积分失败，那么事务会滚，删除插入到积分表中的记录。
				OptTable("Delete from [account] where accID="&CStr(GetMaxID("account","accid")-1))
				
				'输出错误提示 
				Response.Write(SetJSAlert(" - 积分送出失败"))
				Response.Write(SetJS("window.history.back();"))
				Response.End()
			end if
		else
			Response.Write(SetJSAlert(" - 积分送出失败"))
			Response.Write(SetJS("window.history.back();"))
			Response.End()
		end if
	   end if
%>
    <br>
<table width="600" align="center" cellSpacing=1 cellPadding=0  border=0>
  <tr>
    <td height="30" align="center" colspan=5><B>积分管理</B></td>
  </tr>
  <tr>
    <td height="30" align="left" colspan=4 ><B><%=Dreamsun_name%>您目前的总积分是:<%=myAccount%>分</B></td>
    <td align="center"> &gt;<span style="cursor:hand;" onclick="document.getElementById('dvSend').style.display='block';">送积分给他人</span></td>
  </tr>
   <tr>
    <td colspan=5>
    <div style="display:none;" id="dvSend">
        <form name="fmSendValue" action="user.asp?Action=Account&send=yes" method="post">
        您的可用积分是<%=myAccount%>分，您要捐赠给<input size="10" type="text" name="toUser">
        (用户名)积分<input size="10" type="text" name="sendValue">分 <input type="submit" value="执行"> 
        <input type="button" onclick="toUser.value='';sendValue.value='';document.getElementById('dvSend').style.display='none';" value="返回">
 		<input type="hidden" value="<%=myAccount%>" name="maxAcc">
        </form>
    </div>
    </td>
   </tr>
<%
	   ' 取得获得的积分
	   sql = "select * from [account] where AccToUser='"&Dreamsun_name&"' or AccFromUser='"&Dreamsun_name&"' order by accID Desc"
	   Set rsToMe = Server.CreateObject("ADODB.Recordset")
	   rsToMe.Open Sql, conn, 1,3
	   %>
       <tr bgcolor="#ffffff">
        <td width="150">&nbsp;时间</td>
        <td width="50" align="center">属性</td>
        <td width="100" align="center">数量
        <td width="100" align="center">来自/送给
        <td width="100" height="24" align="center">原因</td>
        </td>
      </tr>
	   <%
	   if rsToMe.RecordCount >0 then 
		   rsToMe.PageSize     = MyPageSize
		   MaxPages         = rsToMe.PageCount
		   rsToMe.absolutepage = MyPage
		   Totalcount   = rsToMe.RecordCount
		   for i=1 to rsToMe.PageSize
			   If not rsToMe.eof Then
			   if rsToMe("AccToUser")<>dreamsun_name then
				AccKey = "<font color=red>支出</font>"
				AccUser =rsToMe("AccToUser")
			   else
				AccKey = "收入"
				AccUser =rsToMe("AccFromUser")
			   end if
			%>
				 <tr bgcolor="#ffffff">
					<td width="150">&nbsp;<%=rsToMe("AccTime")%></td>
					<td width="50" align="center"><%=AccKey%></td>
					<td width="100" align="center"><%=rsToMe("AccValue")%>
					<td width="100" align="center"><%=AccUser%>
					<td width="100" height="24" align="center"><%=rsToMe("AccReason")&"["&rsToMe("AccRemark")&"]"%></td>
					</td>
				  </tr>
			<%
			rsToMe.MoveNext
			end if
			Next%>
			<tr bgcolor="#ffffff">
			<td height="80" align="center" colspan=5>
			<center><% =viewpage(Totalcount,MyPageSize,PageShowSize,MyPage,"Action=Account","当前总数:","user.asp")%>
			</center>
			</td>
			</tr>
			<%
			set rsToMe = nothing
	   else 
	   %>
     <tr>
        <td height="30" align="center" colspan=5>暂无您的积分记录</td>
      </tr>
	   <%
	   end if
 %>
 <tr>
    <td height="30" align="center" colspan=5><a href="javascript:history.back()">返回上页</a>&nbsp;&nbsp;</td>
  </tr>

</table>
  <br><br>

<%End Sub%>