Exemple #1
0
 /// <summary>
 /// 是否到了免费期 如果是出售的主题 超出了出售期限 就自动变为免费
 /// </summary>
 /// <param name="forumSetting"></param>
 /// <returns></returns>
 public bool IsOverSellDays(ForumSettingItem forumSetting)
 {
     if (forumSetting.SellThreadDays == 0)
     {
         return(false);
     }
     return(CreateDate.AddSeconds(forumSetting.SellThreadDays) <= DateTimeUtil.Now);
 }
Exemple #2
0
        public bool IsOverUpdateSortOrderTime(ForumSettingItem forumSetting)
        {
            int seconds = forumSetting.UpdateThreadSortOrderIntervals.GetValue(PostUserID);

            if (seconds == 0)
            {
                return(false);
            }
            return(UpdateDate.AddSeconds(seconds) <= DateTimeUtil.Now);
        }
 //判断有没有购买过
 private bool CheckPermission(ForumSettingItem forumSettting)
 {
     //是否已经买过了
     if (attachment.UserID != userID &&
         attachment.Price != 0 &&
         !attachment.IsOverSellDays(forumSettting) &&
         !attachment.IsBuyed(operatorUser))
     {
         return(false);
     }
     return(true);
 }
        private bool CheckFileSize(HttpContext context, string fileName, long fileSize)
        {
            Forum forum = GetForum(context);

            if (forum == null)
            {
                return(false);
            }

            AuthUser operatorUser = User.Current;

            ForumSettingItem forumSetting = AllSettings.Current.ForumSettings.Items.GetForumSettingItem(forum.ForumID);

            long maxSignleSize = forumSetting.MaxSignleAttachmentSize[operatorUser];

            if (maxSignleSize == 0)
            {
                maxSignleSize = long.MaxValue;
            }

            if (fileSize > maxSignleSize)
            {
                WebEngine.Context.ThrowError <OverAttachmentMaxSingleFileSizeError>(new OverAttachmentMaxSingleFileSizeError(forum.ForumID, maxSignleSize, fileName, fileSize));
                return(false);
            }

            long todayFileSize;

            if (!PageCacheUtil.TryGetValue <long>(Key_TodayTotalUsedFileSize, out todayFileSize))
            {
                int todayCount;
                PostBOV5.Instance.GetUserTodayAttachmentInfo(operatorUser.UserID, null, out todayCount, out todayFileSize);
            }

            long maxTotalAttachmentsSizeInDay = AllSettings.Current.BbsSettings.MaxTotalAttachmentsSizeInDay[operatorUser];

            if (maxTotalAttachmentsSizeInDay == 0)
            {
                maxTotalAttachmentsSizeInDay = long.MaxValue;
            }

            if (todayFileSize + fileSize > maxTotalAttachmentsSizeInDay)
            {
                WebEngine.Context.ThrowError <OverTodayAlowAttachmentFileSizeError>(new OverTodayAlowAttachmentFileSizeError("OverTodayAlowAttachmentFileSizeError", maxTotalAttachmentsSizeInDay, maxTotalAttachmentsSizeInDay - todayFileSize, fileSize));
                return(false);
            }

            return(true);
        }
        private void SaveSettings2()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("PostContentLengths", "PostSubjectLengths", "PolemizeValidDays", "PollValidDays", "QuestionValidDays",
                                                             "RecycleOwnThreadsIntervals", "UpdateThreadSortOrderIntervals", "CreatePostIntervals", "DeleteOwnThreadsIntervals", "AllowFileExtensions",
                                                             "new_PostContentLengths", "new_PostSubjectLengths", "new_PolemizeValidDays", "new_PollValidDays", "new_QuestionValidDays",
                                                             "new_RecycleOwnThreadsIntervals", "new_UpdateThreadSortOrderIntervals", "new_CreatePostIntervals", "new_DeleteOwnThreadsIntervals", "new_AllowFileExtensions"
                                                             , "AllowAttachment", "AllowImageAttachment", "CreatePostAllowAudioTag", "CreatePostAllowEmoticon", "CreatePostAllowFlashTag", "CreatePostAllowHTML"
                                                             , "CreatePostAllowImageTag", "CreatePostAllowMaxcode", "CreatePostAllowTableTag", "CreatePostAllowUrlTag", "CreatePostAllowVideoTag", "MaxPostAttachmentCount"
                                                             , "MaxTopicAttachmentCount", "MaxSignleAttachmentSize", "ShowSignatureInThread", "ShowSignatureInPost", "CreateThreadNeedApprove", "ReplyNeedApprove"
                                                             , "new_AllowAttachment", "new_AllowImageAttachment", "new_CreatePostAllowAudioTag", "new_CreatePostAllowEmoticon", "new_CreatePostAllowFlashTag", "new_CreatePostAllowHTML"
                                                             , "new_CreatePostAllowImageTag", "new_CreatePostAllowMaxcode", "new_CreatePostAllowTableTag", "new_CreatePostAllowUrlTag", "new_CreatePostAllowVideoTag", "new_MaxPostAttachmentCount"
                                                             , "new_MaxTopicAttachmentCount", "new_MaxSignleAttachmentSize", "new_ShowSignatureInThread", "new_ShowSignatureInPost", "new_CreateThreadNeedApprove", "new_ReplyNeedApprove"
                                                             , "UpdateOwnPostIntervals", "new_UpdateOwnPostIntervals"
                                                             , "EnableSellThread", "new_EnableSellThread"
                                                             , "EnableSellAttachment", "new_EnableSellAttachment"
                                                             , "DisplayInList", "new_DisplayInList"
                                                             , "VisitForum", "new_VisitForum"
                                                             , "SellAttachmentDays"
                                                             , "SellThreadDays"
                                                             , "ReplyReturnThreadLastPage"
                                                             , "ThreadSortField"
                                                             );


            if (_Request.Get("inheritType", Method.Post, "False").ToLower() == "true")//继承上级
            {
                ForumSettings tempSetting = AllSettings.Current.ForumSettings.Clone();

                ForumSettingItemCollection tempItems = new ForumSettingItemCollection();

                for (int i = 0; i < tempSetting.Items.Count; i++)
                {
                    if (tempSetting.Items[i].ForumID == ForumID)
                    {
                    }
                    else
                    {
                        tempItems.Add(tempSetting.Items[i]);
                    }
                }

                tempSetting.Items = tempItems;
                try
                {
                    if (!SettingManager.SaveSettings(tempSetting))
                    {
                        CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                        m_Success = false;
                    }
                    else
                    {
                        BbsRouter.JumpToUrl(Request.RawUrl, "success=true");
                    }
                }
                catch (Exception ex)
                {
                    m_Success = false;
                    msgDisplay.AddError(ex.Message);
                }
                return;
            }



            ForumSettingItem forumSetItem = new ForumSettingItem();

            ExceptableItem_Int32scope    int32scope    = new ExceptableItem_Int32scope();
            ExceptableItem_Second <long> second_long   = new ExceptableItem_Second <long>();
            ExceptableItem_Second <int>  second_int    = new ExceptableItem_Second <int>();
            ExceptableItem_ExtensionList extensionList = new ExceptableItem_ExtensionList();

            forumSetItem.ForumID                        = ForumID;
            forumSetItem.PostContentLengths             = int32scope.GetExceptable("PostContentLengths", msgDisplay); //GetInt32Exceptable("PostContentLengths",msgDisplay);
            forumSetItem.PostSubjectLengths             = int32scope.GetExceptable("PostSubjectLengths", msgDisplay); //GetInt32Exceptable("PostSubjectLengths",msgDisplay);
            forumSetItem.PolemizeValidDays              = second_long.GetExceptable("PolemizeValidDays", msgDisplay);
            forumSetItem.PollValidDays                  = second_long.GetExceptable("PollValidDays", msgDisplay);
            forumSetItem.QuestionValidDays              = second_long.GetExceptable("QuestionValidDays", msgDisplay);
            forumSetItem.RecycleOwnThreadsIntervals     = second_int.GetExceptable("RecycleOwnThreadsIntervals", msgDisplay);
            forumSetItem.UpdateThreadSortOrderIntervals = second_int.GetExceptable("UpdateThreadSortOrderIntervals", msgDisplay);
            forumSetItem.UpdateOwnPostIntervals         = second_int.GetExceptable("UpdateOwnPostIntervals", msgDisplay);
            forumSetItem.CreatePostIntervals            = second_int.GetExceptable("CreatePostIntervals", msgDisplay);
            forumSetItem.DeleteOwnThreadsIntervals      = second_int.GetExceptable("DeleteOwnThreadsIntervals", msgDisplay);
            forumSetItem.AllowFileExtensions            = extensionList.GetExceptable("AllowFileExtensions", msgDisplay);

            forumSetItem.AllowAttachment         = new ExceptableItem_bool().GetExceptable("AllowAttachment", msgDisplay);
            forumSetItem.AllowImageAttachment    = new ExceptableItem_bool().GetExceptable("AllowImageAttachment", msgDisplay);
            forumSetItem.CreatePostAllowAudioTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowAudioTag", msgDisplay);
            forumSetItem.CreatePostAllowEmoticon = new ExceptableItem_bool().GetExceptable("CreatePostAllowEmoticon", msgDisplay);
            forumSetItem.CreatePostAllowFlashTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowFlashTag", msgDisplay);
            forumSetItem.CreatePostAllowHTML     = new ExceptableItem_bool().GetExceptable("CreatePostAllowHTML", msgDisplay);
            forumSetItem.CreatePostAllowImageTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowImageTag", msgDisplay);
            forumSetItem.CreatePostAllowMaxcode  = new ExceptableItem_bool().GetExceptable("CreatePostAllowMaxcode", msgDisplay);
            forumSetItem.CreatePostAllowTableTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowTableTag", msgDisplay);
            forumSetItem.CreatePostAllowUrlTag   = new ExceptableItem_bool().GetExceptable("CreatePostAllowUrlTag", msgDisplay);
            forumSetItem.CreatePostAllowVideoTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowVideoTag", msgDisplay);
            forumSetItem.MaxPostAttachmentCount  = new ExceptableItem_Int_MoreThenZero().GetExceptable("MaxPostAttachmentCount", msgDisplay);
            forumSetItem.MaxTopicAttachmentCount = new ExceptableItem_Int_MoreThenZero().GetExceptable("MaxTopicAttachmentCount", msgDisplay);
            forumSetItem.MaxSignleAttachmentSize = new ExceptableItem_FileSize().GetExceptable("MaxSignleAttachmentSize", msgDisplay);
            forumSetItem.ShowSignatureInPost     = new ExceptableItem_bool().GetExceptable("ShowSignatureInPost", msgDisplay);
            forumSetItem.ShowSignatureInThread   = new ExceptableItem_bool().GetExceptable("ShowSignatureInThread", msgDisplay);
            forumSetItem.CreateThreadNeedApprove = new ExceptableItem_bool().GetExceptable("CreateThreadNeedApprove", msgDisplay);
            forumSetItem.ReplyNeedApprove        = new ExceptableItem_bool().GetExceptable("ReplyNeedApprove", msgDisplay);
            forumSetItem.EnableSellThread        = new ExceptableItem_bool().GetExceptable("EnableSellThread", msgDisplay);
            forumSetItem.EnableSellAttachment    = new ExceptableItem_bool().GetExceptable("EnableSellAttachment", msgDisplay);
            forumSetItem.EnableHiddenTag         = _Request.Get <bool>("enableHiddenTag", Method.Post, true);
            forumSetItem.EnableThreadRank        = _Request.Get <bool>("EnableThreadRank", Method.Post, true);
            forumSetItem.DefaultThreadSortField  = _Request.Get <ThreadSortField>("ThreadSortField", Method.Post, ThreadSortField.LastReplyDate);


            ThreadSortField oldThreadSortField = ForumSetting.DefaultThreadSortField;
            ThreadSortField newThreadSortField = forumSetItem.DefaultThreadSortField;


            forumSetItem.AllowGuestVisitForum  = _Request.Get <bool>("AllowGuestVisitForum", Method.Post, true);
            forumSetItem.DisplayInListForGuest = _Request.Get <bool>("DisplayInListForGuest", Method.Post, true);
            forumSetItem.VisitForum            = new ExceptableItem_bool().GetExceptable("VisitForum", msgDisplay);
            forumSetItem.DisplayInList         = new ExceptableItem_bool().GetExceptable("DisplayInList", msgDisplay);



            forumSetItem.SellThreadDays     = GetSeconds("SellThreadDays", msgDisplay);
            forumSetItem.SellAttachmentDays = GetSeconds("SellAttachmentDays", msgDisplay);

            forumSetItem.ReplyReturnThreadLastPage = _Request.Get <bool>("ReplyReturnThreadLastPage", Method.Post, false);

            if (msgDisplay.HasAnyError())
            {
                m_Success = false;
                return;
            }

            ForumSettings settings           = AllSettings.Current.ForumSettings.Clone();
            ForumSettingItemCollection items = new ForumSettingItemCollection();


            bool hasAdd     = false;
            bool hasTopItem = false;//是否有ForumID为0的设置

            foreach (ForumSettingItem item in settings.Items)
            {
                if (item.ForumID == forumSetItem.ForumID)
                {
                    items.Add(forumSetItem);
                    hasAdd = true;
                }
                else
                {
                    ProcessApplyAllForumSetting(item, forumSetItem);

                    items.Add(item);
                }
                if (item.ForumID == 0)
                {
                    hasTopItem = true;
                }
            }
            if (hasAdd == false)
            {
                items.Add(forumSetItem);
            }


            if (hasTopItem == false)//如果没有 加入
            {
                ForumSettingItem tempItem = new ForumSettingItem();
                ProcessApplyAllForumSetting(tempItem, forumSetItem);
                items.Add(tempItem);
            }

            settings.Items = items;

            try
            {
                using (new ErrorScope())
                {
                    bool success = SettingManager.SaveSettings(settings);

                    if (!success)
                    {
                        CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                        m_Success = false;
                    }
                    else
                    {
                        if (_Request.Get <bool>("ThreadSortField_aplyallnode", Method.Post, false))
                        {
                            ThreadCachePool.ClearAllCache();
                        }
                        else if (oldThreadSortField != newThreadSortField)
                        {
                            ThreadCachePool.ClearAllCache();
                        }

                        string rawUrl = Request.RawUrl;

                        BbsRouter.JumpToUrl(rawUrl, "success=true");
                    }
                }
            }
            catch (Exception ex)
            {
                m_Success = false;
                msgDisplay.AddError(ex.Message);
            }
        }
        private void ProcessApplyAllForumSetting(ForumSettingItem item, ForumSettingItem forumSetItem)
        {
            ExceptableItem_Int32scope    int32scope    = new ExceptableItem_Int32scope();
            ExceptableItem_Second <long> second_long   = new ExceptableItem_Second <long>();
            ExceptableItem_Second <int>  second_int    = new ExceptableItem_Second <int>();
            ExceptableItem_ExtensionList extensionList = new ExceptableItem_ExtensionList();

            if (int32scope.AplyAllNode("PostContentLengths"))
            {
                item.PostContentLengths = forumSetItem.PostContentLengths;
            }

            if (int32scope.AplyAllNode("PostSubjectLengths"))
            {
                item.PostSubjectLengths = forumSetItem.PostSubjectLengths;
            }

            if (second_long.AplyAllNode("PolemizeValidDays"))
            {
                item.PolemizeValidDays = forumSetItem.PolemizeValidDays;
            }

            if (second_long.AplyAllNode("PollValidDays"))
            {
                item.PollValidDays = forumSetItem.PollValidDays;
            }

            if (second_long.AplyAllNode("QuestionValidDays"))
            {
                item.QuestionValidDays = forumSetItem.QuestionValidDays;
            }


            if (second_long.AplyAllNode("SellThreadDays"))
            {
                item.SellThreadDays = forumSetItem.SellThreadDays;
            }


            if (second_long.AplyAllNode("SellAttachmentDays"))
            {
                item.SellAttachmentDays = forumSetItem.SellAttachmentDays;
            }

            if (second_int.AplyAllNode("RecycleOwnThreadsIntervals"))
            {
                item.RecycleOwnThreadsIntervals = forumSetItem.RecycleOwnThreadsIntervals;
            }

            if (second_int.AplyAllNode("UpdateThreadSortOrderIntervals"))
            {
                item.UpdateThreadSortOrderIntervals = forumSetItem.UpdateThreadSortOrderIntervals;
            }

            if (second_int.AplyAllNode("CreatePostIntervals"))
            {
                item.CreatePostIntervals = forumSetItem.CreatePostIntervals;
            }

            if (second_int.AplyAllNode("DeleteOwnThreadsIntervals"))
            {
                item.DeleteOwnThreadsIntervals = forumSetItem.DeleteOwnThreadsIntervals;
            }

            if (extensionList.AplyAllNode("AllowFileExtensions"))
            {
                item.AllowFileExtensions = forumSetItem.AllowFileExtensions;
            }


            ExceptableItem_bool except_bool = new ExceptableItem_bool();

            if (except_bool.AplyAllNode("AllowAttachment"))
            {
                item.AllowAttachment = forumSetItem.AllowAttachment;
            }

            if (except_bool.AplyAllNode("AllowImageAttachment"))
            {
                item.AllowImageAttachment = forumSetItem.AllowImageAttachment;
            }

            if (except_bool.AplyAllNode("CreatePostAllowAudioTag"))
            {
                item.CreatePostAllowAudioTag = forumSetItem.CreatePostAllowAudioTag;
            }

            if (except_bool.AplyAllNode("CreatePostAllowEmoticon"))
            {
                item.CreatePostAllowEmoticon = forumSetItem.CreatePostAllowEmoticon;
            }

            if (except_bool.AplyAllNode("CreatePostAllowFlashTag"))
            {
                item.CreatePostAllowFlashTag = forumSetItem.CreatePostAllowFlashTag;
            }

            if (except_bool.AplyAllNode("CreatePostAllowHTML"))
            {
                item.CreatePostAllowHTML = forumSetItem.CreatePostAllowHTML;
            }

            if (except_bool.AplyAllNode("CreatePostAllowImageTag"))
            {
                item.CreatePostAllowImageTag = forumSetItem.CreatePostAllowImageTag;
            }

            if (except_bool.AplyAllNode("CreatePostAllowMaxcode"))
            {
                item.CreatePostAllowMaxcode = forumSetItem.CreatePostAllowMaxcode;
            }

            if (except_bool.AplyAllNode("CreatePostAllowTableTag"))
            {
                item.CreatePostAllowTableTag = forumSetItem.CreatePostAllowTableTag;
            }

            if (except_bool.AplyAllNode("CreatePostAllowUrlTag"))
            {
                item.CreatePostAllowUrlTag = forumSetItem.CreatePostAllowUrlTag;
            }

            if (except_bool.AplyAllNode("CreatePostAllowVideoTag"))
            {
                item.CreatePostAllowVideoTag = forumSetItem.CreatePostAllowVideoTag;
            }

            if (new ExceptableItem_Int_MoreThenZero().AplyAllNode("MaxPostAttachmentCount"))
            {
                item.MaxPostAttachmentCount = forumSetItem.MaxPostAttachmentCount;
            }

            if (new ExceptableItem_Int_MoreThenZero().AplyAllNode("MaxTopicAttachmentCount"))
            {
                item.MaxTopicAttachmentCount = forumSetItem.MaxTopicAttachmentCount;
            }

            if (new ExceptableItem_FileSize().AplyAllNode("MaxSignleAttachmentSize"))
            {
                item.MaxSignleAttachmentSize = forumSetItem.MaxSignleAttachmentSize;
            }

            if (new ExceptableItem_bool().AplyAllNode("ShowSignatureInThread"))
            {
                item.ShowSignatureInThread = forumSetItem.ShowSignatureInThread;
            }

            if (new ExceptableItem_bool().AplyAllNode("ShowSignatureInPost"))
            {
                item.ShowSignatureInPost = forumSetItem.ShowSignatureInPost;
            }


            if (new ExceptableItem_bool().AplyAllNode("CreateThreadNeedApprove"))
            {
                item.CreateThreadNeedApprove = forumSetItem.CreateThreadNeedApprove;
            }

            if (new ExceptableItem_bool().AplyAllNode("ReplyNeedApprove"))
            {
                item.ReplyNeedApprove = forumSetItem.ReplyNeedApprove;
            }

            if (new ExceptableItem_bool().AplyAllNode("EnableSellThread"))
            {
                item.EnableSellThread = forumSetItem.EnableSellThread;
            }

            if (new ExceptableItem_bool().AplyAllNode("EnableSellAttachment"))
            {
                item.EnableSellAttachment = forumSetItem.EnableSellAttachment;
            }

            if (second_int.AplyAllNode("UpdateOwnPostIntervals"))
            {
                item.UpdateOwnPostIntervals = forumSetItem.UpdateOwnPostIntervals;
            }

            if (_Request.Get <bool>("enableHiddenTag_aplyallnode", Method.Post, false))
            {
                item.EnableHiddenTag = forumSetItem.EnableHiddenTag;
            }

            if (_Request.Get <bool>("enableThreadRank_aplyallnode", Method.Post, false))
            {
                item.EnableThreadRank = forumSetItem.EnableThreadRank;
            }


            if (_Request.Get <bool>("displayInListForGuest_aplyallnode", Method.Post, false))
            {
                item.DisplayInListForGuest = forumSetItem.DisplayInListForGuest;
            }

            if (_Request.Get <bool>("allowGuestVisitForum_aplyallnode", Method.Post, false))
            {
                item.AllowGuestVisitForum = forumSetItem.AllowGuestVisitForum;
            }

            if (_Request.Get <bool>("SellThreadDays_aplyallnode", Method.Post, false))
            {
                item.SellThreadDays = forumSetItem.SellThreadDays;
            }
            if (_Request.Get <bool>("SellAttachmentDays_aplyallnode", Method.Post, false))
            {
                item.SellAttachmentDays = forumSetItem.SellAttachmentDays;
            }

            if (new ExceptableItem_bool().AplyAllNode("VisitForum"))
            {
                item.VisitForum = forumSetItem.VisitForum;
            }

            if (new ExceptableItem_bool().AplyAllNode("DisplayInList"))
            {
                item.DisplayInList = forumSetItem.DisplayInList;
            }

            if (_Request.Get <bool>("ReplyReturnThreadLastPage_aplyallnode", Method.Post, false))
            {
                item.ReplyReturnThreadLastPage = forumSetItem.ReplyReturnThreadLastPage;
            }

            if (_Request.Get <bool>("ThreadSortField_aplyallnode", Method.Post, false))
            {
                item.DefaultThreadSortField = forumSetItem.DefaultThreadSortField;
            }
        }
 //判断有没有购买过
 private bool CheckPermission(ForumSettingItem forumSettting)
 {
     //是否已经买过了
     if (attachment.UserID != userID
         && attachment.Price != 0
         && !attachment.IsOverSellDays(forumSettting)
         && !attachment.IsBuyed(operatorUser))
     {
         return false;
     }
     return true;
 }
