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

📄 msgdb.java

📁 cwbbs 云网论坛源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    upd = upd.getUserPrivDb(name);                    upd.addAttachTodayUploadCount(i);                }            }            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(fu.getFieldValue(                        "expire_date"));                java.util.Date expireDate = DateUtil.parse(epdate, "yyyy-MM-dd");                String strMaxChoices = StrUtil.getNullString(fu.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[] {                        new Long(id), new Integer(i), voptions[i]                    });                }            }            re = true;                        String[] tmpAttachIds = fu.getFieldValues("tmpAttachId");            if (tmpAttachIds != null) {                int len = tmpAttachIds.length;                for (int k = 0; k < len; k++) {                    Attachment att = new Attachment(Long.parseLong(tmpAttachIds[                            k]));                    att.setMsgId(id);                    att.save();                }                if (!name.equals("")) {                                        ScoreMgr sm = new ScoreMgr();                    Vector vatt = sm.getAllScore();                    Iterator iratt = vatt.iterator();                    while (iratt.hasNext()) {                        ScoreUnit su = (ScoreUnit) iratt.next();                        IPluginScore ips = su.getScore();                        if (ips != null)                            ips.onAddAttachment(name, tmpAttachIds.length);                    }                }            }                        if (!name.equals("")) {                UserDb user = new UserDb();                user = user.getUser(name);                user.setAddCount(user.getAddCount() + 1);                user.save();            }                        if (blog) {                UserConfigDb ucd = new UserConfigDb();                ucd = ucd.getUserConfigDb(blogId);                ucd.setMsgCount(ucd.getMsgCount() + 1);                ucd.setUpdateDate(new java.util.Date());                ucd.save();            }                        if (checkStatus == CHECK_STATUS_PASS) {                setBoardNewAddId(id);                                setBoardStatistic(true, id);            }        } catch (SQLException e) {            conn.rollback();            Logger.getLogger(MsgDb.class.getName()).error("AddNew:" +                    e.getMessage());            throw new ResKeyException(new SkinUtil(), SkinUtil.ERR_DB);        } finally {            if (re) {                                MsgCache mc = new MsgCache();                mc.refreshAdd(boardcode, blogId, blog, blogUserDir);            }            if (conn != null) {                conn.close();                conn = null;            }        }        return re;    }        public boolean create() {        boolean re = false;        id = SequenceMgr.nextID();        Conn conn = new Conn(connname);        try {            conn.beginTrans();                        String sql = "insert into sq_thread (id,boardcode,msg_level,iselite,lydate,redate,name,blogUserDir,isBlog,check_status,thread_type) values (?,?,?,?,?,?,?,?,?,?,?)";            PreparedStatement ps = conn.prepareStatement(sql);            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);            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) 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, content.length());            ps.setInt(8, expression);            ps.setString(9, "" + System.currentTimeMillis());            ps.setString(10, ip);            ps.setInt(11, type);            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, blog?1:0);            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);            conn.executePreUpdate();            if (ps != null) {                ps.close();                ps = null;            }            conn.commit();            re = true;        }        catch (SQLException e) {            conn.rollback();            LogUtil.getLog("create:" + e.getMessage());        }        finally {            if (re) {                                MsgCache mc = new MsgCache();                mc.refreshAdd(boardcode, blogId, blog, blogUserDir);            }            if (conn!=null) {                conn.close();                conn = null;            }        }        return true;    }        public boolean checkMsg(int newCheckStatus) throws ResKeyException {        checkStatus = newCheckStatus;        String sql = "update sq_message set check_status=? where id=?";        String tsql = "update sq_thread set check_status=? where id=?";        boolean re = false;        Conn conn = new Conn(connname);        try {            conn.beginTrans();            PreparedStatement ps = conn.prepareStatement(sql);            ps.setInt(1, newCheckStatus);            ps.setLong(2, id);            re = conn.executePreUpdate() == 1 ? true : false;            ps.close();            if (isRootMsg()) {                ps = conn.prepareStatement(tsql);                ps.setInt(1, newCheckStatus);                ps.setLong(2, id);                re = conn.executePreUpdate() == 1 ? true : false;            }            if (re) {                MsgCache mc = new MsgCache();                if (isRootMsg()) {                    conn.commit();                                        mc.refreshAdd(boardcode, blogId, blog, blogUserDir);                    if (checkStatus == CHECK_STATUS_PASS) {                        setBoardNewAddId(id);                                                setBoardStatistic(true, id);                    }                } else {                                                            if (checkStatus == CHECK_STATUS_PASS) {                        sql = "Update sq_thread set redate=? where id=?";                        ps = conn.prepareStatement(sql);                        ps.setString(1, "" + System.currentTimeMillis());                        ps.setLong(2, rootid);                        conn.executePreUpdate();                        if (ps != null) {                            ps.close();                            ps = null;                        }                        conn.commit();                                                MsgDb rootmsg = getMsgDb(rootid);                        rootmsg.setRename(name);                        rootmsg.setRedate(new java.util.Date());                        rootmsg.setRecount(rootmsg.getRecount() + 1);                        try {                            rootmsg.save();                        } catch (ResKeyException e2) {                            Logger.getLogger(MsgDb.class.getName()).info(                                    "AddReplyWE2:" +                                    StrUtil.trace(e2));                        }                        setBoardNewAddId(id);                                                setBoardStatistic(false, id);                    } else                        conn.commit();                    mc.refreshReply(boardcode, rootid);                }            }            else                conn.rollback();        } catch (Exception e) {            conn.rollback();            Logger.getLogger(MsgDb.class.getName()).error("checkMsg:" +                    e.getMessage());            throw new ResKeyException(SkinUtil.ERR_DB);         } finally {            if (conn != null) {                conn.close();                conn = null;            }        }        return re;    }        public void setBoardStatistic(boolean isAddTopic, long msgId) {        MsgDb md = getMsgDb(msgId);                Leaf lf = new Leaf();        lf = lf.getLeaf(boardcode);                java.util.Date d = lf.getTodayDate();        Calendar todaydb = Calendar.getInstance();        todaydb.setTime(d);        Calendar today = Calendar.getInstance();                if (DateUtil.isSameDay(todaydb, today)) {            lf.setTodayCount(lf.getTodayCount() + 1);        } else {             lf.setTodayCount(1);            lf.setTodayDate(new java.sql.Date(today.getTimeInMillis()));        }        if (isAddTopic)            lf.setTopicCount(lf.getTopicCount() + 1);        lf.setPostCount(lf.getPostCount() + 1);        lf.update();        if (md.isBlog()) {                        BlogDb bd = BlogDb.getInstance();            bd.setStatics(isAddTopic);        }                if (md.isBlog() && md.getboardcode().equals(Leaf.CODE_BLOG)) {            ;        }        else {            ForumDb forum = ForumDb.getInstance();            forum.setStatics(isAddTopic);        }    }    public boolean isRootMsg() {        return id == rootid;    }    public static boolean isOwner(String userName, MsgDb md) {        if (!md.isRootMsg())            md = md.getMsgDb(md.getRootid());        if (userName.equals(md.getName()))            return true;        else            return false;    }    public boolean CheckTopicWE(HttpServletRequest request, FileUpload mfu) throws            ErrMsgException {        String errMsg = "";        name = Privilege.getUser(request);        title = mfu.getFieldValue("topic");        if (title == null || title.trim().equals(""))            errMsg += LoadString(request, "err_need_title");        boardcode = mfu.getFieldValue("boardcode");        if (boardcode == null || boardcode.trim().equals(""))            errMsg += LoadString(request, "err_need_board");        content = mfu.getFieldValue("htmlcode");

⌨️ 快捷键说明

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