<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<!--#include file="../inc/char.asp"-->
<!--#include file="../inc/setup.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../inc/sql.asp"-->
<%
	End If
	action=ReplaceBadChar(Trim(Request.QueryString("action")))
	
	if action="changename" then
		newname=ReplaceBadChar(Trim(Request.Form("newname")))
		newname1=ReplaceBadChar(Trim(Request.Form("newname1")))
		
		
		set rs=server.createobject("adodb.recordset")
		sql="select * from school where sname='"&ReplaceBadChar(Request.Cookies("admin_school_name"))&"'"
		rs.open sql,conn,2,3
		if rs.eof and rs.bof then
			response.write"<SCRIPT language=JavaScript>alert('非法操作');"
			response.write"window.location.href = 'login.asp'"&" </script>"
		else
		
			set rs1=server.createobject("adodb.recordset")
			sql1="select * from school where sname='"&newname&"'"
			rs1.open sql1,conn,1,1
			if rs1.eof then
				rs("uname")=newname
				email=rs("email")
				rs.update
			else
				response.write"<SCRIPT language=JavaScript>alert('对不起，该用户名已存在，请更换另一个用户名');"
				response.write"window.location.href = 'changename.asp'"&" </script>"
			end if
			rs1.close
			set rs1=nothing
			rs.close
			set rs=nothing
			
			Response.Cookies("admin_school_name")=newname
			Response.Cookies("admin_school_name").expires=(now()+1/24)
   
			Set rs = Server.CreateObject("ADODB.Recordset")
			sql="select * from sendmail"
			rs.open sql,conn,1,1
			if rs("open1")=0 then
				mailaddress=rs("mailaddress")
				mailusername=rs("mailusername")
				mailuserpass=rs("mailuserpass")
				mailname=rs("mailname")
				mailsend=rs("mailsend")
			
			
				'发送邮件
				'if Forum_Setting(47)=1 then
				On Error Resume Next
				'发送注册邮件
				topic="["&homename&"]信息：您在"&homename&"的修改密码的资料"
				
				mailbody="<html>"
				mailbody=mailbody & "<title>用户信息</title>"
				mailbody=mailbody & "<body>"
				mailbody=mailbody & "<TABLE border=0 width='95%' align=center><TBODY><TR>"
				mailbody=mailbody & "<TD valign=middle align=top>"
				mailbody=mailbody & ""&newname&"，您好：<br><br>"
				mailbody=mailbody & "您在"&homename&"注册的帐号信息发生改变，下面是你最新的帐号信息！<br>"
				mailbody=mailbody & "下面是您在"&homename&"的注册信息：<br><br>"
				mailbody=mailbody & "注册名："&newname&"<br>"
				mailbody=mailbody & "网站地址：<a href='"&homeurl&"' target='_blank'>"&homeurl&"</a><br><br>"
				mailbody=mailbody & ""&rs("mailtext")&"<br><br><br>"
				mailbody=mailbody & "<center><font color=red>再次感谢您注册"&homename&"</font>"
				mailbody=mailbody & "</TD></TR></TBODY></TABLE><br><hr width=95% size=1>"
				mailbody=mailbody & "</body>"
				mailbody=mailbody & "</html>"
				rs.close
				
				Set JMail=Server.CreateObject("JMail.Message")
				JMail.Charset="gb2312"
				JMail.ContentType = "text/html"
				jmail.from = mailsend
				jmail.silent = true
				jmail.Logging = true
				jmail.FromName = mailname
				jmail.mailserverusername = mailusername
				jmail.mailserverpassword = mailuserpass
				jmail.AddRecipient email
				jmail.body=mailbody
				JMail.Subject=topic
				if not jmail.Send ( mailaddress ) then
					SendMail=""
				else
					SendMail="OK"
				end if
				if SendMail="OK" then
					sendmsg="<p>· 您的注册信息已经发往您的邮箱，请注意查收!</p>"
				else
					sendmsg="<p>· 系统出错，注册信息资料未能发送到您的邮箱!</p>"
				end if
			else
				rs.close
			end if   
			
			response.write"<SCRIPT language=JavaScript>alert('帐号名称修改成功，现在正为您返回，请稍等');"
			response.write"window.location.href = 'changename.asp'"&" </script>"
		end if
		
	end if	
%>
<HTML>
<head>
<meta http-equiv=Content-Language content=zh-cn>
<meta http-equiv=Content-Type content=text/html; charset=gb2312>
<link href="images/1.css" rel="stylesheet" type="text/css">
<link href="images/2.css" rel="stylesheet" type="text/css">
<SCRIPT LANGUAGE="JavaScript">
<!--
function check()
{
   if(checkspace(document.userinfo.newname.value)) {
	document.userinfo.newname.focus();
    alert("对不起，请填写新用户名！");
	return false;
  }
  if(document.userinfo.newname.value != document.userinfo.newname1.value) {
	document.userinfo.newname.focus();
	document.userinfo.newname1.value = '';
	document.userinfo.newname.value = '';
    alert("两次输入的用户名不同，请重新输入！");
	return false;
  }
}
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
//-->
</script>
</head>
<body topmargin="0">
<%
	set rs=server.createobject("adodb.recordset")
	sql="select * from school where sname='"&Request.Cookies("admin_school_name")&"'"
	rs.open sql,conn,1,1
	if rs.eof then
		response.write"<SCRIPT language=JavaScript>alert('非法操作！');"
		response.write"this.location.href='login.asp';</SCRIPT>"
		response.end
	else
