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

📄 bbscsutil.java

📁 一个jsp写的bbs
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    return v;
  }

  public static Vector getPermissionTypeValues(Locale locale) {
    Vector v = new Vector();
    v.add(new LabelValueBean(Constant.MESSAGE.getMessage(locale, "admin.permission.typeid0"), "0"));
    v.add(new LabelValueBean(Constant.MESSAGE.getMessage(locale, "admin.permission.typeid1"), "1"));
    v.add(new LabelValueBean(Constant.MESSAGE.getMessage(locale, "admin.permission.typeid2"), "2"));
    v.add(new LabelValueBean(Constant.MESSAGE.getMessage(locale, "admin.permission.typeid3"), "3"));
    return v;
  }

  public static Vector getUserTitleValues(Locale locale) {
    Vector v = new Vector();
    v.add(new LabelValueBean(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle0"), "0"));
    v.add(new LabelValueBean(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle1"), "1"));
    v.add(new LabelValueBean(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle2"), "2"));
    v.add(new LabelValueBean(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle3"), "3"));
    return v;
  }

  public static Vector getUserForumNumPerPageValues(Locale locale) {
    Vector v = new Vector();
    v.add(new LabelValueBean(Constant.MESSAGE.getMessage(locale, "bbscs.usesystem"), "0"));
    v.add(new LabelValueBean("20", "20"));
    v.add(new LabelValueBean("30", "30"));
    v.add(new LabelValueBean("40", "40"));
    return v;
  }

  public static Vector getUserPostNumPerPageValues(Locale locale, String[] ppns) {
    Vector v = new Vector();
    v.add(new LabelValueBean(Constant.MESSAGE.getMessage(locale, "bbscs.usesystem"), "0"));
    for (int i = 0; i < ppns.length; i++) {
      v.add(new LabelValueBean(ppns[i], ppns[i]));
    }
    return v;
  }

  public static Vector getForumViewModeValues(Locale locale) {
    Vector v = new Vector();
    v.add(new LabelValueBean(Constant.MESSAGE.getMessage(locale, "bbscs.viewmode0"), "0"));
    v.add(new LabelValueBean(Constant.MESSAGE.getMessage(locale, "bbscs.viewmode1"), "1"));
    v.add(new LabelValueBean(Constant.MESSAGE.getMessage(locale, "bbscs.viewmode2"), "2"));
    return v;
  }

  public static List getUserTitleUserKnowValues(Locale locale) {
    List l = new ArrayList();
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.userkonw0"), -500));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.userkonw1"), -100));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.userkonw2"), 0));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.userkonw3"), 50));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.userkonw4"), 100));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.userkonw5"), 200));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.userkonw6"), 400));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.userkonw7"), 750));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.userkonw8"), 1500));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.userkonw9"), 3000));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.userkonw10"), 6000));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.userkonw11"), 10000));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.userkonw12"),
                        Integer.MAX_VALUE));
    return l;
  }

  public static String getUserTitleUserKnow(int value, Locale locale) {
    List l = getUserTitleUserKnowValues(locale);
    for (int i = 0; i < l.size(); i++) {
      UserTitle ut = (UserTitle) l.get(i);
      if (value < ut.getValue()) {
        return ut.getTitleName();
      }
    }
    return Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp12");
  }

  public static List getUserTitleCoinValues(Locale locale) {
    List l = new ArrayList();
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.coin0"), 0));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.coin1"), 1));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.coin2"), 50));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.coin3"), 200));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.coin4"), 600));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.coin5"), 1050));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.coin6"), 1400));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.coin7"), 1800));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.coin8"), 2250));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.coin9"), 2750));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.coin10"), 3300));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.coin11"), 10000));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.coin12"),
                        Integer.MAX_VALUE));
    return l;
  }

  public static String getUserTitleCoin(int value, Locale locale) {
    List l = getUserTitleCoinValues(locale);
    for (int i = 0; i < l.size(); i++) {
      UserTitle ut = (UserTitle) l.get(i);
      if (value < ut.getValue()) {
        return ut.getTitleName();
      }
    }
    return Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.coin12");
  }

  public static List getUserTitleLiteraryValues(Locale locale) {
    List l = new ArrayList();
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.literary0"), 20));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.literary1"), 50));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.literary2"), 100));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.literary3"), 260));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.literary4"), 500));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.literary5"), 860));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.literary6"), 1290));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.literary7"), 2000));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.literary8"), 3500));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.literary9"), 5500));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.literary10"),
                        Integer.MAX_VALUE));
    return l;
  }

  public static String getUserTitleLiterary(int value, Locale locale) {
    List l = getUserTitleLiteraryValues(locale);
    for (int i = 0; i < l.size(); i++) {
      UserTitle ut = (UserTitle) l.get(i);
      if (value < ut.getValue()) {
        return ut.getTitleName();
      }
    }
    return Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.literary10");
  }

  public static List getUserTitleExpValues(Locale locale) {
    List l = new ArrayList();
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp0"), -500));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp1"), -100));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp2"), 0));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp3"), 100));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp4"), 300));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp5"), 800));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp6"), 1500));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp7"), 2500));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp8"), 5000));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp9"), 7000));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp10"), 10000));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp11"), 15000));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp12"), 22000));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp13"), 30000));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp14"), 40000));
    l.add(new UserTitle(Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp15"),
                        Integer.MAX_VALUE));
    return l;
  }

  public static String getUserTitleExp(int value, Locale locale) {
    List l = getUserTitleExpValues(locale);
    for (int i = 0; i < l.size(); i++) {
      UserTitle ut = (UserTitle) l.get(i);
      if (value < ut.getValue()) {
        return ut.getTitleName();
      }
    }
    return Constant.MESSAGE.getMessage(locale, "bbscs.usertitle.exp15");
  }

  public static String getUserTitle(int type, int value, Locale locale) {
    switch (type) {
      case 0:
        return getUserTitleExp(value, locale);
      case 1:
        return getUserTitleLiterary(value, locale);
      case 2:
        return getUserTitleUserKnow(value, locale);
      case 3:
        return getUserTitleCoin(value, locale);
      default:
        return getUserTitleExp(value, locale);
    }
  }

  public static String getUserLevelName(List userlevleList, int value) {
    UserLevel ul = null;
    for (int i = 0; i < userlevleList.size(); i++) {
      ul = (UserLevel) userlevleList.get(i);
      if (value < ul.getLevelValue()) {
        return ul.getLevelName();
      }
    }
    return "-";
  }

  public static String getTimeZone(int id) {
    String[] values = Constant.TIMEZONEVALUES[id];
    return values[1];
  }

  public static String getBoardPrefixLine(int level, String txt) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < level * 2; i++) {
      sb.append(txt);
    }
    return sb.toString();
  }

  public static String[] filterUserSign(String[] sign, boolean useHTML, boolean useUBB,
                                        boolean useSmile) {
    for (int i = 0; i < sign.length; i++) {
      sign[i] = filterUserSign(sign[i], useHTML, useUBB, useSmile);
    }
    return sign;
  }

  public static String filterUserSign(String sign, boolean useHTML, boolean useUBB,
                                      boolean useSmile) {
    if (!useHTML) {
      sign = TagUtils.getInstance().filter(sign);
    }
    if (useUBB) {
      sign = getUBB2HTML(sign);
    }
    if (useSmile) {
      sign = replaceSmile(sign);
    }
    sign = sign.replaceAll("\n", "<BR/>");
    sign = filterScript(sign);
    return sign;
  }

  public static String filterText(String sign, boolean useHTML, boolean useUBB,
                                  boolean useSmile) {
    if (!useHTML) {
      sign = TagUtils.getInstance().filter(sign);
    }
    if (useUBB) {
      sign = getUBB2HTML(sign);
    }
    if (useSmile) {
      sign = replaceSmile(sign);
    }
    sign = sign.replaceAll("\n", "<BR/>");
    sign = filterScript(sign);
    return sign;
  }

  public static String filterScript(String txt) {
    return txt.replaceAll("[Ss][Cc][Rr][Ii][Pp][Tt]", "s.c.r.i.p.t");
  }

  public static String replaceSmile(String txt) {
    if (txt != null) {
      return txt.replaceAll("\\{(\\d{1,2})\\}", "<img src=\"images/smile/$1.gif\" alt=\"smile\"/>");
    }
    else {
      return "";
    }
  }

  public static String replaceHtml(String txt) {
    if (txt != null) {
      StringBuffer sb = new StringBuffer();
      int start = txt.indexOf("<");
      int end = txt.indexOf(">");
      if ( (start != -1) && (end != -1)) {
        while ( (start != -1) && (end != -1)) {
          sb.append(txt.substring(0, start));
          txt = txt.substring(start + 1, txt.length());
          start = txt.indexOf("<");
          end = txt.indexOf(">");
          txt = txt.substring(end + 1, txt.length());
          start = txt.indexOf("<");
          end = txt.indexOf(">");
        }
      }
      else {
        sb.append(txt);
      }
      return sb.toString();
    }
    else {
      return "";
    }
  }

  public static String getClassName(String className, String userID) {
    int num = Math.abs(userID.hashCode());
    className = Constant.BEANPERFIX + className + (num % 10);
    return className;
  }

  public static String getClassName(String className, String userID, int modnum) {
    int num = Math.abs(userID.hashCode());
    className = Constant.BEANPERFIX + className + (num % modnum);
    return className;
  }

  public static String getClassName(String className, long bid, int modnum) {
    className = Constant.BEANPERFIX + className + (bid % modnum);
    return className;
  }

  public static int getTableID(String userID, int num) {
    int absNum = Math.abs(userID.hashCode());
    return (int) (absNum % num);
  }

  public static int getTableID(long bid, int num) {
    return (int) (bid % num);
  }

  public static List stringValues2List(String[] values) {
    List l = new ArrayList();
    if (values != null) {
      for (int i = 0; i < values.length; i++) {
        l.add(values[i]);
      }
    }
    else {
      l.add("0");
    }
    return l;
  }

⌨️ 快捷键说明

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