⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin.jsp

📁 这是一个用JAVA语言编写的BBS论坛程序
💻 JSP
字号:
<%
/*
 * Copyright:  Copyright (c) 2004 
 * @author http://hi.baidu.com/lael80*/
%>
<%@ page contentType="text/html; charset=gb2312" errorPage=""%>
<%@ include file="head.jsp"%>
<br>
<%
if(!workFC.cNULL(String.valueOf(session.getAttribute("u_name")))){
  response.sendRedirect("result.jsp?errcodes="+workFC.GBtoUni("<li>您还没有注册或登录,不能查看会员名单"));
  return;
}
if(workDB.queryCount("select count(user_id) from user_info where user_name='"+session.getAttribute("u_name")+"' and user_type=100")==0){
  response.sendRedirect("result.jsp?errcodes="+workFC.GBtoUni("<li>您的权限不够"));
  return;
}
if(workFC.cNULL(request.getParameter("op"))){
  try{
    id=Integer.parseInt(request.getParameter("id"));
    if(workDB.queryCount("select count(user_id) from user_info where user_id="+id)==0){
      response.sendRedirect("result.jsp?errcodes="+workFC.GBtoUni("<li>错误的用户参数"));
      return;
    }
    if(workDB.queryCount("select count(user_id) from user_info where user_type=100 and user_id="+id)!=0){
      response.sendRedirect("result.jsp?errcodes="+workFC.GBtoUni("<li>错误的用户参数"));
      return;
    }
  }catch(Exception e){
    response.sendRedirect("result.jsp?errcodes="+workFC.GBtoUni("<li>错误的用户参数"));
    return;
  }    
  if(request.getParameter("op").equals("1")){
    workDB.executeUpdate("update user_info set user_type=if(user_type=50,0,50) where user_id="+id);
  }
  if(request.getParameter("op").equals("2")){
    int select=0;
    try{
      select=Integer.parseInt(request.getParameter("select"+id));
      if(select<0||select>9){
        response.sendRedirect("result.jsp?errcodes="+workFC.GBtoUni("<li>错误的等级参数"));
        return;
      }
    }catch(Exception e){
      response.sendRedirect("result.jsp?errcodes="+workFC.GBtoUni("<li>您还没选择要升级的等级"));
      return;
    }
    workDB.executeUpdate("update user_info set user_type="+select+" where user_id="+id);
  }
  if(request.getParameter("op").equals("3")){
    String user_name=workDB.queryData("select user_name from user_info where user_id="+id);
    workDB.executeUpdate("delete from user_topic where user_name='"+user_name+"'");
    workDB.executeUpdate("delete from user_reply where user_name='"+user_name+"'");
    workDB.executeUpdate("delete from user_info where user_id="+id);
  }  
}
%>
<%=tabletop%>
<table width="100%" border="0" cellpadding="0" cellspacing="1">
<tr><td colspan="7" height="25" valign="middle">&nbsp;<a href="admin.jsp?pageid=1" style="text-decoration:underline;">显示全部</a></td></tr>
<tr height="25" align="center" valign="middle" class="b1">
    <td width="18%">用户名称</td>
    <td width="25%">邮箱</td>
    <td width="8%">
    <select onchange="if(this.options[this.selectedIndex].value!=''){location=this.options[this.selectedIndex].value;}">
    <option selected>用户等级</option>
    <option value="admin.jsp?action=1&pageid=1">版主</option>
    <option value="admin.jsp?action=2&pageid=1">会员</option>
    </select>
    </td>
    <td width="8%">
    <select onchange="if(this.options[this.selectedIndex].value!=''){location=this.options[this.selectedIndex].value;}">
    <option selected>发贴数量</option>
    <option value="admin.jsp?action=asc&pageid=1">升序</option>
    <option value="admin.jsp?action=desc&pageid=1">降序</option>
    </select>
    </td>
    <td width="8%">
    <select onchange="if(this.options[this.selectedIndex].value!=''){location=this.options[this.selectedIndex].value;}">
    <option selected>锁定ID</option>
    <option value="admin.jsp?action=4&pageid=1">已锁ID</option>
    </select>
    </td>
    <td width="20%">升级</td>
    <td width="13%">删除ID</td>
</tr>

<%
String temp="";
action=request.getParameter("action");
String search=request.getParameter("user_name");
try{
   pageid=Integer.parseInt(request.getParameter("pageid"));
   if(pageid<0)pageid=1;
}catch(Exception e){pageid=1;}

