示例#1
0
  public boolean execute(MessageState msgState, String param) {
    if (param.length() > 0) {
      if (!msgState.sender.hasRight(IUserStates.ROLE_VIP)) {
        msgState.msgTemplate = "error.noRight.noVipAdmin";
        msgState.sender.sendMessage(msgState.mp);
        return false;
      }
      msgState.msgTemplate = "message.m.vip";
      msgState.message = param;
      for (Enumeration<Object> e = UserManager.mgr.onlineVips(); e.hasMoreElements(); ) {
        User u = (User) e.nextElement();
        if (u == null || u.equals(msgState.sender)) continue;
        u.sendMessage(msgState.mp);
      }
      for (Enumeration<Object> e = UserManager.mgr.notListedAsOnlineVips(); e.hasMoreElements(); ) {
        User u = (User) e.nextElement();
        if (u == null || u.equals(msgState.sender)) continue;
        u.sendMessage(msgState.mp);
      }
      msgState.msgTemplate = "message.m.vip.confirm";
      msgState.sender.sendMessage(msgState.mp);
    } else {

      Vector<Object> v = UserManager.mgr.onlineVipList();
      if (v.size() == 0) {
        msgState.msgTemplate = "error.vip.noVipOnline";
        msgState.sender.sendMessage(msgState.mp);
        return false;
      }
      if (v.size() == 1) {
        msgState.msgTemplate = "message.vip.singular";
        msgState.usercontext = (User) v.get(0);
      } else {
        msgState.msgTemplate = "message.vip.plural";
        msgState.usrList = v.toArray();
      }
      msgState.sender.sendMessage(msgState.mp);
    }
    return true;
  }
示例#2
0
  public String checkTName(User u, String name) {
    if (Server.srv.getProperty("costum.userAgent") == null) return name;

    String browseragent = name;
    if (u != null && u.getUserAgent() != null) {
      browseragent = u.getUserAgent();
    } else return name;

    boolean defaultFile = true;
    String ta[] = Server.srv.getProperty("costum.userAgent").split(",");
    Vector<String> tempAgent = new Vector<String>();
    for (int i = 0; i < ta.length; i++) {
      tempAgent.add(ta[i].trim().toLowerCase());
    }
    int fn = 0;
    int found = 0;
    for (Enumeration<String> e = tempAgent.elements(); e.hasMoreElements(); ) {
      StringBuilder customAgent = new StringBuilder((String) e.nextElement());
      fn++;
      if (browseragent.toLowerCase().indexOf(customAgent.toString().toLowerCase()) >= 0) {
        defaultFile = false;
        Server.log(
            this,
            "Found Browser '" + customAgent + "'(" + u.getUserAgent() + ")",
            Server.MSG_STATE,
            Server.LVL_VERBOSE);
        found = fn;
        continue;
      } else {
        if (u != null && u.getUserAgent() != null)
          Server.log(
              this,
              "Browser '" + customAgent + "' not found(" + u.getUserAgent() + ")",
              Server.MSG_STATE,
              Server.LVL_VERBOSE);
      }
      customAgent = null;
    }
    StringBuilder fName = null;
    if (defaultFile) {
      return name;
    } else {
      fName = new StringBuilder(name).append("_custom").append(found);
      if (ts == null || u == null | u.getName() == null) return name;
      tpl = ts.getTemplate(fName.toString());
      if (tpl == null) {
        Server.log(
            this,
            u.getTemplateSet() + " File " + fName + " not found",
            Server.MSG_STATE,
            Server.LVL_VERBOSE);
        fName = new StringBuilder(name).append("_custom");
        tpl = ts.getTemplate(fName.toString());
      }
      if (tpl == null) {
        Server.log(
            this,
            u.getTemplateSet() + " File " + fName + " not found- loading default input File",
            Server.MSG_ERROR,
            Server.LVL_MAJOR);
        return name;
      }
    }
    return fName.toString();
  }