Exemple #8
0
        private static string OnMatchLocalFile(Match match, ForumSettingItem forumSetting, User postUser, AttachmentCollection attachments, List<int> realAttachmentIDs, Dictionary<string, int> fileIDs, bool isReview)
        {
            if (match.Success == false)
                return match.Value;

            string atype = match.Groups["atype"].Value;
            string type = match.Groups["type"].Value;
            string param = match.Groups["param"].Value;

            bool isLocal = StringUtil.EqualsIgnoreCase(atype, "local");

            int id = int.Parse(match.Groups["id"].Value);

            if (type == string.Empty || StringUtil.EqualsIgnoreCase(type, "file"))//[local]12[/local] [diskfile]12[/diskfile]
            {
                int j = 0;
                for (int i = 0; i < attachments.Count; i++)
                {

                    if (isLocal&& attachments[i].AttachType == AttachType.TempAttach)
                    {
                        if (attachments[i].AttachmentID > 0)
                            continue;

                        if (realAttachmentIDs != null && j == realAttachmentIDs.Count)
                            return match.Value;

                        if (attachments[i].AttachmentID == -id)
                        {
                            if (isReview)
                                return GetAttachUrl(attachments[i]);
                            else
                                return GetAttachTag(realAttachmentIDs[j]);
                        }

                        j++;
                    }
                    else if(attachments[i].AttachType == AttachType.DiskFile)
                    {
                        if (attachments[i].DiskFileID == id)
                        {
                            if (isReview)
                                return GetAttachUrl(attachments[i]);
                            else
                            {
                                int attachmentID;
                                if (fileIDs.TryGetValue(attachments[i].FileID, out attachmentID))
                                {
                                    return GetAttachTag(attachmentID);
                                }
                                else
                                    return match.Value;
                            }
                        }
                    }

                }
            }
            else if (StringUtil.EqualsIgnoreCase(type, "img"))//[localimg]12[/localimg]
            {
                string[] p = StringUtil.Split(param);
                string width, height;
                if (p.Length > 1)
                {
                    width = p[0];
                    height = p[1];
                }
                else
                {
                    width = string.Empty;
                    height = string.Empty;
                }

                int j = 0;
                for (int i = 0; i < attachments.Count; i++)
                {

                    Attachment attachment = attachments[i];

                    if (isLocal && attachment.AttachType == AttachType.TempAttach)
                    {
                        if (attachment.AttachmentID > 0)
                            continue;
                        if (realAttachmentIDs != null && j == realAttachmentIDs.Count)
                            return match.Value;

                        if (attachment.AttachmentID == -id)
                        {
                            if (isImage(attachment.FileType))
                            {
                                if (isReview)
                                {
                                    if (forumSetting.CreatePostAllowImageTag.GetValue(postUser))
                                    {
                                        return GetImageUrl(attachment.AttachmentID, false, width, height, false);
                                    }
                                    else
                                    {
                                        return GetAttachUrl(attachment, false);
                                    } 
                                }
                                else
                                    return GetAttachImgTag(realAttachmentIDs[j], width, height);
                            }
                            else
                                return match.Value;
                        }

                        j++;
                    }
                    else if(attachment.AttachType == AttachType.DiskFile)
                    {
                        if (attachment.DiskFileID == id)
                        {
                            if (isImage(attachment.FileType))//确实是图片才处理
                            {
                                if (isReview)
                                {
                                    if (forumSetting.CreatePostAllowImageTag.GetValue(postUser))
                                    {
                                        return GetImageUrl(attachment.DiskFileID, false, width, height, true);
                                    }
                                    else
                                    {
                                        return GetAttachUrl(attachment, true);
                                    }
                                }
                                else
                                {
                                    int attachmentID;
                                    if (fileIDs.TryGetValue(attachment.FileID, out attachmentID))
                                    {

                                        return GetAttachImgTag(attachmentID, width, height);
                                    }
                                    else
                                        return match.Value;
                                }
                            }
                            else
                                return match.Value;
                        }
                    }
                }
            }
            else if (StringUtil.EqualsIgnoreCase(type, "media"))//[localmedia]12[/localmedia]
            {
                string[] p = StringUtil.Split(param);
                string width, height;
                bool auto = false;
                if (p.Length > 1)
                {
                    width = p[0];
                    height = p[1];
                    if (p.Length > 2)
                    {
                        if (string.Compare(p[2], "1") == 0)
                        {
                            auto = true;
                        }
                    }
                }
                else
                {
                    width = string.Empty;
                    height = string.Empty;
                }

                int j = 0;
                for (int i = 0; i < attachments.Count; i++)
                {

                    Attachment attachment = attachments[i];

                    if (isLocal && attachment.AttachType == AttachType.TempAttach)
                    {
                        if (attachment.AttachmentID > 0)
                            continue;

                        if (realAttachmentIDs != null && j == realAttachmentIDs.Count)
                            return match.Value;

                        if (attachment.AttachmentID == -id)
                        {
                            if (isMediaFile(attachment.FileType))
                            {
                                if (isReview)
                                    return GetMediaContent(attachment, false, width, height, auto, forumSetting, postUser);
                                else
                                    return GetAttachMediaTag(realAttachmentIDs[j], width, height, auto);
                            }
                            else
                                return match.Value;
                        }

                        j++;
                    }
                    else if(attachment.AttachType == AttachType.DiskFile)
                    {
                        if (attachment.DiskFileID == id)
                        {
                            if (isMediaFile(attachment.FileType))
                            {
                                if (isReview)
                                    return GetMediaContent(attachment, true, width, height, auto, forumSetting, postUser);
                                else
                                {
                                    int attachmentID;
                                    if (fileIDs.TryGetValue(attachment.FileID, out attachmentID))
                                    {
                                        return GetAttachMediaTag(attachmentID, width, height, auto);
                                    }
                                    else
                                        return match.Value;
                                }
                            }
                            else
                                return match.Value;
                        }
                    }
                }
            }

            return match.Value;
        }