if(workFC.cNULL(search)){
  urlpath="&user_name="+search+"&";
  temp=" where a.user_type<>100 and a.user_name like '%"+search+"%'";
}  
if(workFC.cNULL(action)){
  if(action.equals("1")){
    urlpath="&action=2&";
    temp=" where a.user_type>0 and a.user_type<10";
  }
  if(action.equals("2")){
    urlpath="&action=3&";
    temp=" where a.user_type=0";
  } 
  if(action.equals("asc")){
    urlpath="&action=asc&";
    temp=" order by count asc";
  }
  if(action.equals("desc")){
    urlpath="&action=desc&";
    temp=" order by count desc";
  }
  if(action.equals("4")){
    urlpath="&action=4&";
    temp=" where a.user_type=50";
  }
}

sql="select count(b.topic_id) as count,a.user_id,a.user_name,a.user_mail,a.user_type from user_info a left join user_topic b using(user_name)";
if(workFC.cNULL(temp)){
  if(temp.indexOf("order")==-1){
    sql+=temp+" group by user_id";
  }else{
    sql+=" where a.user_type<>100 group by user_id"+temp;
    temp="where a.user_type<>100";
  }
}else{
  sql+=" where a.user_type<>100 group by user_id";
  temp+="where a.user_type<>100";
}

workDB.PageInfo("select count(user_id) as count from user_info a "+temp,30,pageid);
String userdata[]=workDB.queryData(sql,5,pageid,30);
for(int i=0;i<userdata.length/5;i++){
  String grade="",freeid="锁定";
  switch (Integer.parseInt(userdata[5*i+4])){
    case 0  : grade="会员"; break;
    case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9: grade="版主"; break;
    case 100: grade="管理员"; break;
    default : grade=""; break;
  }
  if(userdata[5*i+4].equals("50"))freeid="解锁";
  out.println("<tr height='20' align='center' valign='middle'>"+
              "<td><a href='userinfo.jsp?name="+userdata[5*i+2]+"' title='点击看"+userdata[5*i+2]+"详细信息'>"+userdata[5*i+2]+"</a></td>"+
              "<td><a href='mailto:"+userdata[5*i+3]+"' title='发邮件给"+userdata[5*i+2]+"'>"+userdata[5*i+3]+"</a></td>"+
              "<td>"+grade+"</td>"+
              "<td>"+userdata[5*i]+"</td>"+
              "<td><a href='admin.jsp?id="+userdata[5*i+1]+"&op=1'>"+freeid+"</a></td>"+
              "<td><form method='post' action='admin.jsp?id="+userdata[5*i+1]+"&op=2'><select name='select"+userdata[5*i+1]+"'>"+
              "<option selected>选择等级...</option><option value='0'>会员</option>"+
              "<option value='1'>网页设计-版主</option><option value='2'>平面设计-版主</option>"+
              "<option value='3'>动漫前沿-版主</option><option value='4'>编程开发-版主</option>"+
              "<option value='5'>电脑网络-版主</option><option value='6'>灌水乐园-版主</option>"+
              "<option value='7'>电视电影-版主</option><option value='8'>贴图专区-版主</option>"+
              "<option value='9'>论坛事务-版主</option></select>"+             
              "<input type='submit' value='升级'></form></td>"+
              "<td><a href='admin.jsp?id="+userdata[5*i+1]+"&op=3' title='同时删除该用户所有贴子'>删除</a></td></tr>");
}
%>

  <tr height="20">
    <td colspan="7" align="right" valign="middle">
      <table width="100%" border="0" cellpadding="2" cellspacing="0">
      <tr valign="middle"><td width="50%">
      <%="&nbsp;页次:"+pageid+"/"+workDB.getPageCount()+"页&nbsp;本页:"+workDB.getPageNowCount()+"&nbsp;会员:"+workDB.getDataCount()%>  
      </td><td align="right">
      <%=workFC.ShowPage(workDB.getPageCount(),pageid,"admin.jsp?"+urlpath+"pageid")%>
    &nbsp;
       </td></tr>
      </table>
      </td>
  </tr>
</table>
<%=tablebottom%>
<br>
<table width="96%" align="center" border="0" cellpadding="5" cellspacing="0">
<form method="post" action="admin.jsp?pageid=1">
<tr>
 <td width="60%"><input type="text" maxlength="15" size="20" name="user_name">&nbsp;<input type="submit" name="submit1" value="所有用户名中搜索"></td>
 <td align="right">&nbsp;</td>
</tr>
</form>
</table>
<br>
<%@ include file="footer.jsp"%>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -