亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
成人动漫av在线| 欧美xxxxxxxxx| 日韩免费一区二区| 亚洲三级在线免费| 寂寞少妇一区二区三区| 欧美亚洲图片小说| 国产精品久久久久影院色老大| 亚洲一区二区三区四区的| 国产精品亚洲专一区二区三区| 欧日韩精品视频| 最新国产精品久久精品| 精品影视av免费| 欧美酷刑日本凌虐凌虐| 中文字幕综合网| 国产精品一二三四| 欧美xxxx老人做受| 蜜桃视频在线观看一区二区| 欧美日韩精品免费| 亚洲欧美怡红院| 成人在线综合网站| 久久这里都是精品| 久久精品噜噜噜成人88aⅴ| 欧美伊人久久久久久午夜久久久久| 中文字幕高清不卡| 成人手机电影网| 国产网站一区二区三区| 国产一区二三区| 欧美va天堂va视频va在线| 喷白浆一区二区| 3atv一区二区三区| 欧美aⅴ一区二区三区视频| 欧美亚洲免费在线一区| 亚洲永久精品国产| 欧美日韩中文字幕精品| 玉足女爽爽91| 欧美在线不卡视频| 亚洲午夜私人影院| 欧美一区二区三区不卡| 男女男精品视频| 精品嫩草影院久久| 国产精品538一区二区在线| 久久综合一区二区| 国产成人精品亚洲日本在线桃色| 久久精品欧美日韩精品| 国产精品 日产精品 欧美精品| 久久久久国产免费免费 | 国产.欧美.日韩| 久久久久久久久久久久久女国产乱| 久久9热精品视频| 久久精品亚洲麻豆av一区二区| 国产精品69毛片高清亚洲| 亚洲天堂av一区| 欧美蜜桃一区二区三区 | 亚洲永久免费av| 欧美精品tushy高清| 美女任你摸久久| 国产精品视频免费看| 色呦呦日韩精品| 午夜成人免费视频| 久久综合成人精品亚洲另类欧美 | 久久er精品视频| 国产免费成人在线视频| 91理论电影在线观看| 亚洲成人自拍偷拍| 久久视频一区二区| 91在线国内视频| 五月综合激情日本mⅴ| 精品国产一二三区| a在线播放不卡| 日韩高清国产一区在线| 国产精品久久久久久久久免费相片| 91欧美一区二区| 蜜臀久久99精品久久久久宅男| 国产亚洲综合性久久久影院| 99精品视频在线免费观看| 香蕉av福利精品导航| 中文字幕电影一区| 欧美日韩另类一区| 成人永久aaa| 五月婷婷色综合| 国产精品美女www爽爽爽| 欧美日本国产视频| eeuss鲁片一区二区三区| 蜜臀久久99精品久久久画质超高清| 中文字幕日韩精品一区| 欧美xxxx在线观看| 欧美无乱码久久久免费午夜一区 | 色av成人天堂桃色av| 久久99深爱久久99精品| 亚洲成人久久影院| 国产精品区一区二区三| 日韩情涩欧美日韩视频| 在线精品视频免费播放| 国产高清在线精品| 青草国产精品久久久久久| 亚洲在线免费播放| 亚洲欧美一区二区三区孕妇| 精品国产一区久久| 欧美一区在线视频| 欧美日韩一区二区在线观看视频| 成人午夜在线播放| 国产在线视频一区二区三区| 蜜臀久久99精品久久久久久9| 亚洲午夜影视影院在线观看| 国产精品护士白丝一区av| 精品美女在线播放| 日韩精品一区二区三区在线播放 | 日韩二区三区在线观看| 亚洲精品成人少妇| 亚洲色图.com| 1024成人网| 亚洲免费av观看| 亚洲欧美在线观看| 一区二区中文视频| 亚洲视频 欧洲视频| 中文一区一区三区高中清不卡| 精品福利在线导航| 国产亚洲欧美一区在线观看| 日韩欧美黄色影院| 精品日韩av一区二区| 久久香蕉国产线看观看99| 日韩精品一区二区三区四区视频| 日韩免费一区二区| 久久午夜免费电影| 中文字幕高清一区| 亚洲视频一二区| 亚洲一区精品在线| 午夜天堂影视香蕉久久| 亚洲成a人v欧美综合天堂下载| 日韩综合一区二区| 狠狠色丁香婷综合久久| 国产二区国产一区在线观看| 成人午夜免费av| 色乱码一区二区三区88| 欧美日韩一区成人| 日韩视频一区二区三区| 久久精品一区二区三区不卡牛牛 | 亚洲曰韩产成在线| 日韩黄色在线观看| 国产一区日韩二区欧美三区| 99久久综合精品| 欧美日韩国产小视频在线观看| 欧美一级夜夜爽| 日本一区二区三区在线观看| 亚洲欧美视频在线观看视频| 香蕉成人啪国产精品视频综合网| 麻豆精品一区二区三区| 99久久国产综合色|国产精品| 欧美日精品一区视频| 久久久亚洲精品一区二区三区| 国产精品丝袜91| 天天操天天干天天综合网| 国产精品一级片在线观看| 99精品在线免费| 日韩亚洲欧美一区| 国产精品人成在线观看免费| 午夜伦欧美伦电影理论片| 国产福利91精品一区二区三区| 91麻豆免费在线观看| 欧美mv和日韩mv国产网站| 亚洲免费观看视频| 国产乱码精品1区2区3区| 日本乱码高清不卡字幕| 精品国精品自拍自在线| 亚洲国产一区在线观看| 国产一区在线观看麻豆| 欧美日韩美少妇| 亚洲视频你懂的| 国产成人精品影视| 欧美一区二区三区啪啪| 亚洲色图制服丝袜| 国产一区二区三区日韩| 欧美精品在线视频| 亚洲三级电影全部在线观看高清| 久久99精品国产麻豆婷婷| 色狠狠一区二区三区香蕉| 日本一区二区三区四区 | 久久久久久久久99精品| 亚洲成人中文在线| 91丨国产丨九色丨pron| 精品国产伦一区二区三区观看方式| 亚洲一区二区三区四区在线观看 | 亚洲伦在线观看| 国产盗摄一区二区三区| 久久这里都是精品| 麻豆一区二区在线| 777xxx欧美| 日韩精品一级中文字幕精品视频免费观看 | 亚洲视频在线一区观看| 国产麻豆视频一区二区| 中文字幕在线不卡视频| 精品一区二区在线免费观看| 日韩欧美一级二级| 日本午夜精品视频在线观看| 欧美高清你懂得| 亚洲成人激情社区| 欧美日韩色一区| 午夜精品一区二区三区免费视频| 欧美日韩精品一区二区三区| 亚洲一区中文日韩|