Ejemplo n.º 1
0
 public boolean isMobileBrowser(String BrowserAgent) {
   if (BrowserAgent == null) return false;
   StringBuilder c_input = new StringBuilder(Server.srv.MOBILE_BROWSER_REGEX);
   c_input.trimToSize();
   Pattern p = Pattern.compile(c_input.toString().toLowerCase());
   Matcher m = p.matcher(BrowserAgent.toLowerCase());
   if (m.find()) {
     Server.log(
         this,
         "found Mobile Browser [" + m.group() + "] (" + BrowserAgent + ")",
         Server.MSG_TRAFFIC,
         Server.LVL_VERBOSE);
     return true;
   } else return false;
 }
Ejemplo n.º 2
0
 public boolean canUseTemplateset(TemplateSet t) {
   if (Server.srv.DEFAULT_TEMPLATESET == null || t == null) return true;
   StringBuffer defaultTs = new StringBuffer(Server.srv.DEFAULT_TEMPLATESET);
   if (defaultTs != null) {
     StringTokenizer st = new StringTokenizer(defaultTs.toString(), ",");
     while (st.hasMoreTokens()) {
       StringBuilder templateName = new StringBuilder(st.nextToken());
       if (templateName.toString().equals(t.getName())) return true;
     }
   }
   if (Server.DEBUG) {
     StringBuffer scn = new StringBuffer();
     scn.append(" can not use Template ");
     scn.append(t.getName());
     Server.log(this, scn.toString(), Server.MSG_TRAFFIC, Server.LVL_MINOR);
   }
   return false;
 }
Ejemplo n.º 3
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();
  }