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

📄 adminaction.java

📁 一个运行成功的论坛
💻 JAVA
字号:
package mybbs;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
//import org.apache.struts.action.ActionMessage;
//import org.apache.struts.action.ActionMessages;
import javax.servlet.http.HttpSession;
//import javax.servlet.ServletContext;
//import javax.sql.DataSource;
import java.sql.*;

public final class AdminAction
    extends Action {
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) throws Exception {

    CAEncode encode = new CAEncode();
    String PageForward;
    HttpSession session = request.getSession(true);
    String ip = request.getRemoteAddr();
    int power = 0;
    String forum = "";
    if (session.getAttribute("forum") != null) {
      forum = (String) session.getAttribute("forum");
    }
    if (session.getAttribute("userpower") != null) {
      power = Integer.parseInt( (String) session.getAttribute("userpower"));
    }
    try {
      DBConn conn = new DBConn();
      DynaActionForm userform = (DynaActionForm) form;
      String motion = (String) userform.get("motion");
      String postid = encode.htmlEncode( (String) userform.get("postid"));
      String topicid = (String) userform.get("topicid");
      String forumid = (String) userform.get("forumsid");

      /*---------------------------------
       *1:置顶  2:删除  3:锁定 4:加精 11:取消置顶
       *
                  -----------------------------------*/
      if (power > 10 || forum.equals(forumid)) {
        if (motion.equals("1")) {
          conn.update("UPDATE posts SET istop=istop+1 WHERE istopic>0 AND id="+postid);
        }
        if (motion.equals("11")) {
          conn.update("UPDATE posts SET istop=0 WHERE istopic>0 AND id="+postid);
        }
        if (motion.equals("2")) {
          conn.update("UPDATE posts SET isdel=1 WHERE id="+postid);
        }
        if (motion.equals("21")) {
          conn.update("UPDATE posts SET isdel=0 WHERE istopic>0 AND id="+postid);
        }
        if (motion.equals("3")) {
          conn.update("UPDATE posts SET islock=1 WHERE istopic>0 AND id="+postid);
        }
        if (motion.equals("31")) {
          conn.update("UPDATE posts SET islock=0 WHERE istopic>0 AND id="+postid);
        }
        if (motion.equals("4")) {
          conn.update("UPDATE posts SET groupid=1 WHERE istopic>0 AND id="+postid);
        }
        if (motion.equals("41")) {
          conn.update("UPDATE posts SET groupid=0 WHERE istopic>0 AND id="+postid);
        }
        if (power > 10) {
          if (motion.equals("5")) {
            conn.update("UPDATE posts SET groupid=2 WHERE istopic>0 AND id="+postid);
          }
          if (motion.equals("51")) {
            conn.update("UPDATE posts SET groupid=0 WHERE istopic>0 AND id="+postid);
          }
        }

      }
      conn.DBclose();
      request.setAttribute("forumsid", forumid);
      PageForward = "adminOkay";
    }
    catch (Exception e) {
      PageForward = "adminFailed";
      request.setAttribute("throw", e.toString());
    }
    return mapping.findForward(PageForward);
  }
}

⌨️ 快捷键说明

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