<!--#include file="../conn.asp"-->
<!--#include file="admin_check.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../inc/class_upload.asp"-->
<!--#include file="../inc/function.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>管理页面</title>
<link id="maincss" rel="stylesheet" href="images/css/admin_style_<%= AdminSkin %>.css" type="text/css" media="all" />
<script language="JavaScript" src="../js/class.js"></script>
<script language="javascript" src="../js/askA.js"></script>

<script language="javascript">
 function chkpwd(obj){
  var t=obj.value;
  var id=getResult(t);
  
  //定义对应的消息提示
  var msg=new Array(4);
  msg[0]="密码过短。";
  msg[1]="密码强度差。";
  msg[2]="密码强度良好。";
  msg[3]="密码强度高。";
  
  var sty=new Array(4);
  sty[0]=-45;
  sty[1]=-30;
  sty[2]=-15;
  sty[3]=0;
  
  var col=new Array(4);
  col[0]="gray";
  col[1]="red";
  col[2]="#ff6600";
  col[3]="Green";
  
  //设置显示效果
  var bImg="images/chkpass.gif";//一张显示用的图片
  var sWidth=300;
  var sHeight=15;
  var Bobj=document.getElementById("chkResult");

  Bobj.style.fontSize="12px";
  Bobj.style.color=col[id];
  Bobj.style.width=sWidth + "px";
  Bobj.style.height=sHeight + "px";
  Bobj.style.lineHeight=sHeight + "px";
  Bobj.style.background="url(" + bImg + ") no-repeat left " + sty[id] + "px";
  Bobj.style.textIndent="20px";
  Bobj.innerHTML="检测提示：" + msg[id];
 }
 
 //定义检测函数,返回0/1/2/3分别代表无效/差/一般/强
 function getResult(s){
  if(s.length < 4){
   return 0;
  }
  var ls = 0;
  if (s.match(/[a-z]/ig)){
   ls++;
  }
  if (s.match(/[0-9]/ig)){
   ls++;
  }
   if (s.match(/(.[^a-z0-9])/ig)){
   ls++;
  }
  if (s.length < 6 && ls > 0){
   ls--;
  }
  return ls
 }
 
 function Cdiv()
 {
 if(classM.innerHTML!='请选择栏目')
 {
 classM1.innerHTML=classM1.innerHTML+classM.innerHTML;
 classM.innerHTML='请选择栏目';
 }
 }

function CheckAll()
{
var length = document.frm.checkbox.length;
var tocheck = document.frm.SelectAll.checked;

  if (length>=2)
  {
    for (var i=0; i<length; i++){document.frm.checkbox[i].checked = tocheck;}
   }
  else
  {
    document.frm.checkbox.checked = tocheck;    
  }
   
}

function PreviewImg(imgFile)
{
    oimg.style.display="none";
    var newPreview = document.getElementById("newPreview");
    newPreview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgFile.value;
    newPreview.style.width = "80px";
    newPreview.style.height = "80px";
}
</script>
<style type="text/css">
<!--
#chkResult {
	height: 15px;
	background-image: url(Images/chkpass.gif);
	background-repeat: no-repeat;
	background-position: left -45px;
	text-indent: 20px;
	color: gray;
	line-height: 15px;
}
#classM {
	line-height: 30px;
	height: 30px;
}
#newPreview
{
    filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);
}
#star {
	background-image: url(Images/icons.gif);
	background-position: 0px 80px;
	height: 16px;
	width: 16px;
	margin-right: 6px;
	margin-left: 6px;
}
ul {
	margin: 0px;
	padding: 0px;
}
li {
	margin: 0px;
	padding: 0px;
}
-->
</style>
</head>
<body leftmargin="0" bottommargin="0" rightmargin="0" topmargin="5" marginheight="0" marginwidth="0" bgcolor="#DDEEFF">
<%
Dim Act,Userflag
act=Trim(Request.QueryString("act"))
Userflag=Trim(Request.QueryString("userflag"))
if Userflag="" Then Userflag=0
IF Userflag=0 Then Call chkFlag(6) else Call chkFlag(7)
opendb
Dim AskD
Set AskD = Server.CreateObject("KwAsk.FunAsk")
	set AskD.myConn =conn
	AskD.myPredb =predb
select case act
  case "del"
    call del()
  case "add"
    call add()
  case "save"
    call saveuser()
  case "type"
    call ctype()
  case "lock"
    call lockuser()
  case "lockD"
    call lockD()
  case "change"
    call change()
  case "zClass"
    call zClass()
  case "strong"
    call strong()
  case "shutstrong"
    call shutstrong()
  case "savestrong"
    call savestrong()
  case "upfileF"
    call upfileF()
  case else
    call main()
end select
set AskD.myConn =Nothing
Set AskD = Nothing
closedb

