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

📄 messageform.java~13~

📁 源码/软件简介: 云网论坛1.1RC国际版是采用JSP开发的集论坛、CMS(网站内容管理系统)、博客、聊天室、商城、交友、语音灌水等于一体的门户式社区。拥有CWBBS ( Cloud Web BBS
💻 JAVA~13~
字号:
package com.redmoon.forum.message;

import cn.js.fan.base.AbstractForm;
import cn.js.fan.util.ErrMsgException;
import javax.servlet.http.HttpServletRequest;
import cn.js.fan.util.ParamUtil;
import cn.js.fan.db.SQLFilter;
import cn.js.fan.web.SkinUtil;
import cn.js.fan.util.StrUtil;
import com.redmoon.forum.*;

public class MessageForm extends AbstractForm {
    MessageDb md;
    HttpServletRequest request;

    public MessageForm() {
    }

    public MessageForm(HttpServletRequest request, MessageDb md) {
        this.request = request;
        this.md = md;
    }

    public String chkIp() {
        md.ip = request.getRemoteAddr();
        return md.ip;
    }

    public String chkTitle() throws ErrMsgException {
        String title = ParamUtil.get(request, "title");
        if (title.equals("")) {
            log(SkinUtil.LoadString(request, "res.forum.message.MessageForm",
                                    "err_need_title")); // "标题必须填写!");
        }
        Config cfg = new Config();
        int len = cfg.getIntProperty("forum.shortMsgTitleLengthMax");
        if (title.trim().length() >= len) {
            String str = SkinUtil.LoadString(request,
                                             "res.forum.message.MessageForm",
                                             "err_title");
            str = StrUtil.format(str, new Object[] {"" + len});
            throw new ErrMsgException(str);
        }

        if (!SQLFilter.isValidSqlParam(title)) {
            log(SkinUtil.LoadString(request, SkinUtil.ERR_SQL));
        }
        md.title = title;
        return title;
    }

    public String chkContent() throws ErrMsgException {
        String content = ParamUtil.get(request, "content");
        if (content.equals("")) {
            log(SkinUtil.LoadString(request, "res.forum.message.MessageForm",
                                    "err_need_content")); // "内容必须填写!");
        }
        Config cfg = new Config();
        int len = cfg.getIntProperty("forum.shortMsgContentLengthMax");
        if (content.trim().length() >= len) {
            String str = SkinUtil.LoadString(request,
                                             "res.forum.message.MessageForm",
                                             "err_content");
            str = StrUtil.format(str, new Object[] {"" + len});
            throw new ErrMsgException(str);
        }
        if (!SQLFilter.isValidSqlParam(content)) {
            log(SkinUtil.LoadString(request, SkinUtil.ERR_SQL));
        }
        md.content = content;
        return content;
    }

    public String chkReceiver() {
        boolean isToAll = ParamUtil.getBoolean(request, "isToAll", false);
        if (isToAll) {
            return "";
        }
        String receiver = ParamUtil.get(request, "receiver");
        if (receiver.equals("")) {
            log(SkinUtil.LoadString(request, "res.forum.message.MessageForm",
                                    "err_need_receiver"));
        }
        if (!SQLFilter.isValidSqlParam(receiver)) {
            log(SkinUtil.LoadString(request, SkinUtil.ERR_SQL));
        }
        md.receiver = receiver;
        return receiver;
    }

    public String checkIp() {
        String ip = request.getRemoteAddr();
        md.ip = ip;
        return ip;
    }

    public int chkType() {
        String type = request.getParameter("type");
        if (type == null || type.equals("")) {
            md.type = MessageDb.TYPE_USER;
        } else {
            md.type = Integer.parseInt(type);
        }
        return md.type;
    }

    public boolean checkCreate() throws ErrMsgException {
        init();
        chkTitle();
        chkContent();
        chkReceiver();
        chkIp();
        chkType();
        report();
        return true;
    }
}

⌨️ 快捷键说明

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