<!--#include file="inc/inc_sys.asp"-->
<!--#include file="../inc/class_blog.asp"-->
<%
dim rs, sql
dim UserID,UserSearch,Keyword,strField
dim Action,FoundErr,ErrMsg
dim tmpDays
keyword=trim(request("keyword"))
if keyword<>"" then
	keyword=oblog.filt_badstr(keyword)
end if
strField=trim(request("Field"))
UserSearch=trim(request("UserSearch"))
Action=trim(request("Action"))
UserID=trim(Request("UserID"))
'ComeUrl=Request.ServerVariables("HTTP_REFERER")

if UserSearch="" then
	UserSearch=0
else
	UserSearch=Clng(UserSearch)
end if
G_P_FileName="admin_user.asp?UserSearch=" & UserSearch
if strField<>"" then
	G_P_FileName=G_P_FileName&"&Field="&strField
end if
if keyword<>"" then
	G_P_FileName=G_P_FileName&"&keyword="&keyword
end if
if request("page")<>"" then
	G_P_This=cint(request("page"))
else
	G_P_This=1
end if

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>注册用户管理</title>
<link rel="stylesheet" href="images/style.css" type="text/css" />
<script src="images/menu.js" type="text/javascript"></script>
</head>
<body>
<SCRIPT language=javascript>
function unselectall()
	{
	if(document.myform.chkAll.checked){
	document.myform.chkAll.checked = document.myform.chkAll.checked&0;
	} 	
	}

	function CheckAll(form)
	{
	for (var i=0;i<form.elements.length;i++)
	{
	var e = form.elements[i];
	if (e.Name != "chkAll")
	   e.checked = form.chkAll.checked;
	}
	}
</SCRIPT>
<div id="main_body" style= "display:none">
<ul class="main_top">
	<li class="main_top_left left">注 册 用 户 管 理</li>
	<li class="main_top_right right"> </li>
</ul>
<div class="main_content_rightbg">
	<div class="main_content_leftbg">



<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" Class="border">
<form name="form1" action="admin_user.asp" method="get">
<tr class="tdbg">
  <td width="100" height="30"><strong>快速查找用户：</strong></td>
  <td width="687" height="30"><select size=1 name="UserSearch" onChange="javascript:submit()">
	  <option value=>请选择查询条件</option>
	  <option value="0">最后注册的500个用户</option>
	  <option value="1">文章最多TOP100</option>
	  <option value="2">文章最少的100个用户</option>
	  <option value="3">VIP用户</option>
	  <option value="4">前台管理员</option>
	  <option value="5">推荐博客</option>
	  <option value="6">等待管理员认证的用户</option>
	  <option value="7">所有被锁住的用户</option>
	</select>
	&nbsp;&nbsp;&nbsp;&nbsp;<a href="admin_user.asp">用户管理首页</a>&nbsp;|&nbsp;<a href="../reg.asp" target="_blank">添加新用户</a></td>
</tr>
</form>
<form name="form2" method="post" action="admin_user.asp">
<tr class="tdbg">
<td width="120"><strong>用户高级查询：</strong></td>
<td >
  <select name="Field" id="Field">
  <option value="UserName" selected>用户名</option>
  <option value="UserID" >用户ID</option>
  <option value="nickname" >用户昵称</option>
  <option value="ip" >最后登录ip</option>
  <option value="blogname" >blog名称</option>
  <option value="lastlogintime" >多少天内未登录</option>
  <option value="logcount" >文章数小于</option>
  <option value="logintimes" >登录次数小于</option>
  </select>
  <input name="Keyword" type="text" id="Keyword" size="20" maxlength="30">
  <input type="submit" name="Submit2" value=" 查 询 ">
  <input name="UserSearch" type="hidden" id="UserSearch" value="10">
  若为空，则查询所有用户</td>
</tr>
</form>
</table>
	</div>
</div>
<ul class="main_end">
	<li class="main_end_left left"></li>
	<li class="main_end_right right"></li>
</ul>
</div>
<%
if Action="Add" then
'	call AddUser()
elseif Action="SaveAdd" then
'	call SaveAdd()
elseif Action="Modify" then
'	call Modify()
elseif Action="SaveModify" then
'	call SaveModify()
elseif Action="Del" then
'	call DelUser()
elseif Action="Lock" then
'	call LockUser()
elseif Action="UnLock" then
'	call UnLockUser()
elseif Action="Move" then
'	call MoveUser()
elseif Action="Update" then
call UpdateUser()
elseif Action="DoUpdate" then
call DoUpdate()
elseif Action="DoUpdatelog" then
call DoUpdatelog()
elseif Action="gouser1" then
'	call gouser1()
elseif Action="gouser2" then
'	call gouser2()
else
call UpdateUser()
end if
if FoundErr=true then
call WriteErrMsg()
end if