sub upfileF()
  dim id,rs,sql,pass,pass2,username,usermail,sex,face,gradetype,score2,selectC,Incentive
  Dim UpFile,sSavePath,UstrFtyp
	sSavePath ="../UploadFile/Face/"
	set UpFile = New UpLoadClass
	UpFile.AutoSave = 2
	UpFile.MaxSize =  Int(200 * 1024) '# (1024*1024=1M) SESSION里的单位为KB
	UpFile.FileType = "gif/jpg/png/bmp/jpeg"
	UpFile.SavePath = sSavePath
	UpFile.Open()
	If UpFile.Save("Face",0) Then
	    UstrFtyp=Ucase(UpFile.strFtyp)
		IF UstrFtyp="TEXT/PLAIN" Then
		Response.Write "<div style=""padding:6px"">注意：请上传正确文件！</div>"
		Response.End()
		End IF
		'Response.Write "上传成功"
	Else
		Select Case UpFile.Form("face_Err")
		Case -1 : Response.Write ""  '允许不上传文件
		Case 1 : Response.Write "文件大小超出限制，请返回重新上传":Response.End()
		Case 2 : Response.Write "不允许上传的文件类型，请返回重新上传":Response.End()
		Case 3 : Response.Write "文件大小超出限制并且是不允许上传的文件类型，请返回重新上传":Response.End()
		Case Else : Response.Write "未知错误，请返回重新上传":Response.End()
		End Select
	End If
	
  id=UpFile.Form("id")
  pass=UpFile.Form("pass")
  pass2=UpFile.Form("pass2")
  username=UpFile.Form("username")
  usermail=UpFile.Form("usermail")
  sex=UpFile.Form("sex")
  face=UpFile.Form("face")
  gradetype=UpFile.Form("gradetype")
  score2=UpFile.Form("score")
  selectC=UpFile.Form("selectC")
  Incentive=UpFile.Form("Incentive")
  
  if pass<>pass2 then 
     Call SendMsg("两次密码不相同")
	 Response.End()
  end if
  
  dim usertype
  set rs= Server.CreateObject("adodb.recordset")
  sql="select * from "&predb&"user where id="&id
  rs.open sql,conn,1,3
  if pass<>"" then
   rs("userpass")=md5(pass,16)
  end if
  usertype=rs("usertype")
  
  if usertype=1 and selectC="" then
  Call SendMsg("请选择专家栏目！")
  Response.Write("<script>setTimeout(""history.go(-1);"",1000);</script>")
  response.End()
  end if
  
  rs("truename")=username
  rs("usermail")=usermail
  rs("sex")=sex
  if face<>"" then
      Dim Fso
      Set FSO = server.CreateObject("Scripting.FileSystemObject")
	    IF FSO.FileExists(Server.mappath("../UploadFile/"&rs("face"))) Then
           FSO.DeleteFile server.MapPath("../UploadFile/"&rs("face")),True
	    End IF
      Set FSO = Nothing
  rs("face")="Face/"&face
  end if
  rs("gradetype")=gradetype
  rs("score")=score2
  rs("Zclass")=selectC
  rs.update
  rs.close
  set rs=nothing
Set UpFile = Nothing
  Incentive=split(Incentive,"|")
  IF Incentive(0)<>0 Then Call AskD.Score(id,Incentive(0),"奖惩："&Incentive(1))
	  Call SendMsg("恭喜您,修改成功！")
	  Response.Write("<script>setTimeout(""location.href='?userflag="&usertype&"';"",2000);</script>")
end sub

Sub zClass()
  Dim id,selectC
  id=Trim(Request.Form("id"))
  selectC=Trim(Request.Form("selectC"))
  IF selectC="" THen
  Call SendMsg("请选择专家栏目！")
  Response.Write("<script>setTimeout(""history.go(-1);"",1000);</script>")
  response.End()
  End IF
  conn.execute("update "&predb&"user set usertype=1,Zclass='"&selectC&"' where id="&id)
  Call SendMsg("恭喜您，设置专家成功！")
  Response.Write("<script>setTimeout(""location.href='?userflag=1';"",2000);</script>")
End Sub

Sub SaveStrong()
   Dim id,check
   id=Trim(Request.QueryString("id"))
   check=Trim(Request.Form("check"))
   conn.execute("update "&predb&"user set isstrong=1,strongtime='"&now()&"',Strongask='"&check&"' where id="&id)
   Call SendMsg("推荐用户成功")
   Response.Write("<script>setTimeout(""location.href='?'"",2000)</script>")
End Sub

Sub shutstrong()
   Dim id
   id=Trim(Request.QueryString("id"))
   conn.execute("update "&predb&"user set isstrong=0 where id="&id)
   Call SendMsg("取消推荐成功")
   Response.Write("<script>setTimeout(""location.href='?'"",2000)</script>")
End Sub

