⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msgdb.java

📁 cwbbs 云网论坛源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        content = AntiXSS.antiXSS(content);        expression = StrUtil.toInt(mfu.getFieldValue("expression"), EXPRESSION_NONE);        ip = mfu.getFieldValue("ip");        String stremail_notify = mfu.getFieldValue("email_notify");        if (stremail_notify == null || stremail_notify.equals(""))            email_notify = 0;        else {            email_notify = Integer.parseInt(stremail_notify);        }        String strmsg_notify = mfu.getFieldValue("msg_notify");        if (strmsg_notify == null || strmsg_notify.equals(""))            msgNotify = 0;        else            msgNotify = Integer.parseInt(strmsg_notify);        String strsms_notify = mfu.getFieldValue("sms_notify");        if (strsms_notify == null || strsms_notify.equals(""))            smsNotify = 0;        else            smsNotify = Integer.parseInt(strsms_notify);        String strIsBlog = StrUtil.getNullStr(mfu.getFieldValue("isBlog"));        if (strIsBlog.equals("1"))            blog = true;        else {            if (boardcode.equals(Leaf.CODE_BLOG))                blog = true;            else                blog = false;        }        if (blog) {            blogUserDir = mfu.getFieldValue("blogUserDir");            UserConfigDb ucd = new UserConfigDb();            String strBlogId = StrUtil.getNullStr(mfu.getFieldValue("blogId"));            blogId = UserConfigDb.NO_BLOG;            if (!strBlogId.equals("")) {                try {                    blogId = Long.parseLong(strBlogId);                } catch (Exception e) {                }            }            if (blogId == UserConfigDb.NO_BLOG) {                ucd = ucd.getUserConfigDbByUserName(Privilege.getUser(request));            } else {                ucd = ucd.getUserConfigDb(blogId);            }            blogId = ucd.getId();            isLocked = StrUtil.toInt(mfu.getFieldValue("isLocked"), 0);            blogDirCode = StrUtil.getNullStr(mfu.getFieldValue("blogDirCode"));                    }        plugin2Code = StrUtil.getNullStr(mfu.getFieldValue("plugin2Code")).trim();        pluginCode = StrUtil.getNullStr(mfu.getFieldValue("pluginCode")).trim();        if (!errMsg.equals("")) {            throw new ErrMsgException(errMsg);        }                ForumFilter.filterMsg(request, title);        ForumFilter.filterMsg(request, content);        isWebedit = this.WEBEDIT_REDMOON;                TimeConfig tc = new TimeConfig();        if (tc.isPostNeedCheck(request)) {            checkStatus = CHECK_STATUS_NOT;        } else {            Leaf lf = new Leaf();            lf = lf.getLeaf(boardcode);            checkStatus = lf.getCheckMsg() == lf.CHECK_NOT ? CHECK_STATUS_PASS :                          CHECK_STATUS_NOT;        }        String strThreadType = StrUtil.getNullStr(mfu.getFieldValue(                "threadType"));        if (strThreadType.equals(""))            threadType = ThreadTypeDb.THREAD_TYPE_NONE;        else            threadType = Integer.parseInt(strThreadType);        Config cfg = Config.getInstance();        Privilege pvg = new Privilege();                if (cfg.getBooleanProperty("forum.isTag") && pvg.isUserLogin(request)) {                        String tag = StrUtil.getNullStr(mfu.getFieldValue("tag")).                         trim();            if (!tag.equals("")) {                                int tagLenMax = cfg.getIntProperty("forum.tagLenMax");                if (tag.length()>tagLenMax) {                    String limit = StrUtil.format(SkinUtil.LoadString(request, "res.label.forum.showtopic", "tag_limit"), new Object[] { new Integer(cfg.getIntProperty("forum.tagLenMax")) });                    throw new ErrMsgException(limit);                }                tag = tag.replaceAll(" ", " ");                 tag = tag.replaceAll(" +", " ");                                 Pattern pa = Pattern.compile("[^\u4e00-\u9fa5 \\w]+",                                             Pattern.CANON_EQ);                Matcher m = pa.matcher(tag);                if (m.find()) {                    throw new ErrMsgException(SkinUtil.LoadString(request, "res.label.forum.showtopic", "tag_format"));                }                int tagSingleLenMax = cfg.getIntProperty("forum.tagSingleLenMax");                String[] ary = tag.split(" ");                                int len = ary.length;                tempTagNameVector = new Vector();                for (int i = 0; i < len; i++) {                    String tagName = ary[i];                    boolean isRepeat = false;                    for (int j = i + 1; j < len; j++) {                        if (ary[j].equals(tagName)) {                            isRepeat = true;                            break;                        }                    }                    if (!isRepeat) {                        if (tagName.length()>tagSingleLenMax) {                            String limit = tagName + " - " + StrUtil.format(SkinUtil.LoadString(request, "res.label.forum.showtopic", "tag_single_limit"), new Object[] { new Integer(tagSingleLenMax) });                            throw new ErrMsgException(limit);                        }                        tempTagNameVector.addElement(tagName);                    }                }            }        }        return true;    }    public boolean setBoardNewAddId(long id) {        Leaf lf = new Leaf();        lf = lf.getLeaf(boardcode);        if (lf==null)            return false;        lf.setAddId(id);                return lf.update();    }        public static String getCurAttVisualPath() {        Calendar cal = Calendar.getInstance();        int year = cal.get(cal.YEAR);        int month = cal.get(cal.MONTH) + 1;        return year + "/" + month;    }        public boolean AddNewWE(ServletContext application,                            HttpServletRequest request,                            String name, MultiFileUpload mfu) throws            ErrMsgException {        CheckTopicWE(request, mfu);                int msgType = 0;        String isvote = mfu.getFieldValue("isvote");        String[] voptions = null;        if (isvote != null && isvote.equals("1")) {            String voteoption = mfu.getFieldValue("vote").trim();            if (!voteoption.equals("")) {                voptions = voteoption.split("\n");            }            if (voptions != null) {                 msgType = TYPE_VOTE;            }                                }        int writeAttachmentResult = mfu.WRITE_ATTACHMENT_SUCCEED;        String sql = "";        int length = 0;        if (title != null)            length = title.length();        if (length < MIN_TOPIC_LEN)            throw new ErrMsgException(LoadString(request, "err_too_short_title") +                                      MIN_TOPIC_LEN);         if (length > MAX_TOPIC_LEN)            throw new ErrMsgException(LoadString(request, "err_too_large_title") +                                      MAX_TOPIC_LEN);         if (content != null)            length = content.length();        if (length < MIN_CONTENT_LEN)            throw new ErrMsgException(LoadString(request,                                                 "err_too_short_content") +                                      MIN_CONTENT_LEN);        if (length > MAX_CONTENT_LEN_WE)            throw new ErrMsgException(LoadString(request,                                                 "err_too_large_content") +                                      MAX_CONTENT_LEN);        id = SequenceMgr.nextID();        int intIsBlog = blog ? 1 : 0;        int ret = mfu.getRet();        Config cfg = Config.getInstance();        boolean isFtpUsed = cfg.getBooleanProperty("forum.ftpUsed");        if (ret == FileUpload.RET_SUCCESS) {            boolean isDdxc = false;            String sisDdxc = StrUtil.getNullString(mfu.getFieldValue("isDdxc"));                        if (sisDdxc.equals("true"))                isDdxc = true;            String filepath = StrUtil.getNullString(mfu.getFieldValue(                    "filepath"));            String virtualpath = getCurAttVisualPath();                                                            String tempAttachFilePath = Global.getRealPath() + Config.getInstance().getAttachmentPath() + "/" +                                        getCurAttVisualPath() +                                        "/";            mfu.setSavePath(tempAttachFilePath);             File f = new File(tempAttachFilePath);            if (!f.isDirectory()) {                f.mkdirs();            }            FTPUtil ftp = new FTPUtil();            if (isFtpUsed) {                boolean retFtp = ftp.connect(cfg.getProperty(                        "forum.ftpServer"),                                             cfg.getIntProperty("forum.ftpPort"),                                             cfg.getProperty("forum.ftpUser"),                                             cfg.getProperty("forum.ftpPwd"), true);                if (!retFtp) {                    ftp.close();                    throw new ErrMsgException("FTP:" + ftp.getReplyMessage());                }            }            boolean issuccess = true;            Conn conn = new Conn(connname);            boolean re = false;            try {                conn.beginTrans();                                String insertThreadSql = "insert into sq_thread (id,boardcode,msg_level,iselite,lydate,redate,name,blogUserDir,isBlog,check_status,thread_type,blog_id,blog_dir_code) values (?,?,?,?,?,?,?,?,?,?,?,?,?)";                PreparedStatement ps = conn.prepareStatement(insertThreadSql);                ps.setLong(1, id);                ps.setString(2, boardcode);                ps.setInt(3, level);                ps.setInt(4, isElite);                ps.setString(5, "" + System.currentTimeMillis());                ps.setString(6, "" + System.currentTimeMillis());                ps.setString(7, name);                ps.setString(8, blogUserDir);                ps.setInt(9, blog ? 1 : 0);                ps.setInt(10, checkStatus);                ps.setInt(11, threadType);                ps.setLong(12, blogId);                ps.setString(13, blogDirCode);                conn.executePreUpdate();                if (ps != null) {                    ps.close();                    ps = null;                }                sql = "insert into sq_message (id,rootid,boardcode,name,title,content,length,expression,lydate,ip,MSG_TYPE,show_ubbcode,show_smile,iswebedit,redate,colorExpire,boldExpire,isBlog,blogUserDir,plugin2Code,email_notify,thread_type,pluginCode,check_status,replyid,blog_id,islocked,blog_dir_code,msg_notify,sms_notify) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,-1,?,?,?,?,?)";                ps = conn.prepareStatement(sql);                ps.setLong(1, id);                ps.setLong(2, id);                ps.setString(3, boardcode);                ps.setString(4, name);                ps.setString(5, title);                ps.setString(6, content);                ps.setInt(7, length);                ps.setInt(8, expression);                ps.setString(9, "" + System.currentTimeMillis());                ps.setString(10, ip);                ps.setInt(11, msgType);                ps.setInt(12, show_ubbcode);                ps.setInt(13, show_smile);                ps.setInt(14, isWebedit);                ps.setString(15, "" + System.currentTimeMillis());                ps.setString(16, "" + System.currentTimeMillis());                ps.setString(17, "" + System.currentTimeMillis());                ps.setInt(18, intIsBlog);                ps.setString(19, blogUserDir);                ps.setString(20, plugin2Code);                ps.setInt(21, email_notify);                ps.setInt(22, threadType);                ps.setString(23, pluginCode);                ps.setInt(24, checkStatus);                ps.setLong(25, blogId);                ps.setInt(26, isLocked);                ps.setString(27, blogDirCode);                ps.setInt(28, msgNotify);                ps.setInt(29, smsNotify);                re = conn.executePreUpdate() == 1 ? true : false;                conn.commit();                                if (!name.equals("")) {                    if (cfg.getBooleanProperty("forum.isTag")) {                                                if (tempTagNameVector != null) {                                                        TagMsgDb tmd = new TagMsgDb();                            tmd.createForMsg(id, tempTagNameVector, name);                        }                    }                }                if (voptions != null) {                    MsgPollDb mpd = new MsgPollDb();                    String epdate = StrUtil.getNullString(mfu.getFieldValue(                            "expire_date"));                    java.util.Date expireDate = DateUtil.parse(epdate,                            "yyyy-MM-dd");                    String strMaxChoices = StrUtil.getNullString(mfu.                            getFieldValue("max_choice"));                    int maxChoices = StrUtil.toInt(strMaxChoices, 1);                                        mpd.create(new JdbcTemplate(), new Object[] {                        new Long(id), expireDate, new Integer(maxChoices)                    });                    int vlen = voptions.length;                                        MsgPollOptionDb mpod = new MsgPollOptionDb();                    for (int i = 0; i < vlen; i++) {                        mpod.create(new JdbcTemplate(), new Object[] {

⌨️ 快捷键说明

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