예제 #1
0
 public void execute(Object[] args) {
   StringBuffer sb = (StringBuffer) args[0];
   String SiteID = (String) args[1];
   if (!SiteUtil.isBBSEnable(SiteID)) {
     return;
   }
   sb.append("<ul class='sidemenu'>");
   sb.append(
       "<li id='Menu_Fav'><a href='"
           + Config.getContextPath()
           + "Shop/Web/Favorite.jsp?cur=Menu_Fav&SiteID="
           + SiteID
           + "'>我的收藏夹</a></li>");
   sb.append(
       "<li id='Menu_SC'><a href='"
           + Config.getContextPath()
           + "Shop/Web/ShopCart.jsp?cur=Menu_SC&SiteID="
           + SiteID
           + "'>我的购物车</a></li>");
   sb.append(
       "<li id='Menu_MO'><a href='"
           + Config.getContextPath()
           + "Shop/Web/MemberOrder.jsp?cur=Menu_MO&SiteID="
           + SiteID
           + "'>我的订单</a></li>");
   sb.append(
       "<li id='Menu_ME'><a href='"
           + Config.getContextPath()
           + "Shop/Web/MemberEvaluate.jsp?cur=Menu_ME&SiteID="
           + SiteID
           + "'>商品评价</a></li>");
   sb.append(
       "<li id='Menu_ADR'><a href='"
           + Config.getContextPath()
           + "Shop/Web/MemberAddress.jsp?cur=Menu_ADR&SiteID="
           + SiteID
           + "'>收货地址管理</a></li>");
   sb.append("</ul>");
   sb.append("<hr class='shadowline'/>");
 }
예제 #2
0
 public void getNewMessage() {
   if (!Config.isInstalled) {
     redirect(Config.getContextPath() + "Install.jsp");
     return;
   }
   this.Response.put("Count", MessageCache.getNoReadCount());
   String message = MessageCache.getFirstPopMessage();
   if (StringUtil.isEmpty(message)) {
     this.Response.put("PopFlag", "0");
   } else {
     this.Response.put("Message", message);
     this.Response.put("PopFlag", "1");
   }
 }
예제 #3
0
 public void dealFile(String fileName, byte[] bs) {
   try {
     bs = convertCharset(bs);
   } catch (UnsupportedEncodingException e) {
     e.printStackTrace();
   }
   fileName = fileName.substring("File:".length());
   this.task.setCurrentInfo("正在导入站点文件:" + fileName);
   String root =
       Config.getContextRealPath()
           + Config.getValue("Statical.TargetDir")
           + "/"
           + this.map.getString("Alias");
   root = root + "/";
   fileName = root + fileName;
   fileName = fileName.replaceAll("[\\\\/]+", "/");
   String dirName = fileName.substring(0, fileName.lastIndexOf('/'));
   File dir = new File(dirName);
   if (!dir.exists()) {
     dir.mkdirs();
   }
   FileUtil.writeByte(fileName, bs);
 }
예제 #4
0
 private void prepareList()
 {
   if (this.list == null) {
     String path = Config.getContextRealPath() + CrawlConfig.getWebGatherDir();
     if ((!path.endsWith("/")) && (!path.endsWith("\\"))) {
       path = path + "/";
     }
     path = path + this.config.getID() + "/";
     File f = new File(path);
     if (!f.exists()) {
       f.mkdirs();
     }
     this.list = new DocumentList(path);
   }
 }
예제 #5
0
 public static void loadConfig() {
   if (map == null) {
     map = new Mapx();
     String path = Config.getContextRealPath() + "WEB-INF/classes/framework.xml";
     if (!(new File(path).exists())) {
       return;
     }
     SAXReader reader = new SAXReader(false);
     try {
       Document doc = reader.read(new File(path));
       Element root = doc.getRootElement();
       Element extend = root.element("extend");
       if (extend != null) {
         List types = extend.elements("action");
         for (int i = 0; i < types.size(); ++i) {
           Element type = (Element) types.get(i);
           String className = type.attributeValue("class");
           try {
             Object obj = Class.forName(className).newInstance();
             if (!(obj instanceof IExtendAction)) {
               LogUtil.getLogger().warn("类" + className + "必须继承IExtendAction!");
             }
             IExtendAction action = (IExtendAction) obj;
             ArrayList list = (ArrayList) map.get(action.getTarget());
             if (list == null) {
               list = new ArrayList();
             }
             list.add(action);
             map.put(action.getTarget(), list);
           } catch (InstantiationException e) {
             e.printStackTrace();
           } catch (IllegalAccessException e) {
             e.printStackTrace();
           } catch (ClassNotFoundException e) {
             e.printStackTrace();
           }
         }
       }
     } catch (DocumentException e) {
       e.printStackTrace();
     }
   }
 }