sub main()
	dim G_P_Guide
	G_P_Guide="<table width='100%'><tr><td align='left'>您现在的位置：<a href='admin_user.asp'>注册用户管理</a>&nbsp;&gt;&gt;&nbsp;"
	select case UserSearch
		case 0
			sql="select top 500 * from oblog_user order by UserID desc"
			G_P_Guide=G_P_Guide & "最后注册的500个用户"
		case 1
			sql="select top 100 * from oblog_user order by log_count desc"
			G_P_Guide=G_P_Guide & "发表日志最多的前100个用户"
		case 2
			sql="select top 100 * from  oblog_user order by log_count"
			G_P_Guide=G_P_Guide & "发表日志最少的100个用户"
		case 3
			sql="select * from  oblog_user where user_level=8 order by userid desc"
			G_P_Guide=G_P_Guide & "所有VIP用户"
		case 4
			sql="select * from  oblog_user where user_level=9 order by userid desc"
			G_P_Guide=G_P_Guide & "前台管理员"
		case 5
			sql="select * from  oblog_user where user_isbest=1 order by userid desc"
			G_P_Guide=G_P_Guide & "推荐博客"
		case 6
			sql="select * from oblog_user where User_Level=6 order by userID  desc"
			G_P_Guide=G_P_Guide & "等待管理认证证的用户"
		case 7
			sql="select * from oblog_user where  LockUser =1 order by userID  desc"
			G_P_Guide=G_P_Guide & "所有被锁住的用户"
		case 10
			if Keyword="" then
				sql="select top 500 * from oblog_user order by userID desc"
				G_P_Guide=G_P_Guide & "所有用户"
			else
				select case strField
				case "UserID"
					if IsNumeric(Keyword)=false then
						FoundErr=true
						ErrMsg=ErrMsg & "<br><li>用户ID必须是整数！</li>"
					else
						sql="select * from oblog_user where userID =" & Clng(Keyword)
						G_P_Guide=G_P_Guide & "用户ID等于<font color=red> " & Clng(Keyword) & " </font>的用户"
					end if
				case "UserName"
					if is_sqldata=1 then
						sql="select * from oblog_user where username like '%" & Keyword & "%' order by userID  desc"
						G_P_Guide=G_P_Guide & "用户名中含有“ <font color=red>" & Keyword & "</font> ”的用户"
					else
						sql="select * from oblog_user where username= '" & Keyword & "' order by userID  desc"
						G_P_Guide=G_P_Guide & "用户名等于“ <font color=red>" & Keyword & "</font> ”的用户"
					end if
					
				case "nickname"
					if is_sqldata=1 then
						sql="select * from oblog_user where nickname like '%" & Keyword & "%' order by userID  desc"
						G_P_Guide=G_P_Guide & "用户昵称中含有“ <font color=red>" & Keyword & "</font> ”的用户"
					else
						sql="select * from oblog_user where nickname='" & Keyword & "' order by userID  desc"
						G_P_Guide=G_P_Guide & "用户昵称等于“ <font color=red>" & Keyword & "</font> ”的用户"
					end if
				case "ip"
					if is_sqldata=1 then
						sql="select * from oblog_user where lastloginip like '%" & Keyword & "%' order by userID  desc"
						G_P_Guide=G_P_Guide & "最后登录ip中含有“ <font color=red>" & Keyword & "</font> ”的用户"
					else
						sql="select * from oblog_user where lastloginip='" & Keyword & "' order by userID  desc"
						G_P_Guide=G_P_Guide & "最后登录ip等于“ <font color=red>" & Keyword & "</font> ”的用户"
					end if
				case "blogname"
					if is_sqldata=1 then
						sql="select * from oblog_user where blogname like '%" & Keyword & "%' order by userID  desc"
						G_P_Guide=G_P_Guide & "blog名中含有“ <font color=red>" & Keyword & "</font> ”的用户"
					else
						sql="select * from oblog_user where blogname='" & Keyword & "' order by userID  desc"
						G_P_Guide=G_P_Guide & "blog名等于“ <font color=red>" & Keyword & "</font> ”的用户"
					end if
				case "logcount"
					sql="select top 500 * from oblog_user where log_count < " & clng(Keyword) & " order by userID  desc"
					G_P_Guide=G_P_Guide & "文章数小于“ <font color=red>" & Keyword & "</font> ”的用户"
				case "logintimes"
					sql="select top 500 * from oblog_user where logintimes < " & clng(Keyword) & " order by userID  desc"
					G_P_Guide=G_P_Guide & "登录次数小于“ <font color=red>" & Keyword & "</font> ”的用户"
				case "lastlogintime"
				   If is_sqldata=1 Then
					sql="select top 500 * from oblog_user where datediff(d,lastlogintime,getdate())>"&clng(Keyword)&" order by userID  desc"
				   Else
					sql="select top 500 * from oblog_user where datediff('d',lastlogintime,now())>"&clng(Keyword)&" order by userID  desc"
				   End If
					G_P_Guide=G_P_Guide & "“ <font color=red>" & Keyword & "</font> ”天内未登录的用户"
				end select
			end if
		case else
			FoundErr=true
			ErrMsg=ErrMsg & "<br><li>错误的参数！</li>"
	end select
	G_P_Guide=G_P_Guide & "</td><td align='right'>"
	if FoundErr=true then exit sub
	if not IsObject(conn) then link_database
	Set rs=Server.CreateObject("Adodb.RecordSet")
	rs.Open sql,Conn,1,1
	if rs.eof and rs.bof then
		G_P_Guide=G_P_Guide & "共找到 <font color=red>0</font> 个用户</td></tr></table>"
		response.write G_P_Guide
	else
		G_P_AllRecords=rs.recordcount
		G_P_Guide=G_P_Guide & "共找到 <font color=red>" & G_P_AllRecords & "</font> 个用户</td></tr></table>"
		response.write G_P_Guide
		if G_P_This<1 then
			G_P_This=1
		end if
		if (G_P_This-1)*G_P_PerMax>G_P_AllRecords then
			if (G_P_AllRecords mod G_P_PerMax)=0 then
				G_P_This= G_P_AllRecords \ G_P_PerMax
			else
				G_P_This= G_P_AllRecords \ G_P_PerMax + 1
			end if

		end if
		if G_P_This=1 then
			showContent
			response.write oblog.showpage(true,true,"个用户")
		else
			if (G_P_This-1)*G_P_PerMax<G_P_AllRecords then
				rs.move  (G_P_This-1)*G_P_PerMax
				dim bookmark
				bookmark=rs.bookmark
				showContent
				response.write oblog.showpage(true,true,"个用户")
			else
				G_P_This=1
				showContent
				response.write oblog.showpage(true,true,"个用户")
			end if
		end if
	end if
	rs.Close
	set rs=Nothing
end sub

sub showContent()
	dim i
	i=0
	%>
	<div id="main_body">
	<ul class="main_top">
		<li class="main_top_left left">注 册 用 户 管 理</li>
		<li class="main_top_right right"> </li>
	</ul>
	<div class="main_content_rightbg">
		<div class="main_content_leftbg">
	<form name="myform" method="Post" action="admin_user.asp" onsubmit="return confirm('确定要执行选定的操作吗？');">
	<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
		  <tr class="title">
			<td width="30" align="center"><font style="color:#000;font-weight:600;">选中</font></td>
			<td width="30" align="center"><font style="color:#000;font-weight:600;">ID</font></td>
			<td width="80" height="22" align="center"><font style="color:#000;font-weight:600;"> 用户名</font></td>
			<td height="22" align="center"><font style="color:#000;font-weight:600;">所属用户组</font></td>
			<td height="22" align="center"><font style="color:#000;font-weight:600;">最后登录IP</font></td>
			<td align="center"><font style="color:#000;font-weight:600;">最后登录时间</font></td>
			<td width="60" height="22" align="center"><font style="color:#000;font-weight:600;">登录次数</font></td>
			<td width="40" height="22" align="center"><font style="color:#000;font-weight:600;"> 状态</font></td>
			<td width="120" height="22" align="center"><font style="color:#000;font-weight:600;">
			  操作</font></td>
		  </tr>
		  <%do while not rs.EOF %>
		  <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'">
			<td width="30" align="center"><input name='UserID' type='checkbox' onclick="unselectall()" id="UserID" value='<%=cstr(rs("userID"))%>'></td>
			<td width="30" align="center"><%=rs("userID")%></td>
			<td width="80" align="center"><%
			response.write "<a href='../blog.asp?name=" & rs("userName") & "'" 			
			response.write """ target='_blank'>" & rs("userName") & "</a>"
			%> </td>
			<td align="center"> <%
			select case rs("User_Level")
				case 6
					response.write "<font color=green>等待管理员认证的用户</font>"
				case 7
					response.write "普通注册用户"
				case 8
					response.write "<font color=blue>VIP用户</font>"
				case 9
					response.write "<font color=blue>前台管理员</font>"
				case else
					response.write "<font color=red>异常用户</font>"
			end select
			%> </td>
			<td align="center"> <%
	if rs("LastLoginIP")<>"" then
		response.write rs("LastLoginIP")
	else
		response.write "&nbsp;"
	end if
	%> </td>
			<td align="center"> <%
	if rs("LastLoginTime")<>"" then
		response.write rs("LastLoginTime")
	else
		response.write "&nbsp;"
	end if
	%> </td>
			<td width="60" align="center"> <%
	if rs("LoginTimes")<>"" then
		response.write rs("LoginTimes")
	else
		response.write "0"
	end if
	%> </td>
			<td width="40" align="center"><%
	  if rs("LockUser")=1 then
		response.write "<font color=red>已锁定</font>"
	  else
		response.write "正常"
	  end if
	  %></td>
			<td width="120" align="center"><%
		response.write "<a href='admin_user.asp?Action=Modify&UserID=" & rs("userID") & "'>修改</a>&nbsp;"
		response.write "<a href='admin_user.asp?Action=gouser2&username=" & rs("username") & "' target='blank'>进后台</a>&nbsp;"
		if rs("LockUser")=0 then
			response.write "<a href='admin_user.asp?Action=Lock&UserID=" & rs("userID") & "'>锁定</a>&nbsp;"
		else
			response.write "<a href='admin_user.asp?Action=UnLock&UserID=" & rs("userID") & "'>解锁</a>&nbsp;"
		end if
		response.write "<a href='admin_user.asp?Action=Del&UserID=" & rs("userID") & "' onClick='return confirm(""确定要删除此用户吗？"");'>删除</a>&nbsp;"
		%> </td>
		  </tr>
		  <%
	i=i+1
	if i>=G_P_PerMax then exit do
	rs.movenext
	loop
	%>
	</table>
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td width="200" height="30"><input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
			  选中本页显示的所有用户</td>
			<td> <strong>操作：</strong>
			  <input name="Action" type="radio" value="Del" checked onClick="document.myform.User_Level.disabled=true">
			  删除&nbsp;&nbsp;&nbsp;&nbsp;
			  <input name="Action" type="radio" value="Move" onClick="document.myform.User_Level.disabled=false">移动到
			  <select name="User_Level" id="User_Level" disabled>
				<option value="6">等待管理审核的用户</option>
				<option value="7">注册用户</option>
				<option value="8">VIP用户</option>
				<option value="9">前台管理员</option>
			  </select>
			  &nbsp;&nbsp;
			  <input type="submit" name="Submit" value=" 执 行 "> </td>
	</tr>
	</table>
	</form>
		</div>
	</div>
	<ul class="main_end">
		<li class="main_end_left left"></li>
		<li class="main_end_right right"></li>
	</ul>
	</div>
	<%
end sub


sub Modify()
	dim UserID
	dim rsUser,sqlUser
	UserID=trim(request("UserID"))
	if UserID="" then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>参数不足！</li>"
		exit sub
	else
		UserID=Clng(UserID)
	end if
	Set rsUser=Server.CreateObject("Adodb.RecordSet")
	sqlUser="select * from oblog_user where userID=" & UserID
	if not IsObject(conn) then link_database
	rsUser.Open sqlUser,Conn,1,3
	if rsUser.bof and rsUser.eof then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>找不到指定的用户！</li>"
		rsUser.close
		set rsUser=nothing
		exit sub
	end if
	%>
	<div id="main_body">
	<ul class="main_top">
		<li class="main_top_left left">修改注册用户信息</li>
		<li class="main_top_right right"> </li>
	</ul>
	<div class="main_content_rightbg">
		<div class="main_content_leftbg">
	<FORM name="Form1" action="admin_user.asp" method="post">
	<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
	<TR class='title'>
	  <TD height=22 colSpan=2 align="center"><b><font color="#FFFFFF">修改注册用户信息</font></b></TD>
	</TR>
	<TR class="tdbg" >
	  <TD width="40%">用户名：</TD>
	  <TD width="60%"><%=rsUser("userName")%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
	</TR>
	<tr class="tdbg" onmouseover="this.style.backgroundColor='#BFDFFF'" onmouseout="this.style.backgroundColor=''">
	  <td>用户域名：</td>
	  <td><input name="user_domain" type="text" value="<%=oblog.filt_html(rsuser("user_domain"))%>" size=10 maxlength=20 /> <select name="user_domainroot" ><%=oblog.type_domainroot(rsuser("user_domainroot"))%></select></td>
	</tr>
	<tr class="tdbg" onmouseover="this.style.backgroundColor='#BFDFFF'" onmouseout="this.style.backgroundColor=''">
	  <td>blog名：</td>
	  <td><input name=blogname   type=text id="blogname" value="<%=rsuser("blogname")%>" size=30 maxlength=20></td>
	</tr>
	<%if true_domain=1 then%>
	<tr class="tdbg" onMouseOver="this.style.backgroundColor='#BFDFFF'" onMouseOut="this.style.backgroundColor=''">
	  <td>用户绑定的顶级域名：</td>
	  <td><input name=custom_domain   type=text id="custom_domain" value="<%=rsuser("custom_domain")%>" size=30 maxlength=20></td>
	</tr>
	<%end if%>
	<tr class="tdbg" onmouseover="this.style.backgroundColor='#BFDFFF'" onmouseout="this.style.backgroundColor=''">
	  <td>blog类别：</td>
	  <td><select name="usertype" id="usertype">
		  <%if rsUser("user_classid")<>"" then
	  response.Write(oblog.show_class("user",rsUser("user_classid"),0))
	  else
	  response.Write(oblog.show_class("user",0,0))
	  end if
	  %>
		</select></td>
	</tr>
	<TR class="tdbg" >
	  <TD width="40%">密码(至少6位)：<BR>
		请输入密码，区分大小写。 请不要使用任何类似 '*'、' ' 或 HTML 字符 </TD>
	  <TD width="60%"> <INPUT   type=password maxLength=16 size=30 name=Password> <font color="#FF0000">如果不想修改，请留空(整合用户请到论坛修改)</font> </TD>
	</TR>
	<TR class="tdbg" >
	  <TD>确认密码(至少6位)：<br>
		请再输一遍确认</TD>
	  <TD><INPUT name=PwdConfirm   type=password id="PwdConfirm" size=30 maxLength=12> <font color="#FF0000">如果不想修改，请留空(整合用户请到论坛修改)</font> </TD>
	</TR>
	<TR class="tdbg" >
	  <TD width="40%">密码问题：<br>
		忘记密码的提示问题</TD>
	  <TD width="60%"> <INPUT name="Question"   type=text value="<%=rsUser("Question")%>" size=30>(整合用户请到论坛修改)
	  </TD>
	</TR>
	<TR class="tdbg" >
	  <TD width="40%">问题答案：<BR>
		忘记密码的提示问题答案，用于取回密码</TD>
	  <TD width="60%"> <INPUT   type=text size=30 name="Answer"> <font color="#FF0000">如果不想修改，请留空(整合用户请到论坛修改)</font></TD>
	</TR>
	<TR class="tdbg" >
	  <TD width="40%">性别：</TD>
	  <TD width="60%"> <INPUT type=radio value="1" name=sex <%if rsUser("Sex")=1 then response.write "CHECKED"%>>
		男 &nbsp;&nbsp; <INPUT type=radio value="0" name=sex <%if rsUser("Sex")=0 then response.write "CHECKED"%>>
		女</TD>
	</TR>
	<TR class="tdbg" >
	  <TD width="40%">Email地址：</TD>
	  <TD width="60%"> <INPUT name=Email value="<%=rsUser("userEmail")%>" size=30   maxLength=50>
		<a href="mailto:<%=rsUser("userEmail")%>">给此用户发一封电子邮件</a>
	  </TD>
	</TR>
	<TR class="tdbg" >
	  <TD width="40%">OICQ号码：</TD>
	  <TD width="60%"> <INPUT name=OICQ value="<%=rsUser("qq")%>" size=30 maxLength=20></TD>
	</TR>
	<TR class="tdbg" >
	  <TD width="40%">MSN：</TD>
	  <TD width="60%"> <INPUT name=msn value="<%=rsUser("Msn")%>" size=30 maxLength=50></TD>
	</TR>
	<TR class="tdbg" >
	  <TD width="40%">用户级别：</TD>
	  <TD width="60%"><select name="User_Level" id="User_Level">
		  <option value="6" <%if clng(rsUser("user_level"))=6 then response.Write("selected")%>>等待管理审核的用户</option>
		  <option value="7" <%if clng(rsUser("user_level"))=7 then response.Write("selected")%>>注册用户</option>
		  <option value="8" <%if clng(rsUser("user_level"))=8 then response.Write("selected")%>>vip用户</option>
		  <option value="9" <%if clng(rsUser("user_level"))=9 then response.Write("selected")%>>前台管理员</option>
		</select></TD>
	</TR>
	<tr class="tdbg" onmouseover="this.style.backgroundColor='#BFDFFF'" onmouseout="this.style.backgroundColor=''">
	  <td>可上传空间(kb)：</td>
	  <td><input name=user_upfiles_max   type=text value="<%=rsuser("user_upfiles_max")%>" size=20 maxlength=20>
		为零时为系统默认设置，如需单独设置，请输入kb值</td>
	</tr>
	<tr class="tdbg" onmouseover="this.style.backgroundColor='#BFDFFF'" onmouseout="this.style.backgroundColor=''">
	  <td>已上传字节(字节)：</td>
	  <td><input name=upfiles_size   type=text id="upfiles_size" value="<%=rsuser("user_upfiles_size")%>" size=20 maxlength=20></td>
	</tr>
	<TR class="tdbg" >
	  <TD>是否为推荐博客：</TD>
	  <TD><input type="radio" name="isbest" value=1 <%if rsUser("user_isbest")=1 then response.write "checked"%>>
		是 &nbsp;&nbsp; <input type="radio" name="isbest" value=0 <%if rsUser("user_isbest")<>1 then response.write "checked"%>>
		否</TD>
	</TR>
	<TR class="tdbg" >
	  <TD width="40%">用户目录：</TD>
	  <TD width="60%"> <INPUT name=user_dir value="<%=rsUser("user_dir")%>" size=30 maxLength=50>
		如无必要请不要修改，否则将造成用户目录混乱</TD>
	</TR>
	<TR class="tdbg" >
	  <TD width="40%">用户状态：</TD>
	  <TD width="60%"><input type="radio" name="LockUser" value=0 <%if rsUser("LockUser")=0 then response.write "checked"%>>
		正常&nbsp;&nbsp; <input type="radio" name="LockUser" value=1 <%if rsUser("LockUser")=1 then response.write "checked"%>>
		锁定</TD>
	</TR>
	<TR class="tdbg" >
	  <TD height="40" colspan="2" align="center"><input name="Action" type="hidden" id="Action" value="SaveModify"> <input name=Submit   type=submit id="Submit" value="保存修改结果"> <input name="UserID" type="hidden" id="UserID" value="<%=rsUser("userID")%>"></TD>
	</TR>
	</TABLE>
	</form>
		</div>
	</div>
	<ul class="main_end">
		<li class="main_end_left left"></li>
		<li class="main_end_right right"></li>
	</ul>
	</div>
	<%
	rsUser.close
	set rsUser=nothing
end sub


sub UpdateUser()
	%>
	<div id="main_body">
	<ul class="main_top">
		<li class="main_top_left left">更新用户静态页面</li>
		<li class="main_top_right right"> </li>
	</ul>
	<div class="main_content_rightbg">
		<div class="main_content_leftbg">
	<FORM name="Form1" action="admin_user.asp?action=DoUpdate" method="post">
	<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
	<tr class="tdbg">
	  <td colspan="2"><p>说明：<br>
		  1、本操作将重新生成用户静态页面。<br>
		  2、本操作可能将非常消耗服务器资源，而且更新时间很长，请仔细确认每一步操作后执行。<br>
	  3 、本操作根据用户ｉｄ更新。 </p>
	  </td>
	</tr>
	<tr class="tdbg">
	<td height="25">开始用户ID：</td>
	<td height="25"><input name="BeginID" type="text" id="BeginID" value="1" size="10" maxlength="10">
	  用户ID，可以填写您想从哪一个ID号开始进行更新</td>
	</tr>
	<tr class="tdbg">
	<td height="25">结束用户ID：</td>
	<td height="25"><input name="EndID" type="text" id="EndID" value="1000" size="10" maxlength="10">
	  将更新开始到结束ID之间的用户数据，之间的数值最好不要选择过大</td>
	</tr>
	<tr class="tdbg">
	<td height="25">&nbsp;</td>
	<td height="25"><input name="Submit" type="submit" id="Submit" value="生成静态页面"></td>
	</tr>
	</table>
	</form>
		</div>
	</div>
	<ul class="main_end">
		<li class="main_end_left left"></li>
		<li class="main_end_right right"></li>
	</ul>
	</div>

	<div id="main_body">
	<ul class="main_top">
		<li class="main_top_left left">更新日志静态页面</li>
		<li class="main_top_right right"> </li>
	</ul>
	<div class="main_content_rightbg">
		<div class="main_content_leftbg">
	<FORM name="Form1" action="admin_user.asp?action=DoUpdatelog" method="post">
	<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
	<tr class="tdbg">
	  <td colspan="2"><p>说明：<br>
		  1、本操作将重新生成用户静态页面。<br>
		  2、本操作可能将非常消耗服务器资源，而且更新时间很长，请仔细确认每一步操作后执行。<br>
	  3、本操作根据日志ｉｄ更新。</p>
	  </td>
	</tr>
	<tr class="tdbg">
	<td height="25">开始日志ID：</td>
	<td height="25"><input name="BeginID" type="text" id="BeginID" value="1" size="10" maxlength="10">
	  用户ID，可以填写您想从哪一个ID号开始进行更新</td>
	</tr>
	<tr class="tdbg">
	<td height="25">结束日志ID：</td>
	<td height="25"><input name="EndID" type="text" id="EndID" value="1000" size="10" maxlength="10">
	  将更新开始到结束ID之间的日志页面，之间的数值最好不要选择过大</td>
	</tr>
	<tr class="tdbg">
	<td height="25">&nbsp;</td>
	<td height="25"><input name="Submit" type="submit" id="Submit" value="生成日志静态页面"></td>
	</tr>
	</table>
	</form>
		</div>
	</div>
	<ul class="main_end">
		<li class="main_end_left left"></li>
		<li class="main_end_right right"></li>
	</ul>
	</div>
	<%
end sub

sub gouser1()
	%>
	<div id="main_body">
	<ul class="main_top">
		<li class="main_top_left left">登录到用户管理后台</li>
		<li class="main_top_right right"> </li>
	</ul>
	<div class="main_content_rightbg">
		<div class="main_content_leftbg">
	<FORM name="Form1" action="admin_user.asp?action=gouser2" method="post" target="_blank">
	<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
	<tr class="tdbg">
	  <td colspan="2"><p>说明：<br>
		  本操作供管理员登录到用户的管理界面进行管理。<br>
		  当用户操作出现障碍时，可进入该用户后台，协助用户进行操作。<br>
		</p>
	  </td>
	</tr>
	<tr class="tdbg">
	<td height="25">用户账号：</td>
	<td height="25"><input name="username" type="text" id="username" value="" size="30" maxlength="50"></td>
	<tr class="tdbg">
	<td height="25">&nbsp;</td>
	<td height="25"><input name="Submit" type="submit" id="Submit" value=" 提交 "></td>
	</tr>
	</table>
	</form>
		</div>
	</div>
	<ul class="main_end">
		<li class="main_end_left left"></li>
		<li class="main_end_right right"></li>
	</ul>
	</div>
	<%
end sub
	%>
	</body>
	</html>
<%
sub gouser2()
	dim rs,username
	username=oblog.filt_badstr(trim(request("username")))
	if username="" then response.Write("用户名不能为空"):response.End()
	set rs=oblog.execute("select username,password from oblog_user where username='"&username&"'")
	if not rs.eof then
		oblog.SaveCookie rs(0), rs(1), 0, ""
		set rs=nothing
		response.Redirect("../user_index.asp")
	else
		set rs=nothing
		response.Write("无此用户"):response.End()
	end if

end sub
sub SaveModify()
	dim UserID,Password,PwdConfirm,Question,Answer,Sex,Email,Homepage,OICQ,MSN,User_Level,LockUser,isbest
	dim rsUser,sqlUser
	dim blogname,usertype,user_upfiles_max,upfiles_size,user_domain,user_domainroot
	Action=trim(request("Action"))
	UserID=trim(request("UserID"))
	if UserID="" then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>参数不足！</li>"
		exit sub
	else
		UserID=Clng(UserID)
	end if
	Password=trim(request("Password"))
	PwdConfirm=trim(request("PwdConfirm"))
	Question=trim(request("Question"))
	Answer=trim(request("Answer"))
	Sex=trim(Request("Sex"))
	Email=trim(request("Email"))
	Homepage=trim(request("Homepage"))
	OICQ=trim(request("OICQ"))
	MSN=trim(request("MSN"))
	User_Level=trim(request("User_Level"))
	isbest=trim(request("isbest"))
	LockUser=trim(request("LockUser"))
	blogname=trim(request("blogname"))
	usertype=trim(request("usertype"))
	user_upfiles_max=trim(request("user_upfiles_max"))
	upfiles_size=trim(request("upfiles_size"))
	user_domain=trim(request("user_domain"))
	user_domainroot=trim(request("user_domainroot"))

		if Password<>"" then
			if oblog.strLength(Password)>12 or oblog.strLength(Password)<6 then
				founderr=true
				errmsg=errmsg & "<br><li>密码不能大于12小于6，如果你不想修改密码，请保持为空。</li>"
			end if
			if Instr(Password,"=")>0 or Instr(Password,"%")>0 or Instr(Password,chr(32))>0 or Instr(Password,"?")>0 or Instr(Password,"&")>0 or Instr(Password,";")>0 or Instr(Password,",")>0 or Instr(Password,"'")>0 or Instr(Password,",")>0 or Instr(Password,chr(34))>0 or Instr(Password,chr(9))>0 or Instr(Password,"")>0 or Instr(Password,"$")>0 then
				errmsg=errmsg+"<br><li>密码中含有非法字符，如果你不想修改密码，请保持为空。</li>"
				founderr=true
			end if
		end if
		if Password<>PwdConfirm then
			founderr=true
			errmsg=errmsg & "<br><li>密码和确认密码不一致</li>"
		end if
		if Question="" then
			founderr=true
			errmsg=errmsg & "<br><li>密码提示问题不能为空</li>"
		end if

	if Sex="" then
		founderr=true
		errmsg=errmsg & "<br><li>性别不能为空</li>"
	else
		sex=cint(sex)
		if Sex<>0 and Sex<>1 then
			Sex=1
		end if
	end if

		if Email="" then
			founderr=true
			errmsg=errmsg & "<br><li>Email不能为空</li>"
		else
			if oblog.IsValidEmail(Email)=false then
				errmsg=errmsg & "<br><li>您的Email有错误</li>"
				founderr=true
			end if
		end if

	if OICQ<>"" then
		if not isnumeric(OICQ) or len(cstr(OICQ))>10 then
			errmsg=errmsg & "<br><li>OICQ号码只能是4-10位数字，您可以选择不输入。</li>"
			founderr=true
		end if
	end if
	if MSN<>"" then
		if oblog.IsValidEmail(MSN)=false then
			errmsg=errmsg & "<br><li>你的MSN有误。</li>"
			founderr=true
		end if
	end if

	if User_Level="" then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>请指定用户级别！</li>"
	else
		User_Level=CLng(User_Level)
	end if
	if trim(oblog.setup(4,0))<>"" and oblog.setup(12,0)=1 then
		set rsuser=oblog.execute("select userid from oblog_user where user_domain='"&oblog.filt_badstr(user_domain)&"' and user_domainroot='"&oblog.filt_badstr(user_domainroot)&"' and userid<>"&userid)
		if not rsuser.eof then
			FoundErr=true
			ErrMsg=ErrMsg & "<br><li>此域名已经被其他人使用！</li>"
		end if
	end if

	if founderr=true then
		set rsuser=nothing
		exit sub
	end if

	Set rsUser=Server.CreateObject("Adodb.RecordSet")
	sqlUser="select * from oblog_user where userID=" & UserID
	if not IsObject(conn) then link_database
	rsUser.Open sqlUser,Conn,1,3
	if rsUser.bof and rsUser.eof then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>找不到指定的用户！</li>"
		rsUser.close
		set rsUser=nothing
		exit sub
	end if
	if Password<>"" then
		rsUser("password")=md5(Password)
	end if
	rsUser("Question")=Question
	if Answer<>"" then
		rsUser("Answer")=md5(Answer)
	end if
	rsUser("Sex")=Sex
	rsUser("userEmail")=Email
	if oicq="" then
		oicq=0
	end if
	rsUser("qq")=OICQ
	rsUser("Msn")=MSN
	rsUser("User_Level")=User_Level
	rsUser("LockUser")=LockUser
	rsuser("user_isbest")=isbest
	rsuser("blogname")=blogname
	rsuser("user_classid")=usertype
	rsuser("user_upfiles_max")=user_upfiles_max
	rsuser("user_upfiles_size")=upfiles_size
	rsuser("user_dir")=trim(request("user_dir"))
	if true_domain=1 then
		rsuser("custom_domain")=trim(request("custom_domain"))
	end if
	if trim(request("user_domain"))<>"" then
		rsuser("user_domain")=trim(request("user_domain"))
	else
		rsuser("user_domain")=" "
	end if
	rsuser("user_domainroot")=trim(request("user_domainroot"))
	rsUser.update
	rsUser.Close
	set rsUser=nothing
	oblog.showok "修改成功!",""
end sub


sub DelUser()
	dim rs,i
	if UserID="" then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>请指定要删除的用户</li>"
		exit sub
	end if
	if instr(UserID,",")>0 then
		UserID=split(UserID,",")
		for i=0 to ubound(userid)
			deloneuser(userid(i))
		next
	else
		deloneuser(userid)
	end if
	response.redirect "admin_user.asp"
	end sub

	sub deloneuser(userid)
	userid=clng(userid)
	dim rs,fso,f,uname,udir
	set rs=oblog.execute("select user_dir,username,user_folder from oblog_user where userid="&userid)
	if not rs.eof then
		udir=rs(0)
		uname=rs(1)
		set fso=server.createobject("scripting.filesystemobject")
		if fso.FolderExists(server.MapPath(blogdir & udir&"/"&rs("user_folder"))) then
			Set f = fso.GetFolder(server.MapPath(blogdir & udir&"/"&rs("user_folder")))
			f.delete true
		end if
		set f=nothing
		set fso=nothing
		oblog.execute("delete from oblog_log where userid="&userid)
		oblog.execute("delete from oblog_comment where userid="&userid)
		oblog.execute("delete from oblog_message where userid="&userid)
		oblog.execute("delete from oblog_subject where userid="&userid)
		oblog.execute("delete from oblog_user where userid=" & userid)
		oblog.execute("delete from oblog_upfile where userid=" & userid)
		oblog.execute("delete from oblog_friend where userid=" & userid)
		oblog.execute("update oblog_pm set dels=1 where sender='" &uname&"'")
	end if
	set rs=nothing
end sub

sub LockUser()
	dim rs,udir
	if UserID="" then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>请选择要锁定的用户</li>"
		exit sub
	end if
	userid=clng(userid)
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select lockuser,user_dir from oblog_user where userid="&userid,conn,1,3
	if not rs.eof then
		dim strtmp,fso
		rs(0)=1
		udir=rs(1)
		rs.update
		strtmp="<script language=javascript>"&vbcrlf
		strtmp=strtmp&" window.location.replace('"&blogdir&"err.asp?message=此用户已经被锁定，请联系管理员!');"&vbcrlf
		strtmp=strtmp&"</script>"&vbcrlf
		if udir<>"" then
		set fso=server.createobject("scripting.filesystemobject")
			udir=server.MapPath(udir)
			if fso.FolderExists(udir&"/"&userid&"/inc") then
				Call oblog.BuildFile(udir&"/"&userid&"/inc/chkblogpassword.htm",strtmp)								
			end if
			set fso=nothing
		end if
	end if
	rs.close
	set rs=nothing
	oblog.showok "锁定用户成功",""
	end sub

	sub UnLockUser()
	dim rs,udir
	if UserID="" then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>请选择要锁定的用户</li>"
		exit sub
	end if
	userid=clng(userid)
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select lockuser,user_dir from oblog_user where userid="&userid,conn,1,3
	if not rs.eof then
		dim strtmp,fso
		rs(0)=0
		udir=rs(1)
		rs.update
		strtmp=" "
		if udir<>"" then
		set fso=server.createobject("scripting.filesystemobject")
			udir=server.MapPath(udir)
			if fso.FolderExists(udir&"/"&userid&"/inc") then
				Call oblog.BuildFile(udir&"/"&userid&"/inc/chkblogpassword.htm",strtmp)				
			end if			
			set fso=nothing
		end if
	end if
	rs.close
	set rs=nothing
	oblog.showok "解锁用户成功",""
	end sub

	sub MoveUser()
	dim msg
	if UserID="" then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>请指定要移动的用户</li>"
		exit sub
	end if
	dim User_Level
	User_Level=trim(request("User_Level"))
	if User_Level="" then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>请指定目标用户组</li>"
		exit sub
	else
		User_Level=Clng(User_Level)
	end if
	if instr(UserID,",")>0 then
		UserID=replace(UserID," ","")
		if User_Level=6 then
			msg="&nbsp;&nbsp;&nbsp;&nbsp;已经成功将选定用户设为“<font color=blue>等待管理审核的用户</font>”！"
			sql="Update oblog_user set User_Level=6 where userID in (" & UserID & ")"
		elseif User_Level=7 then
			msg="&nbsp;&nbsp;&nbsp;&nbsp;已经成功将选定用户设为“<font color=blue>普通注册用户</font>”！"
			sql="Update oblog_user set User_Level=7 where userID in (" & UserID & ")"
		elseif User_Level=8 then
			msg="&nbsp;&nbsp;&nbsp;&nbsp;已经成功将选定用户设为“<font color=blue>VIP用户</font>”！"
			sql="Update oblog_user set User_Level=8 where userID in (" & UserID & ")"
		elseif User_Level=9 then
			msg="&nbsp;&nbsp;&nbsp;&nbsp;已经成功将选定用户设为“<font color=blue>前台管理员</font>”！"
			sql="Update oblog_user set User_Level=9 where userID in (" & UserID & ")"
		end if
	else
		if User_Level=6 then
			msg="&nbsp;&nbsp;&nbsp;&nbsp;已经成功将选定用户设为“<font color=blue>等待管理审核的用户</font>”！"
			sql="Update oblog_user set User_Level=6 where userID=" & UserID
		elseif User_Level=7 then
			msg="&nbsp;&nbsp;&nbsp;&nbsp;已经成功将选定用户设为“<font color=blue>普通注册用户</font>”！"
			sql="Update oblog_user set User_Level=7 where userID="& UserID
		elseif User_Level=8 then
			msg="&nbsp;&nbsp;&nbsp;&nbsp;已经成功将选定用户设为“<font color=blue>VIP用户</font>”！"
			sql="Update oblog_user set User_Level=8 where userID=" & UserID
		elseif User_Level=9 then
			msg="&nbsp;&nbsp;&nbsp;&nbsp;已经成功将选定用户设为“<font color=blue>前台管理员</font>”！"
			sql="Update oblog_user set User_Level=9 where userID=" & UserID
		end if
	end if
	Conn.Execute sql
	response.Redirect "admin_user.asp"
	'call WriteSuccessMsg(msg)
end sub

sub DoUpdate()
	Server.ScriptTimeOut=999999999
	dim BeginID,EndID,p1,rsUser,blog,i
	BeginID=trim(request("BeginID"))
	EndID=trim(request("EndID"))
	if BeginID="" then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>请指定开始ID</li>"
	else
		BeginID=Clng(BeginID)
	end if
	if EndID="" then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>请指定结束ID</li>"
	else
		EndID=Clng(EndID)
	end if
	if FoundErr=true then exit sub
	set rsuser=oblog.execute("select count(userid) from oblog_user where userID>=" & clng(BeginID) & " and userID<=" & clng(EndID))
	p1=rsuser(0)
	set rsuser=oblog.execute("select userid from oblog_user where userID>=" & clng(BeginID) & " and userID<=" & clng(EndID)&" order by userid")
	set blog=new class_blog
	response.Write("<div style=""text-align: center;"">")
	response.Write("<div class=""progress1""><div class=""progress2"" id=""progress1""></div></div><span id=""pstr1""></span><br><br>")
	i=1
	blog.progress_init
	do while not rsUser.eof
		Response.Write "<script>progress1.style.width ="""&int(i/p1*100)&"%"";progress1.innerHTML="""&int(i/p1*100)&"%"";pstr1.innerHTML=""全部进度：当前用户ID:"&rsuser(0)&""";</script>" & VbCrLf
		Response.Flush
		blog.update_alllog rsUser(0)
		rsUser.movenext
		i=i+1
	loop
	response.Write("</div>")
	set rsUser=nothing
	set blog=nothing
	end sub

	sub DoUpdatelog()
	Server.ScriptTimeOut=999999999
	dim BeginID,EndID,p1,rs,blog,i
	BeginID=trim(request("BeginID"))
	EndID=trim(request("EndID"))
	if BeginID="" then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>请指定开始ID</li>"
	else
		BeginID=Clng(BeginID)
	end if
	if EndID="" then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>请指定结束ID</li>"
	else
		EndID=Clng(EndID)
	end if
	if FoundErr=true then exit sub
	set rs=oblog.execute("select count(logid) from oblog_log where logid>=" & clng(BeginID) & " and logid<=" & clng(EndID))
	p1=rs(0)
	set rs=oblog.execute("select logid,userid from oblog_log where logid>=" & clng(BeginID) & " and logid<=" & clng(EndID)&" order by logid")
	set blog=new class_blog
	response.Write("<div style=""text-align: center;"">")
	response.Write("<div class=""progress1""><div class=""progress2"" id=""progress1""></div></div><span id=""pstr1""></span><br><br>")
	i=1
	'blog.progress_init
	do while not rs.eof
		Response.Write "<script>progress1.style.width ="""&int(i/p1*100)&"%"";progress1.innerHTML="""&int(i/p1*100)&"%"";pstr1.innerHTML=""进度：当前日志ID:"&rs(0)&""";</script>" & VbCrLf
		Response.Flush
		blog.userid=rs(1)
		blog.update_log rs(0),0
		rs.movenext
		i=i+1
	loop
	response.Write("</div>")
	set rs=nothing
	set blog=nothing
end sub

sub WriteErrMsg()
	dim strErr
	strErr=strErr & "<html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbcrlf
	strErr=strErr & "<link href='style.css' rel='stylesheet' type='text/css'></head><body><br><br>" & vbcrlf
	strErr=strErr & "<table cellpadding=2 cellspacing=1 border=0 width=400 class='border' align=center>" & vbcrlf
	strErr=strErr & "  <tr align='center' class='title'><td height='22'><strong>错误信息</strong></td></tr>" & vbcrlf
	strErr=strErr & "  <tr class='tdbg'><td height='100' valign='top'><b>产生错误的可能原因：</b>" & errmsg &"</td></tr>" & vbcrlf
	strErr=strErr & "  <tr align='center' class='tdbg'><td><a href='javascript:history.go(-1)'>&lt;&lt; 返回上一页</a></td></tr>" & vbcrlf
	strErr=strErr & "</table>" & vbcrlf
	strErr=strErr & "</body></html>" & vbcrlf
	response.write strErr
end sub
%>