예제 #1
0
 @Override
 public String runMacro(HTTPRequest httpReq, String parm, HTTPResponse httpResp) {
   final String last = httpReq.getUrlParameter("ROOM");
   if (last == null) return " @break@";
   if (last.length() > 0) {
     final Room R = MUDGrinder.getRoomObject(httpReq, last);
     if (R != null) return clearWebMacros(R.roomID());
   }
   return "";
 }
예제 #2
0
 @Override
 public String runMacro(HTTPRequest httpReq, String parm, HTTPResponse httpResp) {
   final java.util.Map<String, String> parms = parseParms(parm);
   final String last = httpReq.getUrlParameter("GOVERNMENT");
   if (parms.containsKey("RESET")) {
     if (last != null) httpReq.removeUrlParameter("GOVERNMENT");
     return "";
   }
   int lastID = -1;
   for (final ClanGovernment G : CMLib.clans().getStockGovernments()) {
     if ((last == null)
         || ((last.length() > 0) && (CMath.s_int(last) == lastID) && (G.getID() != lastID))) {
       httpReq.addFakeUrlParameter("GOVERNMENT", Integer.toString(G.getID()));
       return "";
     }
     lastID = G.getID();
   }
   httpReq.addFakeUrlParameter("GOVERNMENT", "");
   if (parms.containsKey("EMPTYOK")) return "<!--EMPTY-->";
   return " @break@";
 }
예제 #3
0
  @Override
  public String runMacro(HTTPRequest httpReq, String parm) {
    final java.util.Map<String, String> parms = parseParms(parm);
    boolean finalCondition = false;
    for (String key : parms.keySet()) {
      if (key.length() == 0) continue;
      final String equals = parms.get(key);
      boolean not = false;
      boolean thisCondition = true;
      boolean startswith = false;
      boolean inside = false;
      boolean endswith = false;
      if (key.startsWith("||")) key = key.substring(2);
      if (key.startsWith("<")) {
        startswith = true;
        key = key.substring(1);
      }
      if (key.startsWith(">")) {
        endswith = true;
        key = key.substring(1);
      }
      if (key.startsWith("*")) {
        inside = true;
        key = key.substring(1);
      }

      if (key.startsWith("!")) {
        key = key.substring(1);
        not = true;
      }
      final String check = httpReq.getUrlParameter(key);
      if (not) {
        if ((check == null) && (equals.length() == 0)) thisCondition = false;
        else if (check == null) thisCondition = true;
        else if (startswith) thisCondition = !check.startsWith(equals);
        else if (endswith) thisCondition = !check.endsWith(equals);
        else if (inside) thisCondition = !(check.indexOf(equals) >= 0);
        else if (!check.equalsIgnoreCase(equals)) thisCondition = true;
        else thisCondition = false;
      } else {
        if ((check == null) && (equals.length() == 0)) thisCondition = true;
        else if (check == null) thisCondition = false;
        else if (startswith) thisCondition = check.startsWith(equals);
        else if (endswith) thisCondition = check.endsWith(equals);
        else if (inside) thisCondition = (check.indexOf(equals) >= 0);
        else if (!check.equalsIgnoreCase(equals)) thisCondition = false;
        else thisCondition = true;
      }
      finalCondition = finalCondition || thisCondition;
    }
    if (finalCondition) return "true";
    return "false";
  }
예제 #4
0
 @Override
 public String runMacro(HTTPRequest httpReq, String parm, HTTPResponse httpResp) {
   final String last = httpReq.getUrlParameter("GOVERNMENT");
   if (last == null) return " @break@";
   if (last.length() > 0) {
     if (CMath.isInteger(last)) {
       final ClanGovernment G = CMLib.clans().getStockGovernment(CMath.s_int(last));
       if (G != null) return clearWebMacros(Integer.toString(G.getID()));
     }
     return clearWebMacros(last);
   }
   return "";
 }
예제 #5
0
 @Override
 public float getHttpVer() {
   return request.getHttpVer();
 }
예제 #6
0
 @Override
 public Map<String, Object> getRequestObjects() {
   return request.getRequestObjects();
 }
예제 #7
0
 @Override
 public InetAddress getClientAddress() {
   return request.getClientAddress();
 }
예제 #8
0
 @Override
 public void addFakeUrlParameter(String name, String value) {
   request.addFakeUrlParameter(name, value);
 }
예제 #9
0
 @Override
 public Map<String, String> getUrlParametersCopy() {
   return request.getUrlParametersCopy();
 }
예제 #10
0
 @Override
 public String getUrlPath() {
   return request.getUrlPath();
 }
예제 #11
0
 @Override
 public void removeUrlParameter(String name) {
   request.removeUrlParameter(name);
 }
예제 #12
0
 @Override
 public String getQueryString() {
   return request.getQueryString();
 }
예제 #13
0
 @Override
 public Set<String> getUrlParameters() {
   return request.getUrlParameters();
 }
예제 #14
0
 @Override
 public List<MultiPartData> getMultiParts() {
   return request.getMultiParts();
 }
예제 #15
0
 @Override
 public String getCookie(String name) {
   return request.getCookie(name);
 }
예제 #16
0
 @Override
 public InputStream getBody() {
   return request.getBody();
 }
예제 #17
0
 @Override
 public String getHost() {
   return request.getHost();
 }
예제 #18
0
 @Override
 public String getFullRequest() {
   return request.getFullRequest();
 }
예제 #19
0
 @Override
 public Set<String> getCookieNames() {
   return request.getCookieNames();
 }
예제 #20
0
 @Override
 public String getUrlParameter(String name) {
   return request.getUrlParameter(name);
 }
예제 #21
0
 @Override
 public double getSpecialEncodingAcceptability(String type) {
   return request.getSpecialEncodingAcceptability(type);
 }