예제 #6
0
   public DocumentList crawl() {
     prepareList();
     try {
       this.list.setCrawler(this);
       this.fileDownloader
         .setDenyExtension(".gif.jpg.jpeg.swf.bmp.png.js.wmv.css.ico.avi.mpg.mpeg.mp3.mp4.wma.rm.rmvb.exe.tar.gz.zip.rar");
       this.fileDownloader.setThreadCount(this.config.getThreadCount());
       this.fileDownloader.setTimeout(this.config.getTimeout() * 1000);
 
       if (this.config.isProxyFlag()) {
         this.fileDownloader.setProxyFlag(this.config.isProxyFlag());
         this.fileDownloader.setProxyHost(this.config.getProxyHost());
         this.fileDownloader.setProxyPassword(this.config.getProxyPassword());
         this.fileDownloader.setProxyUserName(this.config.getProxyUserName());
         this.fileDownloader.setProxyPort(this.config.getProxyPort());
       } else if ("Y".equalsIgnoreCase(Config.getValue("Proxy.IsUseProxy"))) {
         this.fileDownloader.setProxyFlag(true);
         this.fileDownloader.setProxyHost(Config.getValue("Proxy.Host"));
         this.fileDownloader.setProxyPassword(Config.getValue("Proxy.Password"));
         this.fileDownloader.setProxyUserName(Config.getValue("Proxy.UserName"));
         this.fileDownloader.setProxyPort(Integer.parseInt(Config.getValue("Proxy.Port")));
       }
 
       prepareScript();
       for (int i = 0; (i < this.config.getUrlLevels().length) && (i <= this.config.getMaxLevel()); ++i) {
         try {
           if ((i >= this.startLevel) || (this.task.checkStop()))
           {
             this.task.setCurrentInfo("正在处理第" + (i + 1) + "层级URL");
             this.currentLevel = i;
             dealOneLevel();
           }
         } catch (Throwable e) {
           e.printStackTrace();
         }
       }
       if (this.task.checkStop())
         break label457;
       if (this.config.isCopyImageFlag()) {
         int maxPage = this.config.getMaxPageCount();
         this.config.setMaxPageCount(-1);
         this.fileDownloader
           .setDenyExtension(".html.htm.jsp.php.asp.shtml.swf.js.css.ico.avi.mpg.mpeg.mp3.mp4.wma.wmv.rm.rmvb.exe.tar.gz.zip.rar");
         this.currentLevel += 1;
         this.task.setCurrentInfo("正在处理第" + (this.currentLevel + 1) + "层级URL");
         String[] urls = this.config.getUrlLevels();
         urls = (String[])
           ArrayUtils.add(urls, 
           "${A}.gif\n${A}.jpg\n${A}.jpeg\n${A}.png\n${A}.bmp\n${A}.GIF\n${A}.JPG\n${A}.JPEG\n${A}.PNG\n${A}.BMP");
         this.config.setUrlLevels(urls);
         dealOneLevel();
         this.config.setMaxPageCount(maxPage);
         this.fileDownloader
           .setDenyExtension(".gif.jpg.jpeg.swf.bmp.png.js.wmv.css.ico.avi.mpg.mpeg.mp3.mp4.wma.rm.rmvb.exe.tar.gz.zip.rar");
       }
       retryWithFilter();
       label457: writeArticle();
     }
     catch (Exception e1) {
       e1.printStackTrace();
       return null;
     } finally {
       this.list.save();
       this.list.close();
     }
     return this.list;
   }
예제 #7
0
  public void dealZCSite(DataRow dr) {
    if (this.isNewSite) {
      if ((LicenseInfo.getName().equals("TrailUser"))
          && (new QueryBuilder("select count(*) from ZCSite").executeInt() >= 1)) {
        throw new RuntimeException("站点数超出限制,请联系泽元软件更换License!");
      }
      this.newSiteID = NoUtil.getMaxID("SiteID");
      ZCSiteSchema site = new ZCSiteSchema();
      site.setValue(dr);
      site.setID(this.newSiteID);
      site.setName(this.map.getString("Name"));
      site.setAlias(this.map.getString("Alias"));
      site.setURL(this.map.getString("URL"));
      site.setHitCount(0L);
      site.setChannelCount(0L);
      site.setSpecialCount(0L);
      site.setMagzineCount(0L);
      site.setArticleCount(0L);
      site.setImageLibCount(1L);
      site.setVideoLibCount(1L);
      site.setAudioLibCount(1L);
      site.setAttachmentLibCount(1L);
      site.setBranchInnerCode(User.getBranchInnerCode());
      site.setAddTime(new Date());
      site.setAddUser(User.getUserName());
      site.setConfigXML(ConfigImageLib.imageLibConfigDefault);
      this.da.insert(site);
      Transaction trans = new Transaction();
      Site.addDefaultPriv(this.newSiteID, trans);
      trans.setDataAccess(this.da);
      trans.commit(false);
      addIDMapping("ZCSite", String.valueOf(this.siteID), String.valueOf(this.newSiteID));
    } else {
      ZCSiteSchema site = new ZCSiteSchema();
      site.setID(this.map.getString("ID"));
      this.newSiteID = site.getID();
      site.fill();

      this.task.setCurrentInfo("正在备份数据,可能需要较长时间,请耐心等待");

      SiteExporter se = new SiteExporter(site.getID());
      se.exportSite(
          Config.getContextRealPath()
              + "WEB-INF/data/backup/"
              + site.getAlias()
              + "_"
              + System.currentTimeMillis()
              + ".dat");

      addIDMapping("ZCSite", dr.getString("ID"), String.valueOf(site.getID()));
      this.da.deleteAndBackup(site);
      BlockingTransaction tran = new BlockingTransaction(this.da);
      Site.delSiteRela(site.getID(), tran);

      String sitePath =
          Config.getContextRealPath()
              + Config.getValue("Statical.TemplateDir")
              + "/"
              + site.getAlias();
      FileUtil.delete(sitePath);

      site = new ZCSiteSchema();
      site.setValue(dr);

      this.da.insert(site);
    }
  }