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

📄 msgdb.java

📁 cwbbs 云网论坛源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        } 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(TheBean.getFieldValue(                "threadType"));        if (strThreadType.equals("") || !StrUtil.isNumeric(strThreadType))            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(req)) {                        String tag = StrUtil.getNullStr(TheBean.getFieldValue("tag")).                         trim();            if (!tag.equals("")) {                                int tagLenMax = cfg.getIntProperty("forum.tagLenMax");                if (tag.length()>tagLenMax) {                    String limit = StrUtil.format(SkinUtil.LoadString(req, "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(req, "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(req, "res.label.forum.showtopic", "tag_single_limit"), new Object[] { new Integer(tagSingleLenMax) });                            throw new ErrMsgException(limit);                        }                        tempTagNameVector.addElement(tagName);                    }                }            }        }        return true;    }        public boolean AddNew(ServletContext application,                          HttpServletRequest request,                          String name, FileUpload fu) throws            ErrMsgException, ResKeyException {        this.name = name;        CheckTopic(request, fu);                String isvote = fu.getFieldValue("isvote");        String[] voptions = null;        int msgType = 0;        if (isvote != null && isvote.equals("1")) {            String voteoption = fu.getFieldValue("vote").trim();            if (!voteoption.equals("")) {                voptions = voteoption.split("\n");            }            if (voptions != null) {                msgType = TYPE_VOTE;            }        }        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)            throw new ErrMsgException(LoadString(request,                                                 "err_too_large_content") +                                      MAX_CONTENT_LEN);        id = SequenceMgr.nextID();        int intIsBlog = blog ? 1 : 0;        FileInfo fi = null;        Vector v = fu.getFiles();        int size = v.size();        String[] fileNameAry = null;        if (size > 0) {            fi = (FileInfo) v.get(0);                         fileNameAry = new String[size];            for (int i = 0; i < size; i++) {                fileNameAry[i] = FileUpload.getRandName() + "." +                                 ((FileInfo) v.get(i)).getExt();            }        }        String virtualpath = "";        Config cfg = Config.getInstance();        boolean isFtpUsed = cfg.getBooleanProperty("forum.ftpUsed");        String attachmentBasePath = request.getContextPath() + "/" + Config.getInstance().getAttachmentPath() + "/";        if (isFtpUsed) {            attachmentBasePath = cfg.getProperty("forum.ftpUrl");            if (attachmentBasePath.lastIndexOf("/")!=attachmentBasePath.length()-1)                attachmentBasePath += "/";        }        if (ret == FileUpload.RET_SUCCESS) {            virtualpath = getCurAttVisualPath();            String filepath = Global.getRealPath() + Config.getInstance().getAttachmentPath() + "/" +                              virtualpath + "/";            if (!isFtpUsed) {                File f = new File(filepath);                if (!f.isDirectory()) {                    f.mkdirs();                }            }            fu.setSavePath(filepath);             Iterator ir = v.iterator();            int k = 0;            String imgStr = "";            while (ir.hasNext()) {                fi = (FileInfo) ir.next();                String ext = fi.getExt();                String ubbtype = "";                if (ext.equalsIgnoreCase("gif") ||                    ext.equalsIgnoreCase("jpg") ||                    ext.equalsIgnoreCase("png") ||                    ext.equalsIgnoreCase("bmp"))                    ubbtype = "img";                else if (ext.equalsIgnoreCase("swf"))                    ubbtype = "flash";                else                    ubbtype = "URL";                if (isWebedit == WEBEDIT_UBB) {                    if (ubbtype.equals("img"))                        imgStr += "\n[" + ubbtype + "]" + attachmentBasePath +                                virtualpath + "/" +                                fileNameAry[k] + "[/" + ubbtype + "]\n";                    else if (ubbtype.equals("flash"))                        imgStr += "\n[" + ubbtype + "]" + attachmentBasePath +                                virtualpath + "/" +                                fileNameAry[k] + "[/" +                                ubbtype + "]\n";                } else {                    if (ubbtype.equals("img"))                        imgStr += "<BR><a onfocus=this.blur() href=\"" +                                attachmentBasePath + virtualpath + "/" +                                fileNameAry[k] + "\" target=_blank><IMG SRC=\"" +                                attachmentBasePath + virtualpath + "/" +                                fileNameAry[k] + "\" border=0 alt=" +                                SkinUtil.                                LoadString(request, "res.cn.js.fan.util.StrUtil",                                           "click_open_win") + " onmousewheel='return zoomimg(this)' onload=\"javascript:if(this.width>screen.width-333)this.width=screen.width-333\"></a><BR>";                    else if (ubbtype.equals("flash"))                        imgStr += "\n[" + ubbtype + "]" + attachmentBasePath +                                virtualpath + "/" +                                fileNameAry[k] + "[/" +                                ubbtype + "]\n";                }                k++;            }            content = imgStr + content;        }        boolean re = false;        Conn conn = new Conn(connname);        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);            conn.executePreUpdate();            if (ps != null) {                ps.close();                ps = null;            }                        if (ret == FileUpload.RET_SUCCESS && fi != null) {                Iterator ir = v.iterator();                                int orders = 1;                int i = 0;                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) {                        String errMsg = ftp.getReplyMessage();                        ftp.close();                        throw new ErrMsgException("FTP:" + errMsg);                    }                }                int intIsRemote = isFtpUsed?1:0;                while (ir.hasNext()) {                    fi = (FileInfo) ir.next();                    if (isFtpUsed) {                        try {                            ftp.storeFile(virtualpath + "/" + fileNameAry[i], fi.getTmpFilePath());                        }                        catch (IOException e) {                            LogUtil.getLog(getClass()).error("AddNew: storeFile - " + e.getMessage());                        }                    }                    else {                        fi.write(fu.getSavePath(), fileNameAry[i]);                    }                    long attachId = SequenceMgr.nextID(SequenceMgr.                            SQ_MESSAGE_ATTACH);                    sql =                            "insert into sq_message_attach (id,msgId,name,diskname,visualpath,orders,UPLOAD_DATE,FILE_SIZE,USER_NAME,is_remote,ext) values (" +                            attachId + "," +                            id + "," +                            StrUtil.sqlstr(fi.getName()) + "," +                            StrUtil.sqlstr(fileNameAry[i]) + "," +                            StrUtil.sqlstr(virtualpath) + "," + orders +                            "," + StrUtil.sqlstr("" + System.currentTimeMillis()) +                            "," + fi.getSize() + "," + StrUtil.sqlstr(name) + "," + intIsRemote + "," + StrUtil.sqlstr(fi.getExt()) +                            ")";                    conn.executeUpdate(sql);                    orders++;                    i++;                }                if (isFtpUsed) {                    ftp.close();                }                if (!name.equals("")) {                    if (i > 0) {                                                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, i);                        }                    }                    UserPrivDb upd = new UserPrivDb();

⌨️ 快捷键说明

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