예제 #22
0
 @Override
 public boolean isUrlParameter(String name) {
   return request.isUrlParameter(name);
 }
예제 #23
0
 @Override
 public int getClientPort() {
   return request.getClientPort();
 }
예제 #24
0
 @Override
 public String getHeader(String name) {
   return request.getHeader(name);
 }
예제 #25
0
 @Override
 public List<long[]> getRangeAZ() {
   return request.getRangeAZ();
 }
예제 #26
0
 @Override
 public HTTPMethod getMethod() {
   return request.getMethod();
 }
예제 #27
0
  @Override
  public String runMacro(HTTPRequest httpReq, String parm) {
    final java.util.Map<String, String> parms = parseParms(parm);
    final String last = httpReq.getUrlParameter("JOURNAL");
    if (last == null) return " @break@";
    boolean securityOverride = false;
    if ((Thread.currentThread() instanceof CWThread)
        && CMath.s_bool(((CWThread) Thread.currentThread()).getConfig().getMiscProp("ADMIN"))
        && parms.containsKey("ALLFORUMJOURNALS")) securityOverride = true;

    final MOB M = Authenticate.getAuthenticatedMob(httpReq);
    if ((!securityOverride)
        && (CMLib.journals().isArchonJournalName(last))
        && ((M == null) || (!CMSecurity.isASysOp(M)))) return " @break@";

    final Clan setClan = CMLib.clans().getClan(httpReq.getUrlParameter("CLAN"));
    final JournalsLibrary.ForumJournal journal = CMLib.journals().getForumJournal(last, setClan);
    if (journal == null) return " @break@";

    final StringBuffer str = new StringBuffer("");
    if (parms.containsKey("ISSMTPFORWARD")) {
      @SuppressWarnings("unchecked")
      final TreeMap<String, JournalsLibrary.SMTPJournal> set =
          (TreeMap<String, JournalsLibrary.SMTPJournal>)
              Resources.getResource("SYSTEM_SMTP_JOURNALS");
      final JournalsLibrary.SMTPJournal entry =
          (set != null) ? set.get(last.toUpperCase().trim()) : null;
      final String email =
          ((M != null) && (M.playerStats() != null) && (M.playerStats().getEmail() != null))
              ? M.playerStats().getEmail()
              : "";
      str.append(
              ((entry != null) && (email.length() > 0)) ? Boolean.toString(entry.forward) : "false")
          .append(", ");
    }

    if (parms.containsKey("ISSMTPSUBSCRIBER")) {
      final Map<String, List<String>> lists =
          Resources.getCachedMultiLists("mailinglists.txt", true);
      final List<String> mylist = lists.get(last);
      str.append(
              ((mylist != null) && (M != null))
                  ? Boolean.toString(mylist.contains(M.Name()))
                  : "false")
          .append(", ");
    }

    if (parms.containsKey("SMTPADDRESS")) {
      @SuppressWarnings("unchecked")
      final TreeMap<String, JournalsLibrary.SMTPJournal> set =
          (TreeMap<String, JournalsLibrary.SMTPJournal>)
              Resources.getResource("SYSTEM_SMTP_JOURNALS");
      final JournalsLibrary.SMTPJournal entry =
          (set != null) ? set.get(last.toUpperCase().trim()) : null;
      if ((entry != null) && (entry.forward)) {
        str.append(entry.name.replace(' ', '_') + "@" + CMProps.getVar(CMProps.Str.MUDDOMAIN))
            .append(", ");
      }
    }

    if (parms.containsKey("CANADMIN") || parms.containsKey("ISADMIN"))
      str.append("" + journal.authorizationCheck(M, ForumJournalFlags.ADMIN)).append(", ");

    if (parms.containsKey("CANPOST"))
      str.append("" + journal.authorizationCheck(M, ForumJournalFlags.POST)).append(", ");

    if (parms.containsKey("CANREAD"))
      str.append("" + journal.authorizationCheck(M, ForumJournalFlags.READ)).append(", ");

    if (parms.containsKey("CANREPLY"))
      str.append("" + journal.authorizationCheck(M, ForumJournalFlags.REPLY)).append(", ");

    if (parms.containsKey("ADMINMASK")) str.append("" + journal.adminMask()).append(", ");

    if (parms.containsKey("READMASK")) str.append("" + journal.readMask()).append(", ");

    if (parms.containsKey("POSTMASK")) str.append("" + journal.postMask()).append(", ");

    if (parms.containsKey("REPLYMASK")) str.append("" + journal.replyMask()).append(", ");

    if (parms.containsKey("ID")) str.append("" + journal.NAME()).append(", ");

    if (parms.containsKey("NAME")) str.append("" + journal.NAME()).append(", ");

    if (parms.containsKey("EXPIRE")) str.append("").append(", ");

    final JournalsLibrary.JournalSummaryStats stats = CMLib.journals().getJournalStats(journal);
    if (stats == null) return " @break@";

    if (parms.containsKey("POSTS")) str.append("" + stats.posts).append(", ");

    if (parms.containsKey("THREADS")) str.append("" + stats.threads).append(", ");

    if (parms.containsKey("SHORTDESC")) str.append("" + stats.shortIntro).append(", ");

    if (parms.containsKey("LONGDESC")) str.append("" + stats.longIntro).append(", ");

    if (parms.containsKey("IMAGEPATH")) {
      if ((stats.imagePath == null) || (stats.imagePath.trim().length() == 0))
        str.append(L("images/lilcm.jpg")).append(", ");
      else str.append("" + stats.threads).append(", ");
    }

    String strstr = str.toString();
    if (strstr.endsWith(", ")) strstr = strstr.substring(0, strstr.length() - 2);
    return clearWebMacros(strstr);
  }