示例#3
0
 public boolean execute(MessageState msgState, String param) {
   if (isPunished(msgState)) return false;
   if (param.length() < 1) {
     msgState.msgTemplate = "error.su.noArg";
     msgState.sender.sendMessage(msgState.mp);
     return false;
   }
   msgState.targetGroup = msgState.sender.getGroup();
   Group sg = msgState.sender.getGroup();
   if (sg == null) return false;
   boolean mayChangeRights = msgState.sender.hasRight(IUserStates.MAY_CHANGE_RIGHT);
   if (!mayChangeRights && !sg.usrIsSu(msgState.sender)) {
     msgState.msgTemplate = "error.noRight.noSuVipAdmin";
     msgState.sender.sendMessage(msgState.mp);
     return false;
   }
   if (param.indexOf(" ") > -1 && !msgState.sender.hasRight(IUserStates.ROLE_VIP)) {
     msgState.msgTemplate = "error.mass.noRight.noVipAdmin";
     msgState.sender.sendMessage(msgState.mp);
     return false;
   }
   msgState.useRenderCache = false;
   GroupUserList gul = new GroupUserList();
   Vector<User> found = getMultibleUsers(msgState, param);
   for (Iterator<User> i = found.iterator(); i.hasNext(); ) {
     User cu = (User) i.next();
     if (cu.hasRight(IUserStates.ROLE_GOD)) {
       msgState.msgTemplate = "error.noRight.isAdmin";
       msgState.usercontext = cu;
       msgState.sender.sendMessage(msgState.mp);
       i.remove();
       continue;
     } else if (cu.hasRight(IUserStates.ROLE_VIP)) {
       msgState.msgTemplate = "error.noRight.isVip";
       msgState.usercontext = cu;
       msgState.sender.sendMessage(msgState.mp);
       i.remove();
       continue;
     } else if (cu.hasRight(IUserStates.ROLE_ASSHOLE)) {
       msgState.msgTemplate = "error.su.noRight";
       msgState.usercontext = cu;
       msgState.sender.sendMessage(msgState.mp);
       i.remove();
       continue;
     }
     if (!mayChangeRights && !msgState.sender.getGroup().equals(cu.getGroup())) {
       msgState.msgTemplate = "error.noRight.noVipAdmin";
       msgState.sender.sendMessage(msgState.mp);
       i.remove();
       continue;
     }
     if (cu.getMembership(sg.getSuForbiddenMembership()) != null) {
       msgState.msgTemplate = "error.noRight.isSuForbiddenMembership";
       msgState.usercontext = cu;
       msgState.sender.sendMessage(msgState.mp);
       i.remove();
       continue;
     }
     if (cu.getGroup() == null // user is currently changing groups...
         || cu.getGroup().usrIsSu(cu)) {
       i.remove();
       continue;
     }
     if (cu.getGroup().hasState(IGroupState.ENTRANCE)
         && !mayChangeRights
         && sg.suUserCount() >= Server.srv.MAX_SUUSERS_PER_STARTGROUP) {
       msgState.msgTemplate = "error.su.tooManyForStartgroup";
       msgState.param = String.valueOf(Server.srv.MAX_SUUSERS_PER_STARTGROUP);
       msgState.sender.sendMessage(msgState.mp);
       i.remove();
       while (i.hasNext()) {
         //    Object o = i.next();
         i.remove();
       }
       break;
     }
     msgState.usrList = null;
     if (setSuRight(msgState, cu, true)) {
       msgState.usercontext = cu;
       gul.addUser(cu, null);
       if (found.size() > 1) {
         msgState.msgTemplate = "message.su.personal";
         cu.sendMessage(msgState.mp);
       }
       StringBuffer sb = new StringBuffer();
       sb.append(msgState.sender.getName());
       sb.append(" gave su-rights to user ");
       sb.append(cu.getName());
       sb.append(" in group ");
       sb.append(cu.getGroup().getRawName());
       Server.log(this, sb.toString(), Server.MSG_STATE, Server.LVL_MINOR);
     } else if (!sg.usrIsSu(msgState.sender) && !msgState.sender.hasRight(IUserStates.ROLE_VIP)) {
       User u = msgState.usercontext;
       msgState.usercontext = cu;
       msgState.msgTemplate = "error.noRight.noSuVipAdmin";
       msgState.sender.sendMessage(msgState.mp);
       i.remove();
       msgState.usercontext = u;
     } else if (!isSu(msgState.sender, cu.getGroup(), msgState)) {
       if (msgState.usrList != null) { // user doesn't have apropriate membership
         msgState.targetGroup = cu.getGroup();
         if (msgState.usrList.length > 1) {
           msgState.msgTemplate = "error.membership.notMember.many";
         } else {
           msgState.msgTemplate = "error.membership.notMember";
         }
         msgState.usercontext = cu;
         msgState.sender.sendMessage(msgState.mp);
         i.remove();
         continue;
       }
     } else {
       User u = msgState.usercontext;
       msgState.usercontext = cu;
       msgState.msgTemplate = "error.noRight.deactivated";
       msgState.sender.sendMessage(msgState.mp);
       i.remove();
       msgState.usercontext = u;
     }
   }
   if (found.size() == 0) return false;
   if (found.size() == 1) {
     msgState.msgTemplate = "message.su.singular";
     msgState.usercontext = (User) found.get(0);
     Group g = msgState.usercontext.getGroup();
     g.sendMessage(msgState.mp);
     if (!msgState.sender.getGroup().equals(g)) {
       msgState.msgTemplate = "message.su.confirm.singular";
       msgState.sender.sendMessage(msgState.mp);
     }
     return true;
   }
   msgState.msgTemplate = "message.su.confirm.plural";
   msgState.usrList = found.toArray();
   msgState.sender.sendMessage(msgState.mp);
   gul.sendMessage(msgState, "message.su", false);
   return true;
 }