userform.java

来自「cwbbs 云网论坛源码」· Java 代码 · 共 77 行

JAVA
77
字号
package com.redmoon.forum.person;import cn.js.fan.base.AbstractForm;import javax.servlet.http.HttpServletRequest;import cn.js.fan.util.ErrMsgException;import java.io.IOException;import com.redmoon.kit.util.FileUpload;import cn.js.fan.web.Global;import cn.js.fan.util.StrUtil;import javax.servlet.ServletContext;import com.redmoon.forum.Config;import cn.js.fan.web.SkinUtil;import java.util.*;import com.redmoon.kit.util.FileInfo;import java.awt.Image;import javax.swing.ImageIcon;import com.redmoon.forum.util.ForumFileUpload;public class UserForm extends AbstractForm {    public UserForm() {    }    public ForumFileUpload doUpload(ServletContext application, HttpServletRequest request) throws            ErrMsgException {        ForumFileUpload fu = new ForumFileUpload();        Config cfg = Config.getInstance();        int photoSize = cfg.getIntProperty("forum.photo_max_size");        fu.setMaxFileSize(photoSize);        String[] extnames = {"jpg", "gif", "png", "bmp"};        fu.setValidExtname(extnames);        int ret = 0;                try {            ret = fu.doUpload(application, request);            if (ret == -4) {                throw new ErrMsgException(fu.getErrMessage(request));            }            if (ret == -3) {                String str = SkinUtil.LoadString(request, "res.forum.person.UserForm", "err_photo_to_large");                str = str.replaceFirst("\\$s", "" + photoSize);                throw new ErrMsgException(StrUtil.makeErrMsg(str));             }        } catch (IOException e) {            logger.error("doUpload:" + e.getMessage());        }        return fu;    }    public ForumFileUpload checkDIYMyface(ServletContext application, HttpServletRequest request) throws ErrMsgException {        init();        ForumFileUpload fu = doUpload(application, request);        Vector v = fu.getFiles();        Iterator ir = v.iterator();        if (ir.hasNext()) {            FileInfo fi = (FileInfo) ir.next();            Image img = new ImageIcon(                    fi.getTmpFilePath()).getImage();            int w = img.getWidth(null);             int h = img.getHeight(null);             Config cfg = Config.getInstance();            int faceWidth = cfg.getIntProperty("forum.faceWidth");            int faceHeight = cfg.getIntProperty("forum.faceHeight");            if (w > faceWidth || h > faceHeight) {                log(StrUtil.format(SkinUtil.LoadString(request, "res.forum.person.UserDb", "err_face_size"), new Object[] {""+faceWidth, ""+faceHeight}));            }        }        report();        return fu;    }}

⌨️ 快捷键说明

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