%>
<table width="550"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><img src="images/m_11.gif" width="550" height="9"></td>
  </tr>
  <tr>
    <td background="images/m_13.gif">
      <table width="98%"  border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td valign="top"><img src="images/jianli-8.gif" width="136" height="33"></td>
        </tr>
		<TR>
          <TD bgColor=#83b629 height=21><FONT style="FONT-SIZE: 13px" face=Verdana color=#ffffff><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;修改帐号</STRONG></FONT></TD>
        </TR>
		 <tr><TD height=5></TD></TR>
 		<tr>
          <td valign="top">
<form name="userinfo" action="?action=changename" method="post" onSubmit="return check()">
                  <TABLE width=42% border=0 align="center" cellPadding=0 cellSpacing=1 bgcolor="#E8E8E8">
                    <TBODY>
                      <TR>
                        <TD bgcolor="#FFFFFF">
						<TABLE height=0 cellSpacing=0 cellPadding=0 width="100%" border=0>
                            <TBODY>
                              <TR>
                                <TD></TD>
                              </TR>
                            </TBODY>
                          </TABLE>
                          <TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
                              <TBODY>
                                <TR>
                                  <TD width="100%" height="30"><div align="center"><span class="style61">*</span> 用 户 名 ：
                                    <input name="old_name" type="text" style="width:200px;font-size:12px;border:0; border-bottom:1 solid #999999;" value="<%= Request.Cookies("admin_school_name") %>" maxlength="20"  readonly>
                                          <BR>
                                  </div></TD>
                                </TR>
                              </TBODY>
                          </TABLE>
                          <TABLE width=450 border=0 align="center" cellPadding=0 cellSpacing=0>
                              <TBODY>
                                <TR>
                                  <TD background="../company/images/contents_dotline.gif" height=5></TD>
                                </TR>
                              </TBODY>
                          </TABLE>
                          <TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
                              <TBODY>
                                <TR>
                                  <TD width="100%" height="30"><div align="center"><span class="style61">*</span> 新用户名 ：
                                      <input name="newname" type="text" style="width:200px;font-size:12px;border:0; border-bottom:1 solid #999999;" maxlength="20">
                                          <BR>
                                  </div></TD>
                                </TR>
                              </TBODY>
                          </TABLE>
                          <TABLE width=450 border=0 align="center" cellPadding=0 cellSpacing=0>
                              <TBODY>
                                <TR>
                                  <TD background=../company/images/contents_dotline.gif height=5></TD>
                                </TR>
                              </TBODY>
                          </TABLE>
                          <TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
                              <TBODY>
                                <TR>
                                  <TD width="100%" height="30"><div align="center"><span class="style61">*</span> 确认用户名 ：
                                      <input name="newname1" type="text" style="width:200px;font-size:12px;border:0; border-bottom:1 solid #999999;" maxlength="20">
                                          <BR>
                                  </div></TD>
                                </TR>
                              </TBODY>
                          </TABLE>
                          <TABLE width=450 border=0 align="center" cellPadding=0 cellSpacing=0>
                              <TBODY>
                                <TR>
                                  <TD background=../company/images/contents_dotline.gif height=5></TD>
                                </TR>
                              </TBODY>
                          </TABLE>
                          <TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
                              <TBODY>
                                <TR>
                                  <TD width="100%" height="30"><div align="center">
                                      <input type="submit" name="Submit" value="确 定" style="width:60px;font-size:12px;">
                                    
                                    <input type="reset" name="botton2" value="清空" style="width:60px;font-size:12px;">
                                    <BR>
                                  </div></TD>
                                </TR>
                              </TBODY>
                          </TABLE>
                          <TABLE width=450 border=0 align="center" cellPadding=0 cellSpacing=0>
                              <TBODY>
                                <TR>
                                  <TD background=../company/images/contents_dotline.gif height=5></TD>
                                </TR>
                              </TBODY>
                          </TABLE></TD>
                      </TR>
                    </TBODY>
                  </TABLE>
              </form>
		  </td>
        </tr>
      </table>
   </td>
  </tr>
  <tr>
    <td background="images/m_13.gif"></td>
  </tr>
  <tr>
    <td><img src="images/m_12.gif" width="550" height="9"></td>
  </tr>
</table>
<%
	End If
%>
</body>
</html>