Sub Strong()
dim id,rs,strongask,Checked,userid,ansNum
id=Trim(Request.QueryString("id"))
set rs=conn.execute("select userid,ansNum,strongask from "&predb&"user where id="&id)
userid=rs("userid")
ansNum=rs("ansNum")
strongask=" "&rs("strongask")&","
set rs=nothing
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <tr>
	<th height="25" colspan="2" align="left"><span id="star"></span> <%= userid %>&nbsp; 回答数：<%= ansNum %></th>
  </tr>
  <form method="post" action="?act=savestrong&id=<%= id %>">
  <tr>
    <td width="19%" align="right" class="TableRow1"><strong>选择相关问题：</strong><br><font color="#999999">(建议选择并只选 3 条)</font></td>
    <td width="81%" class="TableRow1">
    <ul>
<%
    set rs=conn.execute("select top 30 * from "&predb&"ask where ansUser+',' like '%,"&id&",%'")
	IF not(rs.bof And rs.eof) Then
		do while not rs.eof
		IF instr(strongask," "&rs("askid")&",")>0 Then Checked="checked" Else Checked=""
		   Response.Write("<li><input name=""check"" type=""checkbox"" "&Checked&" value="""&rs("askid")&"""> <a target=""_blank"" href=""../ask.asp?id="&rs("askid")&""">"&rs("title")&"</a></li>")
		rs.movenext
		loop
	Else
	    Response.Write("<li>暂无相关…</li>")
	End IF
	rs.close
	set rs=nothing
%>
</ul>
    </td>
  </tr>
  <tr>
    <td align="right" class="TableRow1">&nbsp;</td>
    <td class="TableRow1"><input type="submit" name="button9" id="button9" value="确认推荐">
      &nbsp; <input type="button" name="button10" id="button10" value="修改用户" onClick="location.href='?act=change&id=<%= id %>'">
      &nbsp; <input type="button" name="button10" id="button10" value="返回管理" onClick="location.href='?'">
      &nbsp; <input type="button" name="button10" id="button10" value="取消推荐" onClick="location.href='?act=shutstrong&id=<%= id %>'">
      </td>
  </tr>
  </form>
</table>
<%
end sub

sub change()
dim rs,id,Zclass,i,rs1
id=Trim(Request.QueryString("id"))
set rs=conn.execute("select * from "&predb&"user where id="&id)
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <form enctype="multipart/form-data" action="?act=upfileF" method="post" name="frm">
  <input name="id" type="hidden" value="<%=id%>">
  <tr>
	<th height="25" colspan="3" align="left">用户信息修改</th>
  </tr>  
  <tr>
    <td width="19%" align="right" class="TableRow1"><strong>用 户 名：</strong></td>
    <td colspan="2" class="TableRow1"><input type="text" name="adminname" id="adminname" value="<%= rs("userid") %>" readonly></td>
  </tr>
  <tr>
    <td align="right" class="TableRow1"><strong>新 密 码：</strong></td>
    <td colspan="2" class="TableRow1"><input type="password" name="pass" id="pass" onPropertyChange="chkpwd(this);" onBlur="chkpwd(this);">
    不修改密码请留空</td>
  </tr>
  <tr>
    <td align="right" class="TableRow1"><strong>密码强度：</strong></td>
    <td colspan="2" class="TableRow1"><div id="chkResult">检测提示：请输入密码</div></td>
  </tr>
  <tr>
    <td align="right" class="TableRow1"><strong>确认密码：</strong></td>
    <td colspan="2" class="TableRow1"><input type="password" name="pass2" id="pass2"></td>
  </tr>
  
  <tr>
    <td align="right" class="TableRow1"><strong>真实姓名：</strong></td>
    <td colspan="2" class="TableRow1"><input type="text" name="username" id="username" value="<%= rs("Truename") %>"></td>
  </tr>
  <tr>
    <td align="right" class="TableRow1"><strong>E-mail：</strong></td>
    <td colspan="2" class="TableRow1"><input name="usermail" type="text" id="usermail" size="30" value="<%= rs("usermail") %>"></td>
  </tr>
  <tr>
    <td align="right" class="TableRow1"><strong>性别：</strong></td>
    <td colspan="2" class="TableRow1"><input type="radio" name="sex" id="radio3" value="男" <% If rs("sex")="男" Then %>checked<% End If %>>
      男
        <input type="radio" name="sex" id="radio4" value="女" <% If rs("sex")="女" Then %>checked<% End If %>>
        女</td>
  </tr>
  <tr>
    <td align="right" class="TableRow1"><strong>头像：</strong></td>
    <td width="53%" class="TableRow1"><input onChange="javascript:PreviewImg(this);" name="face" type="file" id="face" size="30" value="<%=rs("face")%>"></td>
    <td width="28%" rowspan="3" class="TableRow1"><div id="newPreview"></div><div id="oimg"><% If rs("face")="" or isnull(rs("face")) Then %><img src="../UploadFile/Face/info.gif" width="80" height="80">
        <% Else %><img src="../UploadFile/<%= rs("face") %>" width="80" height="80"><% End If %></div></td>
  </tr>
  <tr>
    <td align="right" class="TableRow1"><strong>等级方案：</strong></td>
    <td class="TableRow1">
    <select name="gradetype" id="gradetype">
    <% 
	set rs1=conn.execute("select * from "&predb&"UserGradeType")
	do while not rs1.eof
	 
	 if rs("gradetype")=0 then
	 %>
      <option <% If rs1("isDefault")=1 Then %>value="0" selected<% Else %> value="<%= rs1("id") %>"<% End If %>><%= rs1("GradeTypename") %></option>
	 <%
	 else
	 %>
      <option value="<%= rs1("id") %>" <% If rs1("id")=rs("gradetype") Then %>selected<% End If %>><%= rs1("GradeTypename") %></option>
     <% End If
	 
	rs1.movenext
	loop
	set rs1=nothing
	%>
    </select>    </td>
    </tr>
  <tr>
    <td align="right" class="TableRow1"><strong>积分：</strong></td>
    <td class="TableRow1"><input type="text" name="score" id="score" value="<%=rs("score")%>"></td>
    </tr>  
    <tr>
    <td align="right" class="TableRow1"><strong>惩罚与奖励：</strong></td>
    <td colspan="2" class="TableRow1">
    <select name="Incentive" id="Incentive">
      <option value="0|0">请选择项目</option>
      <%
	  set rs1=conn.execute("select * from "&predb&"Incentive")
	  do while not rs1.eof
	  %>
      <option value="<%= rs1("FenZ") %>|<%=rs1("Incentive") %>"><%=rs1("Incentive") %></option>
      <%
	  rs1.movenext
	  loop
	  set rs1=nothing
	  %>
    </select>
    </td>
  </tr>
  <% If rs("userType")=1 Then %>

  <tr>
    <td align="right" class="TableRow1"><strong>专家栏目：</strong></td>
    <td colspan="2" class="TableRow1">
    <div id="classM1">
    <%
	if rs("Zclass")<>"" and isnull(rs("Zclass"))=false then
		Zclass=rs("Zclass")&","
		Zclass=split(zclass,",")
		for i=0 to ubound(Zclass)-1
		%>
		<br><input name="selectC" checked type="checkbox" value="<%= Trim(Zclass(i)) %>"> <%= ZclassList(Trim(Zclass(i))) %>
    <%
	    next
	End If
	%>
    </div>
    <div id="classM">请选择栏目</div>
    <div onClick="Cdiv()" style="cursor:pointer"><img src="Images/c-d.gif"> <font color="#000099">增加</font></div>    </td>
  </tr>
  <tr>
    <td class="TableRow1">&nbsp;</td>
    <td colspan="2" class="TableRow1">
    <select name="select1" size="12" id="select1" style="width:88px" onChange="searchlist2(this.form);classM.innerHTML='<br><input name=selectC checked type=checkbox value='+this.value+'> <a target=_blank href=../list.asp??classid='+this.value+'>'+this.options[this.selectedIndex].text+'</a>'">
    </select>  
		<script language="JavaScript">
			searchinit1("", 0);
		</script>
      <select name="select2" size="12" id="select2" style="width:88px" onChange="searchlist3(this.form);classM.innerHTML='<br><input name=selectC checked type=checkbox value='+this.value+'> <a target=_blank href=../list.asp??classid='+frm.select1.value+'>'+frm.select1.options[frm.select1.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+this.value+'>'+this.options[this.selectedIndex].text+'</a>'">
      </select>
	    <script language="JavaScript">
			searchinit2("", 0);
		</script>
      <select name="select3" size="12" id="select3" style="width:88px" onChange="searchlist4(this.form);classM.innerHTML='<br><input name=selectC checked type=checkbox value='+this.value+'> <a target=_blank href=../list.asp??classid='+frm.select1.value+'>'+frm.select1.options[frm.select1.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+frm.select2.value+'>'+frm.select2.options[frm.select2.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+this.value+'>'+this.options[this.selectedIndex].text+'</a>'">
      </select>
	    <script language="JavaScript">
			searchinit3("", 0);
		</script>
      <select name="select4" size="12" id="select4" style="width:88px" onChange="classM.innerHTML='<br><input name=selectC checked type=checkbox value='+this.value+'> <a target=_blank href=../list.asp??classid='+frm.select1.value+'>'+frm.select1.options[frm.select1.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+frm.select2.value+'>'+frm.select2.options[frm.select2.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+frm.select3.value+'>'+frm.select3.options[frm.select3.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+this.value+'>'+this.options[this.selectedIndex].text+'</a>'">
      </select>
		<script language="JavaScript">
			searchinit4("", 0);
		</script>    </td>
    </tr>
    <% End If %>
  <tr>
    <td class="TableRow1">&nbsp;</td>
    <td colspan="2" class="TableRow1"><input type="submit" name="button3" id="button3" value=" 修 改 ">
      &nbsp; <input type="button" name="button4" id="button4" value=" 取 消 " onClick="location.href='?'">
      &nbsp; <input type="button" name="button4" id="button4" value="推荐用户" onClick="location.href='?act=strong&id=<%= id %>'">
      &nbsp; <input type="button" name="button4" id="button4" value="取消推荐" onClick="location.href='?act=shutstrong&id=<%= id %>'">
      </td>
  </tr>
  </form>
</table>
<%
set rs=nothing
end sub

Sub Del()
  dim ID
  ID=Trim(Request.Form("checkbox"))
  if ID<>"" then
  conn.execute("delete from "&predb&"user where id in("&ID&")")
  end if
	  Call SendMsg("删除用户成功")
	  Response.Write("<script>setTimeout(""location.href='?'"",2000)</script>")
End Sub

Sub lockuser()
  dim ID,l,islock
  ID=Trim(Request.QueryString("id"))
  l=Trim(Request.QueryString("l"))
  IF l="0" then
     islock=1
  Else
     islock=0
  End IF
  IF ID<>"" Then
  conn.execute("update "&predb&"user set islock="&islock&" where id="&id)
  End IF
  	  Call SendMsg("锁定操作成功1")
	  Response.Write("<script>setTimeout(""location.href='?'"",2000)</script>")
End Sub

Sub lockD()
  dim checkbox,l,islock
  checkbox=Trim(Request.Form("checkbox"))
  l=Trim(Request.QueryString("l"))
  if l="0" then
     islock=1
  elseif l="1" then
     islock=0
  end if
  if checkbox<>"" then
  conn.execute("update "&predb&"user set islock="&islock&" where id in ("&checkbox&")")
  end if
  	  Call SendMsg("锁定操作成功2")
	  Response.Write("<script>setTimeout(""location.href='?'"",2000)</script>")
End Sub

Sub ctype()
  dim ID,t
  ID=Trim(Request.QueryString("id"))
  t=Trim(Request.QueryString("t"))
  if t="0" then
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <tr>
		<th height="25" align="left">专家栏目设置</th>
  </tr> 
  <form action="?act=zClass" name="frm" method="post">
  <input name="id" type="hidden" value="<%=id%>">
  <tr>
    <td class="TableRow1">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="49%">
    <select name="select1" size="12" id="select1" style="width:88px" onChange="searchlist2(this.form);classM.innerHTML='<br><input name=selectC checked type=checkbox value='+this.value+'> <a target=_blank href=../list.asp??classid='+this.value+'>'+this.options[this.selectedIndex].text+'</a>'">
    </select>  
		<script language="JavaScript">
			searchinit1("", 0);
		</script>
      <select name="select2" size="12" id="select2" style="width:88px" onChange="searchlist3(this.form);classM.innerHTML='<br><input name=selectC checked type=checkbox value='+this.value+'> <a target=_blank href=../list.asp??classid='+frm.select1.value+'>'+frm.select1.options[frm.select1.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+this.value+'>'+this.options[this.selectedIndex].text+'</a>'">
      </select>
	    <script language="JavaScript">
			searchinit2("", 0);
		</script>
      <select name="select3" size="12" id="select3" style="width:88px" onChange="searchlist4(this.form);classM.innerHTML='<br><input name=selectC checked type=checkbox value='+this.value+'> <a target=_blank href=../list.asp??classid='+frm.select1.value+'>'+frm.select1.options[frm.select1.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+frm.select2.value+'>'+frm.select2.options[frm.select2.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+this.value+'>'+this.options[this.selectedIndex].text+'</a>'">
      </select>
	    <script language="JavaScript">
			searchinit3("", 0);
		</script>
      <select name="select4" size="12" id="select4" style="width:88px" onChange="classM.innerHTML='<br><input name=selectC checked type=checkbox value='+this.value+'> <a target=_blank href=../list.asp??classid='+frm.select1.value+'>'+frm.select1.options[frm.select1.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+frm.select2.value+'>'+frm.select2.options[frm.select2.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+frm.select3.value+'>'+frm.select3.options[frm.select3.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+this.value+'>'+this.options[this.selectedIndex].text+'</a>'">
      </select>
		<script language="JavaScript">
			searchinit4("", 0);
		</script>    </td>
    <td width="51%" valign="top">
    <div id="classM1"></div>
    <div id="classM">请选择栏目</div>
    <div onClick="Cdiv()" style="cursor:pointer"><img src="Images/c-d.gif"> <font color="#000099">增加</font></div></td>
  </tr>
</table>

    </td>
    </tr>
  <tr>
    <td class="TableRow1"><input type="submit" name="button" id="button" value="确认专家设置">
      &nbsp; <input type="button" name="button2" id="button2" value="取消设置" onClick="location.href='?'"></td>
  </tr>
  </form>
</table>
<%
  
  elseif t="1" then
	 conn.execute("update "&predb&"user set usertype=0,Zclass='' where id="&id)
	 Response.Write("<script>location.href='?';</script>")
  end if
End Sub

sub saveuser()
  dim userid,userpass,userpass2,usertype,rs,sql,selectC
  userid=Trim(Request.Form("userid"))
  userpass=Trim(Request.Form("userpass"))
  userpass2=Trim(Request.Form("userpass2"))
  usertype=Trim(Request.Form("usertype"))
  selectC=Trim(Request.Form("selectC"))
  
  if usertype="1" and selectC="" then
  Call SendMsg("请选择专家栏目！")
  Response.Write("<script>setTimeout(""history.go(-1);"",1000);</script>")
  response.End()
  end if
  
  if userid="" or userpass="" or userpass<>userpass2 then
     Response.Write("<script>history.go(-1);</script>")
  else
  
  set rs= Server.CreateObject("adodb.recordset")
  sql="select * from "&predb&"user where userid='"&userid&"'"
  rs.open sql,conn,1,3
  if rs.bof and rs.eof then
  rs.addnew()
  rs("userid")=userid
  rs("userpass")=md5(userpass,16)
  rs("usertype")=usertype
  rs("Zclass")=selectC
  rs("regtime")=now()
  rs.update
  end if
  rs.close
  set rs=nothing
  Response.Redirect("?userflag="&usertype)
  end if
end sub

Sub add()
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <form action="?act=save" method="post" name="frm">
  <tr>
	<th height="25" colspan="2" align="left">新用户增加</th>
  </tr>  
  <tr>
    <td width="19%" align="right" class="TableRow1"><strong>新用户名：</strong></td>
    <td width="81%" class="TableRow1"><input type="text" name="userid" id="userid"></td>
  </tr>
  <tr>
    <td align="right" class="TableRow1"><strong>初始密码：</strong></td>
    <td class="TableRow1"><input type="password" name="userpass" id="userpass" onPropertyChange="chkpwd(this);" onBlur="chkpwd(this);"></td>
  </tr>
  <tr>
    <td align="right" class="TableRow1"><strong>密码强度：</strong></td>
    <td class="TableRow1"><div id="chkResult">检测提示：请输入密码</div></td>
  </tr>
  <tr>
    <td align="right" class="TableRow1"><strong>确认密码：</strong></td>
    <td class="TableRow1"><input type="password" name="userpass2" id="userpass2"></td>
  </tr>
  <tr>
    <td align="right" class="TableRow1"><strong>权限设置：</strong></td>
    <td class="TableRow1"><input name="usertype" type="radio" id="radio" value="0" onClick="adds.style.display='none'" checked>
    普通用户 
        <input name="usertype" type="radio" id="radio2" value="1" onClick="adds.style.display='block'">
        专家用户</td>
  </tr>
  <tbody id="adds" style="display:none">
  <tr>
    <td align="right" class="TableRow2"><strong>专家栏目：</strong></td>
    <td colspan="2" class="TableRow2">
    <div id="classM1">
    </div>
    <div id="classM">请选择栏目</div>
    <div onClick="Cdiv()" style="cursor:pointer"><img src="Images/c-d.gif"> <font color="#000099">增加</font></div>    </td>
  </tr>
  <tr>
    <td class="TableRow1">&nbsp;</td>
    <td colspan="2" class="TableRow1">
    <select name="select1" size="12" id="select1" style="width:88px" onChange="searchlist2(this.form);classM.innerHTML='<br><input name=selectC checked type=checkbox value='+this.value+'> <a target=_blank href=../list.asp??classid='+this.value+'>'+this.options[this.selectedIndex].text+'</a>'">
    </select>  
		<script language="JavaScript">
			searchinit1("", 0);
		</script>
      <select name="select2" size="12" id="select2" style="width:88px" onChange="searchlist3(this.form);classM.innerHTML='<br><input name=selectC checked type=checkbox value='+this.value+'> <a target=_blank href=../list.asp??classid='+frm.select1.value+'>'+frm.select1.options[frm.select1.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+this.value+'>'+this.options[this.selectedIndex].text+'</a>'">
      </select>
	    <script language="JavaScript">
			searchinit2("", 0);
		</script>
      <select name="select3" size="12" id="select3" style="width:88px" onChange="searchlist4(this.form);classM.innerHTML='<br><input name=selectC checked type=checkbox value='+this.value+'> <a target=_blank href=../list.asp??classid='+frm.select1.value+'>'+frm.select1.options[frm.select1.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+frm.select2.value+'>'+frm.select2.options[frm.select2.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+this.value+'>'+this.options[this.selectedIndex].text+'</a>'">
      </select>
	    <script language="JavaScript">
			searchinit3("", 0);
		</script>
      <select name="select4" size="12" id="select4" style="width:88px" onChange="classM.innerHTML='<br><input name=selectC checked type=checkbox value='+this.value+'> <a target=_blank href=../list.asp??classid='+frm.select1.value+'>'+frm.select1.options[frm.select1.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+frm.select2.value+'>'+frm.select2.options[frm.select2.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+frm.select3.value+'>'+frm.select3.options[frm.select3.selectedIndex].text+'</a> &raquo; <a target=_blank href=../list.asp??classid='+this.value+'>'+this.options[this.selectedIndex].text+'</a>'">
      </select>
		<script language="JavaScript">
			searchinit4("", 0);
		</script>    </td>
    </tr>
    </tbody>
  <tr>
    <td class="TableRow1">&nbsp;</td>
    <td class="TableRow1"><input type="submit" name="button3" id="button3" value=" 增 加 ">
      &nbsp; <input type="button" name="button4" id="button4" value=" 取 消 " onClick="location.href='?'"></td>
  </tr>
  </form>
</table>
<% 
end sub

Sub main()
Dim key
Key=Trim(Request.Form("key"))
IF key<>"" Then Key=" and userid like '%"&key&"%'"
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <tr>
		<th height="25" colspan="9" align="left">普通用户和专家管理</th>
  </tr>  
  <form action="?userflag=<%= Userflag %>" method="post">
  <tr>
    <td colspan="9" class="TableRow2">搜索：
    <input type="text" name="key" id="key"> <input type="submit" name="button5" id="button5" value=" 搜 索 ">
    </td>
  </tr>
  </form>
  <tr>
    <td width="5%" align="center" class="TableRow1"><strong>选中</strong></td>
    <td align="center" class="TableRow1"><strong>用户</strong></td>
    <td width="5%" align="center" class="TableRow1"><strong>等级</strong></td>
    <td width="8%" align="center" class="TableRow1"><strong>问答数</strong></td>
    <td width="13%" align="center" class="TableRow1"><strong>最后登录IP</strong></td>
    <td width="15%" align="center" class="TableRow1"><strong>最后登录时间</strong></td>
    <td width="8%" align="center" class="TableRow1"><strong>登录次数</strong></td>
    <td width="7%" align="center" class="TableRow1"><strong>状态</strong></td>
    <td width="25%" align="center" class="TableRow1"><strong>操作</strong></td>
  </tr>
  <form method="post" action="?act=del" name="frm" onSubmit="return confirm('请确认您的操作？');">
<%
dim rs,rs1,rs2,Grade,i,c,page,maxperpage,minid,n,idcount
maxperpage=25
page=clng(Request.QueryString("page"))
        set rs2=conn.execute("select count(id) from "&predb&"user where UserType="&Userflag&Key)
		idcount=rs2(0) 
		set rs2=nothing
		
		If idcount Mod maxperpage = 0 Then
			n = idcount \ maxperpage
		else
			n = idcount \ maxperpage + 1
		end If
		
IF page>n then page=n
IF page<1 then page=1

		if page=1 then
           set rs=conn.execute("select top "&maxperpage&" * from "&predb&"user where UserType="&Userflag&Key&" order by id desc")
		else
			set rs2=conn.execute("select min(id) from (select top "&(page-1)*maxperpage&" id from "&predb&"user where UserType="&Userflag&Key&" order by id desc) d")
			minid=rs2(0)
			set rs2=nothing
			set rs=conn.execute("select top "&maxperpage&" * from "&predb&"user where id<"&minid&" and UserType="&Userflag&Key&" order by id desc")
		end if
   
do while not rs.eof
i=i+1
if i mod 2=0 then
  c=1
else
  c=2
end if
set rs1=conn.execute("select Grade from "&predb&"Score where tScore>="&rs("Score"))
IF rs1.bof and rs1.eof Then
Grade=1
Else
Grade=rs1("Grade")
End IF
set rs1=nothing
%>
  <tr>
    <td align="center" class="TableRow<%= c %>"><input name="checkbox" type="checkbox" value="<%= rs("id") %>"></td>
    <td title="全名：<%= rs("userid") %>&#13注册时间：<%= rs("regtime") %>&#13被采纳：<%= rs("bcn") %>&#13积分：<%= rs("Score") %>" align="center" class="TableRow<%= c %>"><%= AskD.Leftstr(rs("userid"),10) %><% If rs("isStrong")=1 Then %> <font color="#009900">荐！</font><% End If %></td>
    <td align="center" class="TableRow<%= c %>"><%= Grade %></td>
    <td align="center" class="TableRow<%= c %>"><font color="#FF3300"><%= rs("AskNum") %></font> / <font color="#0000FF"><%= rs("AnsNum") %></font></td>
    <td align="center" class="TableRow<%= c %>"><%= rs("Previousip") %></td>
    <td align="center" class="TableRow<%= c %>"><%= rs("Previoustime") %></td>
    <td align="center" class="TableRow<%= c %>"><%= rs("loginsum") %></td>
    <td align="center" class="TableRow<%= c %>">
	<% If rs("isLock")=1 Then %>
    <font color="#FF0000">已锁定</font>
    <% ElseIf rs("isLock")=2 Then %>
    <font color="#0000FF">待审核</font>
    <% ElseIf rs("isLock")=3 Then %>
    <font color="#FF6600">待激活</font>
	<% Else %>
    正常
	<% End If %>    </td>
    <td align="center" class="TableRow<%= c %>"><a href="?act=change&id=<%= rs("id") %>">修改</a>&nbsp; <a href="?act=type&t=<%= rs("usertype") %>&id=<%= rs("id") %>"><% If rs("usertype")=0 Then %>设为专家<% Else %><font color="#0000FF">取消专家</font><% End If %></a>&nbsp; <a href="admin_message.asp?act=add&user=<%= rs("userid") %>" title="发送站内信"><img align="absmiddle" src="Images/message.gif" border="0"></a> <a href="admin_mail.asp?user=<%= rs("userid") %>" title="发送邮件"><img align="absmiddle" src="Images/mail.gif" border="0"></a>&nbsp; <a href="?act=lock&l=<%= rs("islock") %>&id=<%= rs("id") %>">
      <% If rs("islock")=0 Then %>锁定<% Else %><font color="#FF0000">通过</font><% End If %></a></td>
  </tr>

<%
rs.movenext
loop
set rs=nothing
%>  
  <tr>
    <td colspan="9" class="TableRow1"><label><input type="checkbox" name="SelectAll" id="SelectAll" onClick="CheckAll()">全选\全不选</label>
    &nbsp; <input type="submit" name="button" id="button" value="删除选中的用户">
      &nbsp;
      <input type="submit" name="button6" id="button6" onClick="frm.action='?act=lockD&l=0'" value="批量锁定"> 
      &nbsp;
      <input type="submit" name="button6" id="button6" onClick="frm.action='?act=lockD&l=1'" value="批量解锁"> 
      &nbsp;
      <input type="button" name="button2" id="button2" value="增加新用户" onClick="location.href='?act=add'"></td>
  </tr>
 </form>
  <tr>
    <td colspan="9" align="center" class="TableRow2">共<b><%= idcount %></b>则 <font color="#FF0000"><%= page %></font>/<%= n %>页&nbsp;&nbsp; <a href="?page=1&userflag=<%= userflag %>">首页</a>&nbsp;&nbsp; <a href="?page=<%= page-1 %>&userflag=<%= userflag %>">上一页</a>&nbsp;&nbsp; <a href="?page=<%= page+1 %>&userflag=<%= userflag %>">下一页</a>&nbsp;&nbsp; <a href="?page=<%= n %>&userflag=<%= userflag %>">尾页</a>&nbsp;&nbsp;转到第<Input type="text" name="page" size="3" maxlength="5" value="<%= page %>" onKeyPress="if (event.keyCode==13) window.location='?page='+this.value+'&userflag=<%= userflag %>';">页</td>
  </tr>
</table>
<% 
end sub

Function ZclassList(num)
IF isobject(application("myClassxml"))=false Then call AskD.DoClassXml

if num<>0 then

Dim PostListStr,PStr
dim Rexml,Node,Topic,fstr,nx,ParentStr,classname,xs
set Rexml=application("myClassxml")
set Node=Rexml.documentElement.selectSingleNode("row[@classid="&num&"]")
    ParentStr=Node.selectSingleNode("@parentstr").Text
	classname=Node.selectSingleNode("@classname").Text
set node=nothing
    ParentStr=ParentStr&","
	ParentStr=split(ParentStr,",")

	  
   for each PStr in ParentStr
   if PStr="" then PStr=0
   if clng(PStr)>0 then
   set xs=Rexml.documentElement.selectSingleNode("row[@classid="&pstr&"]")
       PostListStr=PostListStr&" &raquo; <a href=""list.asp?classid="&PStr&""">"&xs.selectSingleNode("@classname").Text&"</a>"
   set xs=nothing
   end if
   next
	   PostListStr=PostListStr&" &raquo; <a href=""list.asp?classid="&num&""">"&ClassName&"</a>"&vbcrlf
set Rexml=nothing

end if

   ZclassList=PostListStr
End Function
%>
<br>
</body>
</html>
