<!--#include file="conn.asp"-->
<!--#include file="user_chkpass.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/md5.asp"-->
<%

if CheckUserLogined()=False then
	response.Redirect "user_login.asp"
end if
dim action,password
action=trim(request.QueryString("action"))
if action="lock" then
	password=md5(trim(request("password")))
	conn.execute("update [user] set blog_password='"&password&"' where username='"&username&"'")
	conn.execute("update [blog] set blog_password='"&password&"' where username='"&username&"'")
	Response.Write"<script language=JavaScript>"
	Response.Write"alert(""设定密码成功！"");"
	Response.Write"window.history.go(-1);"
	Response.Write"</script>"
elseif action="unlock" then
	password=md5(trim(request("password")))
	conn.execute("update [user] set blog_password='' where username='"&username&"'")
	conn.execute("update [blog] set blog_password='' where username='"&username&"'")
	Response.Write"<script language=JavaScript>"
	Response.Write"alert(""解除密码成功！"");"
	Response.Write"window.history.go(-1);"
	Response.Write"</script>"
end if
%>
<link href="Admin_STYLE.CSS" rel="stylesheet" type="text/css">
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0" class="bgcolor">
<br>
<table width="98%"  border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
  <tr>
    <td height="25" class="topbg"><div align="center"><strong>整个blog站点的密码设定</strong></div></td>
  </tr>
  <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'">
    <td height="30" ><div align="center"><form name="form1" method="post" action="user_blogpassword.asp?action=lock" onSubmit='return Verify()'>
        <br>
        密码：
        <input type="password" name="password"> 
        <input type="submit" name="Submit" value="加密我的blog站点"> 

        (加上密码后，访问自己的blog需要通过密码验证。)       
        </form>
</div></td>
  </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'">
    <td height="30" ><div align="center">
	<form name="form2" method="post" action="user_blogpassword.asp?action=unlock">
      <br>
      <input type="submit" name="Submit" value="解除blog站点的密码保护">
	  </form>
    </div></td>
  </tr>
</table>
<SCRIPT language="javascript">
<!--
function del_space(s)
{
	for(i=0;i<s.length;++i)
	{
	 if(s.charAt(i)!=" ")
		break;
	}

	for(j=s.length-1;j>=0;--j)
	{
	 if(s.charAt(j)!=" ")
		break;
	}

	return s.substring(i,++j);
}

function Verify()
{
	v = del_space(document.form1.password.value);
     if (v.length == 0)
     {
        alert("密码不能为空!");
	return false;
     }
	
	return true;
}
//-->
</SCRIPT>

