<!--#include file="conn.asp"-->
<!--#include file="md5.asp"-->
<title>DVBBS-kEY管理员钥匙工具</title>
<link rel="stylesheet" href="forum_admin.css" type="text/css">
<meta NAME=GENERATOR Content="Microsoft FrontPage 3.0" CHARSET=GB2312>
<BODY leftmargin="0" bottommargin="0" rightmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor="#DDEEFF">
<%
dim rs,sql
dim flag
flag="00,01,02,03,10,11,12,13,14,15,16,17,20,21,22,23,24,25,26,27,28,30,31,32,33,34,35,40,41,42,43,44,50,51,52,53,54,55,60,61,62,63,64,70,71,72,73,74,75"

dim groupsname,titlepic
set rs=conn.execute("select title from [UserGroups] where UserGroupID=1 ")
groupsname=rs(0)
set rs=conn.execute("select titlepic from usertitle where usergroupid=1 order by Minarticle desc")
titlepic=rs(0)
set rs=nothing

select case request("action")
case "newpsw"
	call newpsw()
case "changepsw"
	call changepsw()
case "openbbs"
	call openbbs()
case "saveedit"
	call saveedit()
case else
	call main()
end select
%>
</body>
</html>

<%
sub main()
%>
<p>　</p>
<p>　</p>
<table cellpadding="2" cellspacing="1" border="0" width="95%" class="tableBorder" align=center>
    <FORM METHOD=POST ACTION="?action=newpsw">
	<tr >
      <td width=20% height=28 class=forumrow>新建帐号</td>
      <td width=50% height=28 class=forumrow>重新建立新的管理员帐号</td>
	  <td width=30% height=28 class=forumrow valign="middle"><input type=submit name=submit value="新建帐号">
	  </td>
    </tr>
	</FORM>
	<FORM METHOD=POST ACTION="?action=changepsw">
    <tr>
      <td	  height=28 class=forumrow>修改密码</td>
      <td  height=28 class=forumrow>当管理员权限及密码丢失时,重新修改密码.</td>
	  	  <td width=30% height=28 class=forumrow valign="middle"><input type=submit name=submit value="修改密码">
</td>
    </tr>
	</FORM>
	<FORM METHOD=POST ACTION="?action=openbbs">
    <tr>
      <td  height=28 class=forumrow>开启论坛</td>
      <td  height=28 class=forumrow>论坛关闭快速开启功能</td>
	  	  <td width=30% height=28 class=forumrow valign="middle"><input type=submit name=submit value="开启论坛">
</td>
    </tr>
	</FORM>
	<FORM METHOD=POST ACTION="Ecookies.asp">
    <tr>
      <td  height=28 class=forumrow>清空cookies</td>
      <td  height=28 class=forumrow>清空您在本论坛的Cookies信息</td>
	  	  <td width=30% height=28 class=forumrow valign="middle"><input type=submit name=submit value="点击清除">
</td>
    </tr>
	</FORM>
    <tr>
      <td colspan=3 height=28 class=forumrow><font color=red><li>切记使用完毕后立刻删除此文件，不要留下后门哦！</font></td>
    </tr>
  </table>
<%
end sub

sub changepsw()
%>
	<FORM METHOD=POST ACTION="?action=saveedit">
<table cellpadding="2" cellspacing="1" border="0" width="95%" class="tableBorder" align=center>
    <tr>
      <th width="100%" height="19" colspan="2">请填写管理员修改资料</th>
    </tr>
  <tr>
    <td width="20%" height="24" class=forumrow align="right">
前台登陆名:</td>
    <td width="80%" height="24" class="forumRowHighlight"><INPUT TYPE="text" NAME="name1"></td>
    </tr>
<tr>
    <td  height="1" class=forumrow align="right">
新的前台登陆密码:</td>
    <td  height="1" class="forumRowHighlight"><INPUT TYPE="password" name=pass1>(长度不能大于10小于6)</td>
    </tr>
  <tr>
    <td  height="1" class=forumrow align="right">
新的后台登名:</td>
    <td  height="1" class="forumRowHighlight"><INPUT TYPE="text" NAME="name2"></td>
    </tr>
  <tr>
    <td  height="1" class=forumrow align="right">
新的后台登陆密码:</td>
    <td  height="1" class="forumRowHighlight"><INPUT TYPE="password" name=pass2>(长度不能大于10小于6)</td>
    </tr>
    <tr>
      <th  height="1" colspan="2" class="forumRow" align="center">
	  <input type="submit" value="提交" name="B1">&nbsp;&nbsp;<input type="reset" value="全部重写" name="B2">
</th>
    </tr>
  </table>
  	</FORM>
  <%
end sub

sub saveedit()
dim name1,name2,pass1,pass2
dim ars
name1=checkStr(trim(request.form("name1")))
name2=checkStr(trim(request.form("name2")))
pass1=checkStr(trim(request.form("pass1")))
pass2=checkStr(trim(request.form("pass2")))

if name1="" then
		response.write "<li>请输入已存在的前台登陆名字。<a href="&Request.ServerVariables("HTTP_REFERER")&"><<返回上一页</a>"
		exit sub
end if
if name2="" then
		response.write "<li>请输入管理员名字。<a href="&Request.ServerVariables("HTTP_REFERER")&"><<返回上一页</a>"
		exit sub
end if
if pass1="" or len(pass1)>10 or len(pass1)<6 then
		response.write "<li>请输入新的前台登陆密码,(长度不能大于10小于6)。<a href="&Request.ServerVariables("HTTP_REFERER")&"><<返回上一页</a>"
		exit sub
		else
		pass1=md5(pass1)
end if
if pass2="" or len(pass2)>10 or len(pass2)<6  then
		response.write "<li>请输入新的后台登陆密码,(长度不能大于10小于6)。<a href="&Request.ServerVariables("HTTP_REFERER")&"><<返回上一页</a>"
		exit sub
		else
		pass2=md5(pass2)
end if

set rs=conn.execute("select top 1 userid,UserName from [user] where UserName='"&name1&"' ")
	if rs.eof then
		response.write "<li>你所填写的用户名已不存在,请选择创新新帐号.。<a href=?><<返回</a>"
		exit sub
	else
		set ars=conn.execute("select top 1 * from admin where adduser='"&checkStr(trim(rs(1)))&"' ")
		if ars.eof  then
		conn.execute("insert into admin (username,[password],flag,adduser) values ('"&name2&"','"&pass2&"','"&flag&"','"&checkStr(trim(rs(1)))&"')")
		else
		conn.execute("update admin set [password]='"&pass2&"',flag='"&flag&"' where adduser='"&checkStr(trim(rs(1)))&"' ")
		end if

		conn.execute("update [user] set UserPassword='"&pass1&"',usergroupid=1,userclass='"&groupsname&"',titlepic='"&titlepic&"' where userid="&rs(0))
	end if
	response.write "<li>修改成功!请记好你的新密码。"
	rs.close
	set ars=nothing
	set rs=nothing

end sub

sub newpsw()
dim newname,pass
newname="admin888"
pass="admin888"
pass=md5(pass)

conn.execute("insert into [user] (UserName,UserPassword,usergroupid,userclass,titlepic) values ('"&newname&"','"&pass&"',1,'"&groupsname&"','"&titlepic&"')	")

conn.execute("insert into admin (username,[password],flag,adduser) values ('"&newname&"','"&pass&"','"&flag&"','"&newname&"')")
response.write "<li>创建帐号完成,用户名:admin888 , 密码:admin888"
end sub

sub openbbs()
dim setting
setting="0,300,1,1,0,1,1,1,40,lang_gb.asp,0,20,,,0,0,,,,0,30,0,40,0,1,0,9999,,1,0,1,1,1,1,1,1,0,1,32,32,0,10,1,,10,,1,1,1,1,0,0,0,1,0,1,500,120,,9,15,4,0,300,0,1,0,1,20,0,0|24,,"

conn.execute("update config set Forum_Setting='"&setting&"' where active=1 ")

response.write "论坛已经开启"
end sub



Rem 过滤SQL非法字符
function checkStr(str)
	if isnull(str) then
		checkStr = ""
		exit function 
	end if
	checkStr=replace(str,"'","''")
end function


conn.close
set conn=nothing
%>

