亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? attachmentwebhandler.java

?? java servlet著名論壇源代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/user/AttachmentWebHandler.java,v 1.13 2004/06/01 13:00:02 skoehler Exp $
 * $Author: skoehler $
 * $Revision: 1.13 $
 * $Date: 2004/06/01 13:00:02 $
 *
 * ====================================================================
 *
 * Copyright (C) 2002-2004 by MyVietnam.net
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * All copyright notices regarding mvnForum MUST remain intact
 * in the scripts and in the outputted HTML.
 * The "powered by" text/logo with a link back to
 * http://www.mvnForum.com and http://www.MyVietnam.net in the
 * footer of the pages MUST remain visible when the pages
 * are viewed on the internet or intranet.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Support can be obtained from support forums at:
 * http://www.mvnForum.com/mvnforum/index
 *
 * Correspondence and Marketing Questions can be sent to:
 * info@MyVietnam.net
 *
 * @author: Minh Nguyen  minhnn@MyVietnam.net
 * @author: Mai  Nguyen  mai.nh@MyVietnam.net
 */
package com.mvnforum.user;

import java.io.*;
import java.sql.Timestamp;
import java.util.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mvnforum.MVNForumConfig;
import com.mvnforum.MyUtil;
import com.mvnforum.auth.*;
import com.mvnforum.common.AttachmentUtil;
import com.mvnforum.db.*;
import net.myvietnam.mvncore.exception.*;
import net.myvietnam.mvncore.fileupload.*;
import net.myvietnam.mvncore.filter.DisableHtmlTagFilter;
import net.myvietnam.mvncore.interceptor.InterceptorService;
import net.myvietnam.mvncore.util.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

class AttachmentWebHandler {

    private static Log log = LogFactory.getLog(AttachmentWebHandler.class);

    private OnlineUserManager userManager = OnlineUserManager.getInstance();

    AttachmentWebHandler() {
    }

    public void prepareAdd(HttpServletRequest request)
        throws BadInputException, DatabaseException, ObjectNotFoundException,
        AuthenticationException, AssertionException {

        if (MVNForumConfig.getEnableAttachment() == false) {
            throw new AssertionException("Cannot add Attachment because Attachment feature is disabled by administrator.");
        }

        OnlineUser onlineUser = userManager.getOnlineUser(request);
        MVNForumPermission permission = onlineUser.getPermission();
        /* was: permission.ensureIsAuthenticated();
         * That didn't allow guests to add attachments even if admin tried to
         * explicitly allow them to. So, we only need ensureCanAddAttachment(forumID),
         * and the admin will be responsible if he gets flooded (as he has to
         * explicitly allow them that anyway).
         * Same goes for processAdd() method below.
         */

        // primary key column(s)
        int postID  = ParamUtil.getParameterInt(request, "post");

        PostBean postBean = DAOFactory.getPostDAO().getPost(postID);

        int forumID       = postBean.getForumID();
        permission.ensureCanAddAttachment(forumID);

        ForumCache.getInstance().getBean(forumID).ensureNotDisabledForum();

        int logonMemberID = onlineUser.getMemberID();
        int authorID      = postBean.getMemberID();

        // check constraint
        if (permission.canEditPost(forumID)) {//@todo is this the correct permission checking ??? Igor: yes it is
            // have permission, just do nothing, that is dont check the max day contraint
        } else if ( (logonMemberID==authorID) && onlineUser.isMember() ) {
            // same author, but not guest
            Timestamp now = DateUtil.getCurrentGMTTimestamp();
            // check date here, usually must not older than 1 days
            Timestamp postDate = postBean.getPostCreationDate();
            int maxDays = MVNForumConfig.getMaxAttachDays();
            if ( (now.getTime() - postDate.getTime()) > (DateUtil.DAY * maxDays) ) {
                /** @todo choose a better Exception here */
                throw new BadInputException("You cannot attach a file to a post which is older than " + maxDays + " days.");
            }
            /** @todo check status of this post */
            /*
            if (postBean.getPostStatus() == ?) {
                throw new BadInputException("Cannot attach a file to disabled post.");
            }*/
        } else {//not an author, so this user must have Edit Permission
            //@todo is this the correct permission checking ??? Igor: yes it is
            permission.ensureCanEditPost(forumID);// this method ALWAYS throws AuthenticationException
        }

        request.setAttribute("PostBean", postBean);
    }