Exemple #9
0
        public static string GetMediaContent(Attachment attachment, bool isDiskFile, object width, object height, bool auto
            , ForumSettingItem forumSetting, User user, ref bool? allowAudioTag, ref bool? allowVideoTag, ref bool? allowFlashTag)
        {
            string url;
            if (isDiskFile)
                url = BbsUrlHelper.GetDiskImageAttachmentUrl(attachment.DiskFileID);
            else
                url = BbsUrlHelper.GetImageAttachmentUrl(attachment.AttachmentID, false);

            switch (attachment.FileType.ToLower())
            {
                case "mp3":
                case "wma":
                case "mid":
                case "wav":
                    if (allowAudioTag == null)
                        allowAudioTag = forumSetting.CreatePostAllowAudioTag.GetValue(user);
                    if (allowAudioTag.Value)
                    {
                        MP3 mp3 = new MP3(true, true);
                        if (width == null || height == null)
                        {
                            return mp3.BuildHtml(url);
                        }
                        else
                        {
                            return mp3.BuildHtml(width, height, auto, url);
                        }
                    }
                    break;
                case "wmv":
                case "avi":
                    if (allowVideoTag == null)
                        allowVideoTag = forumSetting.CreatePostAllowVideoTag.GetValue(user);
                    if (allowVideoTag.Value)
                    {
                        WMV wmv = new WMV(true, true);
                        if (width == null || height == null)
                        {
                            return wmv.BuildHtml(url);
                        }
                        else
                        {
                            return wmv.BuildHtml(width, height, auto, url);
                        }
                    }
                    break;
                case "ra":
                case "rm":
                case "rmvb":
                    if (allowVideoTag == null)
                        allowVideoTag = forumSetting.CreatePostAllowVideoTag.GetValue(user);
                    if (allowVideoTag.Value)
                    {
                        RM media = new RM(true, true);
                        if (width == null || height == null)
                        {
                            return media.BuildHtml(url);
                        }
                        else
                        {
                            return media.BuildHtml(width, height, auto, url);
                        }
                    }
                    break;
                case "flv":
                    if (allowVideoTag == null)
                        allowVideoTag = forumSetting.CreatePostAllowVideoTag.GetValue(user);
                    if (allowVideoTag.Value)
                    {
                        FLV media = new FLV(true, true);
                        if (width == null || height == null)
                        {
                            return media.BuildHtml(url);
                        }
                        else
                        {
                            return media.BuildHtml(width, height, auto, url);
                        }
                    }
                    break;
                case "swf":
                    if (allowFlashTag == null)
                        allowFlashTag = forumSetting.CreatePostAllowFlashTag.GetValue(user);
                    if (allowFlashTag.Value)
                    {
                        FLASH media = new FLASH(true, true);
                        if (width == null || height == null)
                        {
                            return media.BuildHtml(url);
                        }
                        else
                        {
                            return media.BuildHtml(width, height, auto, url);
                        }
                    }
                    break;
                default: break;
            }
            return GetAttachUrl(attachment, isDiskFile);
        }
