userconfigdb.java

来自「cwbbs 云网论坛源码」· Java 代码 · 共 877 行 · 第 1/2 页

JAVA
877
字号
    public void setUserName(String userName) {        this.userName = userName;    }    public void setTitle(String title) {        this.title = title;    }    public void setSubtitle(String subtitle) {        this.subtitle = subtitle;    }    public void setPenName(String penName) {        this.penName = penName;    }    public void setSkin(String skin) {        this.skin = skin;    }    public void setNotice(String notice) {        this.notice = notice;    }    public void setValid(boolean valid) {        this.valid = valid;    }    public void setViewCount(int viewCount) {        this.viewCount = viewCount;    }    public void setMsgCount(int msgCount) {        this.msgCount = msgCount;    }    public void setReplyCount(int replyCount) {        this.replyCount = replyCount;    }    public void setKind(String kind) {        this.kind = kind;    }    public void setId(long id) {        this.id = id;    }    public void setType(int type) {        this.type = type;    }    public void setUpdateDate(java.util.Date updateDate) {        this.updateDate = updateDate;    }    public void setIcon(String icon) {        this.icon = icon;    }    public void setFriends(String friends) {        this.friends = friends;    }    public void setFootprint(boolean footprint) {        this.footprint = footprint;    }    public void setDomain(String domain) {        this.domain = domain;    }    public void setBkMusic(boolean bkMusic) {        this.bkMusic = bkMusic;    }    public void setUserCss(boolean userCss) {        this.userCss = userCss;    }    public void setCssPath(String cssPath) {        this.cssPath = cssPath;    }    public void setPhotoDig(boolean photoDig) {        this.photoDig = photoDig;    }    public void setAddDate(Date addDate) {        this.addDate = addDate;    }    public String getUserName() {        return userName;    }    public String getTitle() {        return title;    }    public String getSubtitle() {        return subtitle;    }    public String getPenName() {        return penName;    }    public String getSkin() {        return skin;    }    public String getNotice() {        return notice;    }    public java.util.Date getAddDate() {        return addDate;    }    public boolean isValid() {        return valid;    }    public int getViewCount() {        return viewCount;    }    public int getMsgCount() {        return msgCount;    }    public int getReplyCount() {        return replyCount;    }    public String getKind() {        return kind;    }    public long getId() {        return id;    }    public int getType() {        return type;    }    public java.util.Date getUpdateDate() {        return updateDate;    }    public String getIcon() {        return icon;    }    public String getFriends() {        return friends;    }    public void initDB() {        this.tableName = "blog_user_config";        primaryKey = new PrimaryKey("id", PrimaryKey.TYPE_LONG);        objectCache = new UserConfigCache(this);        this.QUERY_DEL =                "delete FROM " + tableName + " WHERE id=?";        this.QUERY_CREATE =                "INSERT into " + tableName + " (userName,title,subtitle,penName,skin,notice,kind,addDate,id,blog_type,icon,is_footprint,domain,is_bk_music,is_user_css) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,0,0)";        this.QUERY_LOAD =                "SELECT title,subtitle,penName,skin,notice,addDate,isValid,viewCount,msgCount,replyCount,kind,blog_type,userName,update_date,icon,friends,is_footprint,domain,is_bk_music,is_user_css,css_path,is_photo_dig FROM " +                tableName + " WHERE id=?";        this.QUERY_SAVE =                "UPDATE " + tableName +                " SET title=?,subtitle=?,penName=?,skin=?,notice=?,isValid=?,viewCount=?,msgCount=?,replyCount=?,kind=?,blog_type=?,update_date=?,icon=?,friends=?,is_footprint=?,domain=?,is_bk_music=?,is_user_css=?,css_path=?,is_photo_dig=? WHERE id=?";        this.QUERY_LIST = "select id from " + tableName +                          " order by addDate desc";        isInitFromConfigDB = false;    }    public boolean isFootprint() {        return footprint;    }    public String getDomain() {        return domain;    }    public boolean isBkMusic() {        return bkMusic;    }    public boolean isUserCss() {        return userCss;    }    public String getCssPath() {        return cssPath;    }    public boolean isPhotoDig() {        return photoDig;    }    public String getCSS(HttpServletRequest request) {        if (!userCss) {            TemplateDb td = new TemplateDb();            td = td.getTemplateDb(StrUtil.toInt(skin));            if (td==null)                return "";            else                return request.getContextPath() + "/blog/skin/" + td.getString("code") + "/skin.css";        }        else {                        return getUserDefinedCSSUrl(request);        }    }    public String getUserDefinedCSSUrl(HttpServletRequest request) {        chkAndCreateCSSFile(request);        com.redmoon.forum.Config cfg = com.redmoon.forum.Config.getInstance();        String basePath = request.getContextPath() + "/upfile/" +                                    cssBasePath + "/";        boolean isFtpUsed = cfg.getBooleanProperty("forum.ftpUsed");        if (isFtpUsed) {            basePath = cfg.getRemoteBaseUrl();            basePath += cssBasePath + "/";        }        return basePath + cssPath;    }        public String createDefaultCSSFile(HttpServletRequest request) {        String path = cssBasePath;        Calendar cal = Calendar.getInstance();        String year = "" + (cal.get(cal.YEAR));        String month = "" + (cal.get(cal.MONTH) + 1);        if (cssPath.equals(""))            path += "/" + year + "/" + month + "/" + id + ".css";        else            path += "/" + cssPath;        com.redmoon.forum.Config cfg = com.redmoon.forum.Config.getInstance();        boolean isFtpUsed = cfg.getBooleanProperty("forum.ftpUsed");                FileUtil fu = new FileUtil();        String tmpFileRealPath = Global.realPath + "upfile/tmp_blog_css_" + id + ".css";        TemplateDb td = new TemplateDb();        td = td.getTemplateDb(StrUtil.toInt(skin));        try {            String css = "";            css = fu.ReadFile(Global.realPath + "blog/skin/" + td.getString("code") + "/skin.css");            css = css.replaceAll("images/", request.getContextPath() + "/blog/skin/" + td.getString("code") + "/images/");            fu.WriteFileUTF8(tmpFileRealPath, css);        }        catch (IOException e) {            LogUtil.getLog(getClass()).error("chkAndCreateCSSFile:" + e.getMessage());        }        FTPUtil ftp = new FTPUtil();        if (isFtpUsed) {            try {                boolean retFtp = ftp.connect(cfg.getProperty(                        "forum.ftpServer"),                                             cfg.getIntProperty("forum.ftpPort"),                                             cfg.getProperty("forum.ftpUser"),                                             cfg.getProperty("forum.ftpPwd"), true);                if (!retFtp) {                    LogUtil.getLog(getClass()).error("writeFile:" +                            ftp.getReplyMessage());                } else {                    try {                        ftp.storeFile(path,                                      tmpFileRealPath);                    } catch (IOException e1) {                        LogUtil.getLog(getClass()).error(                                "AddNewWE: storeFile - " +                                e1.getMessage());                    }                }            } finally {                ftp.close();            }        } else {                        String fullPath = Global.realPath + "upfile/" + path;            int p = fullPath.lastIndexOf("/");            String pa = fullPath.substring(0, p);                        File f = new File(pa);            if (!f.isDirectory())                f.mkdirs();            fu.CopyFile(tmpFileRealPath,                        fullPath);                    }                File f = new File(tmpFileRealPath);        f.delete();        return year + "/" + month + "/" + id + ".css";    }        public void chkAndCreateCSSFile(HttpServletRequest request) {                if (!cssPath.equals(""))            return;        String p = createDefaultCSSFile(request);        if (!p.equals("")) {            cssPath = p;            try {                save();            }            catch (ResKeyException e) {                LogUtil.getLog(getClass()).error("chkAndCreateCSSFile:" + e.getMessage(request));            }        }    }    public String getCSSContent(HttpServletRequest request) {        chkAndCreateCSSFile(request);        String tmpRemoteFilePath = "";        Config cfg = Config.getInstance();        boolean isFtpUsed = cfg.getBooleanProperty("forum.ftpUsed");        if (isFtpUsed) {            String basePath = cfg.getProperty("forum.ftpUrl");                        String remoteFileName = RobotUtil.gatherFile(basePath + "/" +                    cssBasePath + "/" +                    cssPath, "utf-8", Global.realPath +                    "upfile" + "/");            if (!remoteFileName.equals("")) {                try {                    tmpRemoteFilePath = Global.realPath +                                        "upfile" + "/" +                                        remoteFileName;                    String s = FileUtil.ReadFile(tmpRemoteFilePath);                    return s;                } catch (Exception e) {                    logger.error("getCSSContent1:" +                                 StrUtil.trace(e));                }                finally {                    File f = new File(tmpRemoteFilePath);                    f.delete();                }            }        }        else {            try {                String p = Global.realPath + "upfile/" + cssBasePath + "/" + cssPath;                return FileUtil.ReadFile(p);            }            catch (IOException e) {                LogUtil.getLog(getClass()).error("getCSSContent2:" + e.getMessage());            }        }        return "";    }    public void modifyCSSFile(HttpServletRequest request) {        String content = ParamUtil.get(request, "content");        content = cn.js.fan.security.AntiXSS.antiXSS(content);        String basePath = cssBasePath;        com.redmoon.forum.Config cfg = com.redmoon.forum.Config.getInstance();        boolean isFtpUsed = cfg.getBooleanProperty("forum.ftpUsed");        FTPUtil ftp = new FTPUtil();        if (isFtpUsed) {            try {                                FileUtil fu = new FileUtil();                String tmpFileRealPath = Global.realPath + "upfile/tmp_blog_" + id +                                         ".css";                fu.WriteFileUTF8(tmpFileRealPath, content);                boolean retFtp = ftp.connect(cfg.getProperty(                        "forum.ftpServer"),                                             cfg.getIntProperty("forum.ftpPort"),                                             cfg.getProperty("forum.ftpUser"),                                             cfg.getProperty("forum.ftpPwd"), true);                if (!retFtp) {                    LogUtil.getLog(getClass()).error("writeFile:" +                            ftp.getReplyMessage());                } else {                    try {                        ftp.storeFile(basePath + "/" + cssPath,                                      tmpFileRealPath);                    } catch (IOException e1) {                        LogUtil.getLog(getClass()).error(                                "AddNewWE: storeFile - " +                                e1.getMessage());                    }                }                                File f = new File(tmpFileRealPath);                f.delete();            } finally {                ftp.close();            }        } else {            FileUtil.WriteFileUTF8(Global.realPath + "upfile/" + basePath + "/" + cssPath, content);        }    }    private String userName;    private String title;    private String subtitle;    private String penName;    private String skin;    private String notice;    private java.util.Date addDate;    private boolean valid = true;    private int viewCount = 0;    private int msgCount = 0;    private int replyCount = 0;    private String kind;    private long id;    private int type = TYPE_PERSON;    private java.util.Date updateDate;    private String icon;    private String friends;    private boolean footprint = true;    private String domain;    private boolean bkMusic = false;    private boolean userCss = false;    private String cssPath = "";    private boolean photoDig = true;}

⌨️ 快捷键说明

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