    void processAdd(HttpServletRequest request)
        throws BadInputException, CreateException, DatabaseException, IOException, ForeignKeyNotFoundException,
        AuthenticationException, AssertionException, ObjectNotFoundException, InterceptorException {

        if (MVNForumConfig.getEnableAttachment() == false) {
            throw new AssertionException("Cannot add Attachment because Attachment feature is disabled by administrator.");
        }

        OnlineUser onlineUser = userManager.getOnlineUser(request);
        MVNForumPermission permission = onlineUser.getPermission();
        /* was: permission.ensureIsAuthenticated();
         * See prepareAdd() method above.
         */

        String tempDir = MVNForumConfig.getTempDir();
        log.debug("AttachmentWebHandler : process upload with temp dir = " + tempDir);

        FileUpload fileUpload = new FileUpload();
        fileUpload.setSizeMax(MVNForumConfig.getMaxAttachmentSize());
        fileUpload.setSizeThreshold(100000);// max memory used = 100K
        fileUpload.setRepositoryPath(tempDir);
        List fileItems;
        try {
            fileItems = fileUpload.parseRequest(request);
        } catch (FileUploadException ex) {
            log.error("Cannot upload", ex);
            throw new IOException("Cannot upload. Detailed reason: " + ex.getMessage());
        }

        // values that must get from the form
        int offset                  = 0;
        int postID                  = 0;
        String attachFilename       = null;
        int attachFileSize          = 0;
        String attachMimeType       = null;
        String attachDesc           = null;

        FileItem attachFileItem = null;
        boolean attachMore = false;
        for (int i = 0; i < fileItems.size(); i++ ) {
            FileItem currentFileItem = (FileItem)fileItems.get(i);
//            System.out.println(
//                "ContentType = " + currentFileItem.getContentType() +
//                " Fieldname = " + currentFileItem.getFieldName() +
//                " Name = " + currentFileItem.getName() +
//                " Size = " + currentFileItem.getSize()
//                //" String = " + currentFileItem.getString()
//                );

            String fieldName = currentFileItem.getFieldName();
            boolean isFormField = currentFileItem.isFormField();
            if (fieldName.equals("offset")) {
                String content = currentFileItem.getString("utf-8");
                offset = Integer.parseInt(content);
                log.debug("offset = " + offset);
            } else if (fieldName.equals("AttachMore")) {
                String content = currentFileItem.getString("utf-8");
                attachMore = (content.length() > 0);
                log.debug("attachMore = " + attachMore);
            } else if (fieldName.equals("PostID")) {
                String content = currentFileItem.getString("utf-8");
                postID = Integer.parseInt(content);
                log.debug("postID = " + postID);
            } else if (fieldName.equals("AttachDesc")) {
                String content = currentFileItem.getString("utf-8");
                attachDesc = DisableHtmlTagFilter.filter(content);
                log.debug("attachDesc = " + attachDesc);
                InterceptorService.getInstance().validateContent(attachDesc);
            } else if (fieldName.equals("vnselector")) {
                //ignore
            } else if (fieldName.equals("AttachFilename")) {
                if (currentFileItem.isFormField() == true) {
                    throw new AssertionException("Cannot process uploaded attach file with a form field.");
                }
                attachMimeType = currentFileItem.getContentType();
                attachMimeType = DisableHtmlTagFilter.filter(attachMimeType);
                attachFileSize = (int)currentFileItem.getSize();
                if (attachFileSize == 0) {
                    throw new BadInputException("Cannot process an attach file with size = 0. Please check the file size or check if your file is missing.");
                }
                String fullFilePath = currentFileItem.getName();
                attachFilename = FileUtil.getFileName(fullFilePath);
                attachFilename = DisableHtmlTagFilter.filter(attachFilename);
                log.debug("attachFilename = " + attachFilename);

                // now save to attachFileItem
                attachFileItem = currentFileItem;
            } else {
                throw new AssertionException("Cannot process field name = " + fieldName);
            }
        }
        Timestamp now = DateUtil.getCurrentGMTTimestamp();

        // check constraint
        PostBean postBean = DAOFactory.getPostDAO().getPost(postID);
        int forumID = postBean.getForumID();
        permission.ensureCanAddAttachment(forumID);

        ForumCache.getInstance().getBean(forumID).ensureNotDisabledForum();

        int    logonMemberID    = onlineUser.getMemberID();
        //String logonMemberName  = onlineUser.getMemberName();
        int    authorID         = postBean.getMemberID();

        // check constraint
        if (permission.canEditPost(forumID)) { //@todo is this the correct permission checking ??? Igor: yes it is

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久国产精华| 国产精品羞羞答答xxdd| 色欧美片视频在线观看| 亚洲视频免费在线观看| 一本久久综合亚洲鲁鲁五月天| 亚洲欧美自拍偷拍色图| 99精品偷自拍| 亚洲综合在线观看视频| 欧美日韩一区小说| 日韩中文欧美在线| 欧美v日韩v国产v| 懂色av中文字幕一区二区三区| 日本一区二区三级电影在线观看| 北条麻妃国产九九精品视频| 亚洲精品国产一区二区精华液| 欧美性xxxxxxxx| 蜜臀av国产精品久久久久| 久久久久久久久久久电影| 高清日韩电视剧大全免费| 亚洲天堂成人在线观看| 欧美日韩在线播放| 国产一区二区三区在线观看免费视频 | 成人综合婷婷国产精品久久免费| 国产精品三级av在线播放| 99这里只有久久精品视频| 日韩中文字幕亚洲一区二区va在线 | 欧美亚洲动漫制服丝袜| 麻豆精品国产91久久久久久| 日本一区二区高清| 欧美在线free| 国产v日产∨综合v精品视频| 亚洲国产精品自拍| 久久精品欧美日韩| 欧美丝袜自拍制服另类| 国产精品白丝av| 亚洲成av人片在线| 国产调教视频一区| 在线不卡中文字幕| 97国产精品videossex| 麻豆精品在线播放| 亚洲激情五月婷婷| 久久精品一区四区| 欧美二区三区91| 97久久精品人人澡人人爽| 久久se这里有精品| 亚洲一区二区在线免费看| 国产色产综合色产在线视频| 欧美日韩国产综合一区二区| 成人av在线资源| 国产一区欧美日韩| 婷婷亚洲久悠悠色悠在线播放| 国产精品伦理一区二区| 日韩一区二区三| 欧美这里有精品| 99久久国产综合精品麻豆 | 国产一区在线不卡| 午夜精品久久久久久久99水蜜桃 | 在线视频一区二区免费| 成人av午夜电影| 国产老肥熟一区二区三区| 免费高清在线视频一区·| 亚洲愉拍自拍另类高清精品| 国产精品国产馆在线真实露脸 | 青青草原综合久久大伊人精品优势| 综合久久久久久| 国产精品久久影院| 国产视频不卡一区| 久久久91精品国产一区二区精品 | 欧美激情一区在线观看| 欧美大白屁股肥臀xxxxxx| 91精品国产一区二区| 欧美精品久久99| 欧美日韩国产一二三| 欧美日韩久久久久久| 欧美亚洲日本国产| 欧美性色黄大片| 欧美最新大片在线看 | 日韩国产精品91| 亚洲成人免费在线观看| 亚洲成人免费av| 亚洲午夜精品网| 亚洲小说春色综合另类电影| 亚洲成av人**亚洲成av**| 亚洲va欧美va人人爽| 视频一区视频二区在线观看| 午夜在线成人av| 日韩不卡在线观看日韩不卡视频| 日韩av网站在线观看| 日本不卡在线视频| 精品亚洲国内自在自线福利| 国内精品国产成人国产三级粉色| 国产麻豆精品在线观看| 成人av资源站| a美女胸又www黄视频久久| 欧美在线一区二区三区| 91精品国产综合久久久久 | 国产日韩欧美一区二区三区综合 | 色94色欧美sute亚洲线路一ni| 在线免费不卡视频| 7777精品久久久大香线蕉| 337p粉嫩大胆噜噜噜噜噜91av| 久久精品一区二区| 亚洲色图视频网站| 日本视频在线一区| 国产宾馆实践打屁股91| 91国模大尺度私拍在线视频| 欧美一区二区高清| 国产精品女同一区二区三区| 一区二区不卡在线播放| 免费观看日韩电影| 99精品视频一区二区| 91精品国产麻豆| 国产欧美日韩在线| 亚洲综合在线第一页| 韩国欧美国产一区| 欧美亚洲禁片免费| 久久精品人人做| 亚洲成人免费影院| 久久精品国产秦先生| 成人深夜福利app| 色综合久久久久综合体| 91免费看视频| 亚洲精品在线观看网站| 国产精品女同一区二区三区| 亚洲一区二区中文在线| 国产在线一区二区综合免费视频| 不卡在线视频中文字幕| 欧美性xxxxxx少妇| 欧美精品一区男女天堂| 国产精品久久久久天堂| 丝袜美腿亚洲综合| 91蝌蚪porny| 日韩三级视频在线观看| 国产嫩草影院久久久久| 亚洲成年人影院| 美女视频黄久久| 91成人在线免费观看| 亚洲精品一区二区三区影院| 亚洲欧洲日韩综合一区二区| 日韩成人精品在线| 成人性色生活片免费看爆迷你毛片| 欧美私模裸体表演在线观看| 久久夜色精品一区| 亚洲一区二区三区中文字幕在线 | 亚洲3atv精品一区二区三区| 老色鬼精品视频在线观看播放| 99re热这里只有精品视频| 欧美一区二区三区四区视频| 亚洲视频在线一区| 国产伦精品一区二区三区视频青涩 | 国产一区二区三区免费播放| 欧美精选一区二区| 国产精品久久久久婷婷 | 麻豆91在线观看| 91激情五月电影| 一区二区三区中文字幕| 国产尤物一区二区| 欧美一区二区国产| 久久影音资源网| 成人听书哪个软件好| 欧洲生活片亚洲生活在线观看| 国产精品久久久久久久久久免费看| 日韩国产在线观看一区| 一本一本大道香蕉久在线精品| 精品国产伦一区二区三区免费| 亚洲成人av电影| 成人久久视频在线观看| 精品久久一二三区| 蜜桃视频一区二区三区| 欧美剧情电影在线观看完整版免费励志电影| 欧美成人精品3d动漫h| 久久国产精品色| 欧美美女黄视频| 亚洲国产sm捆绑调教视频| 欧美综合久久久| 亚洲精品日产精品乱码不卡| av在线综合网| 成人免费一区二区三区在线观看| 成人久久久精品乱码一区二区三区| 久久嫩草精品久久久精品一| 韩国在线一区二区| 久久品道一品道久久精品| 麻豆免费精品视频| 精品少妇一区二区| 国产一本一道久久香蕉| 欧美绝品在线观看成人午夜影视| 亚洲激情图片一区| 欧美午夜精品久久久久久超碰| 国产精品久久久久久久久久免费看 | 8v天堂国产在线一区二区| 偷窥少妇高潮呻吟av久久免费| 欧美精品777| 青青草97国产精品免费观看| 精品成人佐山爱一区二区| 极品瑜伽女神91| 久久久不卡网国产精品二区| 国产精品99久久久久久久vr | 中文字幕av一区二区三区免费看 | 欧美一区二区三区成人| 精品无人区卡一卡二卡三乱码免费卡|