Exemple #10
0
 public static string GetMediaContent(Attachment attachment, bool isDiskFile, object width, object height, bool auto
     , ForumSettingItem forumSetting, User user)
 {
     return GetMediaContent(attachment, isDiskFile, width, height, auto, forumSetting, user);
 }
Exemple #11
0
 private static string ProcessAttach(Attachment attachment, AuthUser operatorUser, ForumSettingItem forumSetting, bool canAlwaysViewContents)
 {
     if (attachment.Price == 0 || canAlwaysViewContents || attachment.UserID == operatorUser.UserID || attachment.IsBuyed(operatorUser) || attachment.IsOverSellDays(forumSetting))
     {
         return GetAttachUrl(attachment);
     }
     else//附件没购买,不显示。
     {
         return GetMustBuyFileLink(attachment.FileName);
     }
 }
Exemple #12
0
        private static string OnMatchAllAttach(Match match, AuthUser operatorUser, User postUser, int forumID, AttachmentCollection attachments, ForumSettingItem forumSetting
            , ref bool? hasViewAttachPermission, ref bool? canAlwaysViewContents, ref bool? allowImageTag, ref bool? allowAudioTag, ref bool? allowVideoTag, ref bool? allowFlashTag)
        {
            if (match.Success == false)
                return match.Value;

            string type = match.Groups["type"].Value;

            if (hasViewAttachPermission == null)
                hasViewAttachPermission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(forumID).Can(operatorUser, ForumPermissionSetNode.Action.ViewAttachment);

            if (!hasViewAttachPermission.Value)
            {
                string message;
                if (operatorUser.UserID == 0)
                {
                    message = "您是游客";
                }
                else
                {
                    message = string.Empty;
                }

                if (StringUtil.EqualsIgnoreCase(type, "img"))
                    return GetNopermissionStyle(string.Concat(message, "您没有权限查看该图片"));
                else if (StringUtil.EqualsIgnoreCase(type, "media"))
                    return GetNopermissionStyle(string.Concat(message, "您没有权限查看该多媒体"));
                else
                {
                    int attachID = int.Parse(match.Groups["id"].Value);
                    Attachment attachment = attachments.GetValue(attachID);
                    if (attachment != null)
                        return GetNoPermissonfileStyle(attachment.FileName, operatorUser.UserID == 0);
                    else
                        return match.Value;
                }
            }
            else
            {
                int attachID = int.Parse(match.Groups["id"].Value);
                Attachment attachment = attachments.GetValue(attachID);

                if (attachment == null)
                    return match.Value;

                if (canAlwaysViewContents == null)
                {
                    ForumPermissionSetNode forumPermission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(forumID);
                    canAlwaysViewContents = forumPermission.Can(operatorUser, ForumPermissionSetNode.Action.AlwaysViewContents);
                }

                if (StringUtil.EqualsIgnoreCase(type, "img"))
                {
                    if (allowImageTag == null)
                    {
                        allowImageTag = forumSetting.CreatePostAllowImageTag.GetValue(postUser);
                    }
                    if (allowImageTag.Value)
                    {
                        if (attachment.Price == 0 || attachment.UserID == operatorUser.UserID || canAlwaysViewContents.Value || attachment.IsBuyed(operatorUser) || attachment.IsOverSellDays(forumSetting))
                        {
                            //string info = string.Concat("<br /><img src=\"", attachment.FileIcon, "\" alt=\"\" /><a href=\"", BbsUrlHelper.GetAttachmentUrl(attachment.AttachmentID), "\">", attachment.FileName, "</a>  <span class=\"filesize gray\">(大小:", attachment.FileSizeFormat, "    下载次数:", attachment.TotalDownloads.ToString(), ")</span><br />");

                            string[] param = StringUtil.Split(match.Groups["param"].Value);
                            string width, height;
                            if (param.Length > 1)
                            {
                                width = param[0];
                                height = param[1];
                            }
                            else
                            {
                                width = string.Empty;
                                height = string.Empty;
                            }
                            return GetImageUrl(attachment.AttachmentID, false, width, height);
                        }
                        else
                        {
                            return string.Concat("<br /><img src=\"", attachment.FileIcon, "\" alt=\"\" />", attachment.FileName, " <span class=\"filesize gray\">(大小:", attachment.FileSizeFormat, "    下载次数:" + attachment.TotalDownloads.ToString(), ")</span><br />", GetNopermissionStyle("您需要购买后才能查看该图片"));
                        }
                    }
                    else
                        return ProcessAttach(attachment, operatorUser, forumSetting, canAlwaysViewContents.Value);
                }
                else if (StringUtil.EqualsIgnoreCase(type, "media"))
                {
                    if (attachment.Price == 0 || canAlwaysViewContents.Value || attachment.UserID == operatorUser.UserID || attachment.IsBuyed(operatorUser)
                        || attachment.IsOverSellDays(forumSetting))
                    {
                        string[] param = StringUtil.Split(match.Groups["param"].Value);
                        string width, height;
                        bool auto = false;
                        if (param.Length > 1)
                        {
                            width = param[0];
                            height = param[1];
                            if (param.Length > 2)
                            {
                                if (string.Compare(param[2], "1") == 0)
                                {
                                    auto = true;
                                }
                            }
                        }
                        else
                        {
                            width = string.Empty;
                            height = string.Empty;
                        }

                        //return string.Concat("<br /><img src=\"", attachment.FileIcon, "\" alt=\"\" />", "<a href=\"", BbsUrlHelper.GetAttachmentUrl(attachment.AttachmentID), "\">", attachment.FileName
                        //    , "</a>  <span class=\"filesize gray\">(大小:", attachment.FileSizeFormat, "    下载次数:", attachment.TotalDownloads, ")</span><br />"
                        //    , GetMediaContent(attachment, false, width, height, auto, forumSetting, user, ref allowAudioTag, ref allowVideoTag, ref allowFlashTag));

                        return GetMediaContent(attachment, false, width, height, auto, forumSetting, operatorUser, ref allowAudioTag, ref allowVideoTag, ref allowFlashTag);

                    }
                    else
                    {
                        return string.Concat("<br /><img src=\"", attachment.FileIcon, "\" alt=\"\" />", attachment.FileName, "<span class=\"filesize gray\">(大小:", attachment.FileSizeFormat
                            , "    下载次数:", attachment.TotalDownloads, ")</span><br />", GetNopermissionStyle("您需要购买后才能查看该多媒体"));
                    }
                }
                else
                {
                    return ProcessAttach(attachment, operatorUser, forumSetting, canAlwaysViewContents.Value);
                }
            }
        }
        private void SaveSettings2()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("PostContentLengths", "PostSubjectLengths", "PolemizeValidDays", "PollValidDays", "QuestionValidDays",
                "RecycleOwnThreadsIntervals", "UpdateThreadSortOrderIntervals", "CreatePostIntervals", "DeleteOwnThreadsIntervals", "AllowFileExtensions",
                "new_PostContentLengths", "new_PostSubjectLengths", "new_PolemizeValidDays", "new_PollValidDays", "new_QuestionValidDays",
                "new_RecycleOwnThreadsIntervals", "new_UpdateThreadSortOrderIntervals", "new_CreatePostIntervals", "new_DeleteOwnThreadsIntervals", "new_AllowFileExtensions"
                , "AllowAttachment", "AllowImageAttachment", "CreatePostAllowAudioTag", "CreatePostAllowEmoticon", "CreatePostAllowFlashTag", "CreatePostAllowHTML"
                , "CreatePostAllowImageTag", "CreatePostAllowMaxcode", "CreatePostAllowTableTag", "CreatePostAllowUrlTag", "CreatePostAllowVideoTag", "MaxPostAttachmentCount"
                , "MaxTopicAttachmentCount", "MaxSignleAttachmentSize", "ShowSignatureInThread", "ShowSignatureInPost", "CreateThreadNeedApprove", "ReplyNeedApprove"
                , "new_AllowAttachment", "new_AllowImageAttachment", "new_CreatePostAllowAudioTag", "new_CreatePostAllowEmoticon", "new_CreatePostAllowFlashTag", "new_CreatePostAllowHTML"
                , "new_CreatePostAllowImageTag", "new_CreatePostAllowMaxcode", "new_CreatePostAllowTableTag", "new_CreatePostAllowUrlTag", "new_CreatePostAllowVideoTag", "new_MaxPostAttachmentCount"
                , "new_MaxTopicAttachmentCount", "new_MaxSignleAttachmentSize", "new_ShowSignatureInThread", "new_ShowSignatureInPost", "new_CreateThreadNeedApprove", "new_ReplyNeedApprove"
                , "UpdateOwnPostIntervals", "new_UpdateOwnPostIntervals"
                , "EnableSellThread", "new_EnableSellThread"
                , "EnableSellAttachment", "new_EnableSellAttachment"
                , "DisplayInList", "new_DisplayInList"
                , "VisitForum", "new_VisitForum"
                , "SellAttachmentDays"
                , "SellThreadDays"
                , "ReplyReturnThreadLastPage"
                , "ThreadSortField"
                );


            if (_Request.Get("inheritType", Method.Post, "False").ToLower() == "true")//继承上级
            {
                ForumSettings tempSetting = AllSettings.Current.ForumSettings.Clone();

                ForumSettingItemCollection tempItems = new ForumSettingItemCollection();

                for (int i = 0; i < tempSetting.Items.Count; i++)
                {
                    if (tempSetting.Items[i].ForumID == ForumID)
                    {
                    }
                    else
                        tempItems.Add(tempSetting.Items[i]);
                }

                tempSetting.Items = tempItems;
                try
                {
                    if (!SettingManager.SaveSettings(tempSetting))
                    {
                        CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                        m_Success = false;
                    }
                    else
                    {
                        BbsRouter.JumpToUrl(Request.RawUrl, "success=true");
                    }
                }
                catch (Exception ex)
                {
                    m_Success = false;
                    msgDisplay.AddError(ex.Message);
                }
                return;
            }



            ForumSettingItem forumSetItem = new ForumSettingItem();

            ExceptableItem_Int32scope int32scope = new ExceptableItem_Int32scope();
            ExceptableItem_Second<long> second_long = new ExceptableItem_Second<long>();
            ExceptableItem_Second<int> second_int = new ExceptableItem_Second<int>();
            ExceptableItem_ExtensionList extensionList = new ExceptableItem_ExtensionList();

            forumSetItem.ForumID = ForumID;
            forumSetItem.PostContentLengths = int32scope.GetExceptable("PostContentLengths", msgDisplay); //GetInt32Exceptable("PostContentLengths",msgDisplay);
            forumSetItem.PostSubjectLengths = int32scope.GetExceptable("PostSubjectLengths", msgDisplay);//GetInt32Exceptable("PostSubjectLengths",msgDisplay);
            forumSetItem.PolemizeValidDays = second_long.GetExceptable("PolemizeValidDays",msgDisplay);
            forumSetItem.PollValidDays = second_long.GetExceptable("PollValidDays", msgDisplay);
            forumSetItem.QuestionValidDays = second_long.GetExceptable("QuestionValidDays", msgDisplay);
            forumSetItem.RecycleOwnThreadsIntervals = second_int.GetExceptable("RecycleOwnThreadsIntervals", msgDisplay);
            forumSetItem.UpdateThreadSortOrderIntervals = second_int.GetExceptable("UpdateThreadSortOrderIntervals", msgDisplay);
            forumSetItem.UpdateOwnPostIntervals = second_int.GetExceptable("UpdateOwnPostIntervals", msgDisplay);
            forumSetItem.CreatePostIntervals = second_int.GetExceptable("CreatePostIntervals", msgDisplay);
            forumSetItem.DeleteOwnThreadsIntervals = second_int.GetExceptable("DeleteOwnThreadsIntervals", msgDisplay);
            forumSetItem.AllowFileExtensions = extensionList.GetExceptable("AllowFileExtensions", msgDisplay);

            forumSetItem.AllowAttachment = new ExceptableItem_bool().GetExceptable("AllowAttachment", msgDisplay);
            forumSetItem.AllowImageAttachment = new ExceptableItem_bool().GetExceptable("AllowImageAttachment", msgDisplay);
            forumSetItem.CreatePostAllowAudioTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowAudioTag", msgDisplay);
            forumSetItem.CreatePostAllowEmoticon = new ExceptableItem_bool().GetExceptable("CreatePostAllowEmoticon", msgDisplay);
            forumSetItem.CreatePostAllowFlashTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowFlashTag", msgDisplay);
            forumSetItem.CreatePostAllowHTML = new ExceptableItem_bool().GetExceptable("CreatePostAllowHTML", msgDisplay);
            forumSetItem.CreatePostAllowImageTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowImageTag", msgDisplay);
            forumSetItem.CreatePostAllowMaxcode = new ExceptableItem_bool().GetExceptable("CreatePostAllowMaxcode", msgDisplay);
            forumSetItem.CreatePostAllowTableTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowTableTag", msgDisplay);
            forumSetItem.CreatePostAllowUrlTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowUrlTag", msgDisplay);
            forumSetItem.CreatePostAllowVideoTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowVideoTag", msgDisplay);
            forumSetItem.MaxPostAttachmentCount = new ExceptableItem_Int_MoreThenZero().GetExceptable("MaxPostAttachmentCount", msgDisplay);
            forumSetItem.MaxTopicAttachmentCount = new ExceptableItem_Int_MoreThenZero().GetExceptable("MaxTopicAttachmentCount", msgDisplay);
            forumSetItem.MaxSignleAttachmentSize = new ExceptableItem_FileSize().GetExceptable("MaxSignleAttachmentSize", msgDisplay);
            forumSetItem.ShowSignatureInPost = new ExceptableItem_bool().GetExceptable("ShowSignatureInPost",msgDisplay);
            forumSetItem.ShowSignatureInThread = new ExceptableItem_bool().GetExceptable("ShowSignatureInThread", msgDisplay);
            forumSetItem.CreateThreadNeedApprove = new ExceptableItem_bool().GetExceptable("CreateThreadNeedApprove", msgDisplay);
            forumSetItem.ReplyNeedApprove = new ExceptableItem_bool().GetExceptable("ReplyNeedApprove", msgDisplay);
            forumSetItem.EnableSellThread = new ExceptableItem_bool().GetExceptable("EnableSellThread", msgDisplay);
            forumSetItem.EnableSellAttachment = new ExceptableItem_bool().GetExceptable("EnableSellAttachment", msgDisplay);
            forumSetItem.EnableHiddenTag = _Request.Get<bool>("enableHiddenTag", Method.Post, true);
            forumSetItem.EnableThreadRank = _Request.Get<bool>("EnableThreadRank", Method.Post, true);
            forumSetItem.DefaultThreadSortField = _Request.Get<ThreadSortField>("ThreadSortField", Method.Post, ThreadSortField.LastReplyDate);


            ThreadSortField oldThreadSortField = ForumSetting.DefaultThreadSortField;
            ThreadSortField newThreadSortField = forumSetItem.DefaultThreadSortField;


            forumSetItem.AllowGuestVisitForum = _Request.Get<bool>("AllowGuestVisitForum", Method.Post, true);
            forumSetItem.DisplayInListForGuest = _Request.Get<bool>("DisplayInListForGuest", Method.Post, true);
            forumSetItem.VisitForum = new ExceptableItem_bool().GetExceptable("VisitForum", msgDisplay);
            forumSetItem.DisplayInList = new ExceptableItem_bool().GetExceptable("DisplayInList", msgDisplay);



            forumSetItem.SellThreadDays = GetSeconds("SellThreadDays", msgDisplay);
            forumSetItem.SellAttachmentDays = GetSeconds("SellAttachmentDays", msgDisplay);

            forumSetItem.ReplyReturnThreadLastPage = _Request.Get<bool>("ReplyReturnThreadLastPage", Method.Post, false);

            if (msgDisplay.HasAnyError())
            {
                m_Success = false;
                return;
            }

            ForumSettings settings = AllSettings.Current.ForumSettings.Clone();
            ForumSettingItemCollection items = new ForumSettingItemCollection();


            bool hasAdd = false;
            bool hasTopItem = false;//是否有ForumID为0的设置  
            foreach (ForumSettingItem item in settings.Items)
            {
                if (item.ForumID == forumSetItem.ForumID)
                {
                    items.Add(forumSetItem);
                    hasAdd = true;
                }
                else
                {
                    ProcessApplyAllForumSetting(item,forumSetItem);

                    items.Add(item);
                }
                if (item.ForumID == 0)
                    hasTopItem = true;
            }
            if (hasAdd == false)
                items.Add(forumSetItem);


            if (hasTopItem == false)//如果没有 加入
            {
                ForumSettingItem tempItem = new ForumSettingItem();
                ProcessApplyAllForumSetting(tempItem, forumSetItem);
                items.Add(tempItem);
            }

            settings.Items = items;

            try
            {
                using (new ErrorScope())
                {

                    bool success = SettingManager.SaveSettings(settings);

                    if (!success)
                    {
                        CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                        m_Success = false;
                    }
                    else
                    {
                        if (_Request.Get<bool>("ThreadSortField_aplyallnode", Method.Post, false))
                        {
                            ThreadCachePool.ClearAllCache();
                        }
                        else if (oldThreadSortField != newThreadSortField)
                        {
                            ThreadCachePool.ClearAllCache();
                        }

                        string rawUrl = Request.RawUrl;

                        BbsRouter.JumpToUrl(rawUrl, "success=true");
                    }

                }
            }
            catch (Exception ex)
            {
                m_Success = false;
                msgDisplay.AddError(ex.Message);
            }
        }
        private void ProcessApplyAllForumSetting(ForumSettingItem item, ForumSettingItem forumSetItem)
        {
            ExceptableItem_Int32scope int32scope = new ExceptableItem_Int32scope();
            ExceptableItem_Second<long> second_long = new ExceptableItem_Second<long>();
            ExceptableItem_Second<int> second_int = new ExceptableItem_Second<int>();
            ExceptableItem_ExtensionList extensionList = new ExceptableItem_ExtensionList();

            if (int32scope.AplyAllNode("PostContentLengths"))
                item.PostContentLengths = forumSetItem.PostContentLengths;

            if (int32scope.AplyAllNode("PostSubjectLengths"))
                item.PostSubjectLengths = forumSetItem.PostSubjectLengths;

            if (second_long.AplyAllNode("PolemizeValidDays"))
                item.PolemizeValidDays = forumSetItem.PolemizeValidDays;

            if (second_long.AplyAllNode("PollValidDays"))
                item.PollValidDays = forumSetItem.PollValidDays;

            if (second_long.AplyAllNode("QuestionValidDays"))
                item.QuestionValidDays = forumSetItem.QuestionValidDays;


            if (second_long.AplyAllNode("SellThreadDays"))
                item.SellThreadDays = forumSetItem.SellThreadDays;


            if (second_long.AplyAllNode("SellAttachmentDays"))
                item.SellAttachmentDays = forumSetItem.SellAttachmentDays;

            if (second_int.AplyAllNode("RecycleOwnThreadsIntervals"))
                item.RecycleOwnThreadsIntervals = forumSetItem.RecycleOwnThreadsIntervals;

            if (second_int.AplyAllNode("UpdateThreadSortOrderIntervals"))
                item.UpdateThreadSortOrderIntervals = forumSetItem.UpdateThreadSortOrderIntervals;

            if (second_int.AplyAllNode("CreatePostIntervals"))
                item.CreatePostIntervals = forumSetItem.CreatePostIntervals;

            if (second_int.AplyAllNode("DeleteOwnThreadsIntervals"))
                item.DeleteOwnThreadsIntervals = forumSetItem.DeleteOwnThreadsIntervals;

            if (extensionList.AplyAllNode("AllowFileExtensions"))
                item.AllowFileExtensions = forumSetItem.AllowFileExtensions;


            ExceptableItem_bool except_bool = new ExceptableItem_bool();

            if (except_bool.AplyAllNode("AllowAttachment"))
                item.AllowAttachment = forumSetItem.AllowAttachment;

            if (except_bool.AplyAllNode("AllowImageAttachment"))
                item.AllowImageAttachment = forumSetItem.AllowImageAttachment;

            if (except_bool.AplyAllNode("CreatePostAllowAudioTag"))
                item.CreatePostAllowAudioTag = forumSetItem.CreatePostAllowAudioTag;

            if (except_bool.AplyAllNode("CreatePostAllowEmoticon"))
                item.CreatePostAllowEmoticon = forumSetItem.CreatePostAllowEmoticon;

            if (except_bool.AplyAllNode("CreatePostAllowFlashTag"))
                item.CreatePostAllowFlashTag = forumSetItem.CreatePostAllowFlashTag;

            if (except_bool.AplyAllNode("CreatePostAllowHTML"))
                item.CreatePostAllowHTML = forumSetItem.CreatePostAllowHTML;

            if (except_bool.AplyAllNode("CreatePostAllowImageTag"))
                item.CreatePostAllowImageTag = forumSetItem.CreatePostAllowImageTag;

            if (except_bool.AplyAllNode("CreatePostAllowMaxcode"))
                item.CreatePostAllowMaxcode = forumSetItem.CreatePostAllowMaxcode;

            if (except_bool.AplyAllNode("CreatePostAllowTableTag"))
                item.CreatePostAllowTableTag = forumSetItem.CreatePostAllowTableTag;

            if (except_bool.AplyAllNode("CreatePostAllowUrlTag"))
                item.CreatePostAllowUrlTag = forumSetItem.CreatePostAllowUrlTag;

            if (except_bool.AplyAllNode("CreatePostAllowVideoTag"))
                item.CreatePostAllowVideoTag = forumSetItem.CreatePostAllowVideoTag;

            if (new ExceptableItem_Int_MoreThenZero().AplyAllNode("MaxPostAttachmentCount"))
                item.MaxPostAttachmentCount = forumSetItem.MaxPostAttachmentCount;

            if (new ExceptableItem_Int_MoreThenZero().AplyAllNode("MaxTopicAttachmentCount"))
                item.MaxTopicAttachmentCount = forumSetItem.MaxTopicAttachmentCount;

            if (new ExceptableItem_FileSize().AplyAllNode("MaxSignleAttachmentSize"))
                item.MaxSignleAttachmentSize = forumSetItem.MaxSignleAttachmentSize;

            if (new ExceptableItem_bool().AplyAllNode("ShowSignatureInThread"))
                item.ShowSignatureInThread = forumSetItem.ShowSignatureInThread;

            if (new ExceptableItem_bool().AplyAllNode("ShowSignatureInPost"))
                item.ShowSignatureInPost = forumSetItem.ShowSignatureInPost;


            if (new ExceptableItem_bool().AplyAllNode("CreateThreadNeedApprove"))
                item.CreateThreadNeedApprove = forumSetItem.CreateThreadNeedApprove;

            if (new ExceptableItem_bool().AplyAllNode("ReplyNeedApprove"))
                item.ReplyNeedApprove = forumSetItem.ReplyNeedApprove;

            if (new ExceptableItem_bool().AplyAllNode("EnableSellThread"))
                item.EnableSellThread = forumSetItem.EnableSellThread;

            if (new ExceptableItem_bool().AplyAllNode("EnableSellAttachment"))
                item.EnableSellAttachment = forumSetItem.EnableSellAttachment;

            if (second_int.AplyAllNode("UpdateOwnPostIntervals"))
                item.UpdateOwnPostIntervals = forumSetItem.UpdateOwnPostIntervals;

            if (_Request.Get<bool>("enableHiddenTag_aplyallnode", Method.Post, false))
            {
                item.EnableHiddenTag = forumSetItem.EnableHiddenTag;
            }

            if (_Request.Get<bool>("enableThreadRank_aplyallnode", Method.Post, false))
            {
                item.EnableThreadRank = forumSetItem.EnableThreadRank;
            }


            if (_Request.Get<bool>("displayInListForGuest_aplyallnode", Method.Post, false))
            {
                item.DisplayInListForGuest = forumSetItem.DisplayInListForGuest;
            }

            if (_Request.Get<bool>("allowGuestVisitForum_aplyallnode", Method.Post, false))
            {
                item.AllowGuestVisitForum = forumSetItem.AllowGuestVisitForum;
            }

            if (_Request.Get<bool>("SellThreadDays_aplyallnode", Method.Post, false))
            {
                item.SellThreadDays = forumSetItem.SellThreadDays;
            }
            if (_Request.Get<bool>("SellAttachmentDays_aplyallnode", Method.Post, false))
            {
                item.SellAttachmentDays = forumSetItem.SellAttachmentDays;
            }

            if (new ExceptableItem_bool().AplyAllNode("VisitForum"))
                item.VisitForum = forumSetItem.VisitForum;

            if (new ExceptableItem_bool().AplyAllNode("DisplayInList"))
                item.DisplayInList = forumSetItem.DisplayInList;

            if (_Request.Get<bool>("ReplyReturnThreadLastPage_aplyallnode", Method.Post, false))
            {
                item.ReplyReturnThreadLastPage = forumSetItem.ReplyReturnThreadLastPage;
            }

            if (_Request.Get<bool>("ThreadSortField_aplyallnode", Method.Post, false))
            {
                item.DefaultThreadSortField = forumSetItem.DefaultThreadSortField;
            }
        }
        public override bool BeforeUpload(HttpContext context, string fileName, string serverFilePath, NameValueCollection queryString, ref object customResult)
        {
            Forum forum = GetForum(context);

            if (forum == null)
            {
                return(false);
            }

            AuthUser operatorUser = User.Current;

            if (operatorUser.UserID == 0)
            {
                WebEngine.Context.ThrowError <NoPermissionCreateAttachmentError>(new NoPermissionCreateAttachmentError(forum.ForumID));
                return(false);
            }

            ForumSettingItem forumSetting = AllSettings.Current.ForumSettings.Items.GetForumSettingItem(forum.ForumID);

            if (false == forumSetting.AllowAttachment[operatorUser])
            {
                WebEngine.Context.ThrowError <NoPermissionCreateAttachmentError>(new NoPermissionCreateAttachmentError(forum.ForumID));
                return(false);
            }

            int  usedAttachmentCount;
            long totalUsedFileSize;

            PostBOV5.Instance.GetUserTodayAttachmentInfo(operatorUser.UserID, null, out usedAttachmentCount, out totalUsedFileSize);

            PageCacheUtil.Set(Key_TodayTotalUsedFileSize, totalUsedFileSize);

            int maxCountInDay = AllSettings.Current.BbsSettings.MaxAttachmentCountInDay[operatorUser];

            if (maxCountInDay == 0)
            {
                maxCountInDay = int.MaxValue;
            }
            int count = maxCountInDay - usedAttachmentCount;

            if (count < 1)
            {
                WebEngine.Context.ThrowError <OverTodayAlowAttachmentCountError>(new OverTodayAlowAttachmentCountError(maxCountInDay, 0, 1));
                return(false);
            }

            int    index    = fileName.LastIndexOf('.') + 1;
            string fileType = fileName.Substring(index, fileName.Length - index);

            if (false == forumSetting.AllowFileExtensions[operatorUser].Contains(fileType))
            {
                WebEngine.Context.ThrowError <NotAllowAttachmentFileTypeError>(new NotAllowAttachmentFileTypeError(forum.ForumID, fileType));
                return(false);
            }

            if (m_CheckFileSize == true)
            {
                long fileSize = 0;

                if (long.TryParse(queryString["filesize"], out fileSize))
                {
                    return(CheckFileSize(context, fileName, fileSize));
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }