Exemple #1
0
        public string BuildGuestID()
        {
            string guestID;

            if (PageCacheUtil.TryGetValue <string>("GuestID_BX", out guestID) == false)
            {
                HttpCookie cookie = CookieUtil.Get("bbxmax_guest");

                if (cookie != null)
                {
                    guestID = cookie.Value;
                }
                else
                {
                    guestID = string.Empty;
                }

                //必须是32位长度(GUID)
                if (guestID == null || guestID.Length != 32)
                {
                    guestID = Guid.NewGuid().ToString("N");
                    CookieUtil.Set("bbxmax_guest", guestID, DateTime.MaxValue);
                }

                PageCacheUtil.Set("GuestID_BX", guestID);
            }

            if (guestID == string.Empty)
            {
                return(null);
            }

            return(guestID);
        }
Exemple #2
0
        public string PrizeDescription(string lineFormat, string separator)
        {
            string key = string.Format(prizeDescriptionKey, lineFormat, separator, this.Prize.ConvertToString());
            string description;

            if (PageCacheUtil.TryGetValue <string>(key, out description) == false)
            {
                description = MissionBO.Instance.GetMissionPrizeDescription(this.Prize, lineFormat, separator);
                PageCacheUtil.Set(key, description);
            }

            return(description);
        }
        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);
        }
Exemple #4
0
        private FieldInfo[] GetFieldInfosWithTarget()
        {
            string cachekey = string.Format("PermissionSet/FieldInfos/{0}", typeof(TA2).Name);

            FieldInfo[] fieldInfos;

            if (PageCacheUtil.TryGetValue(cachekey, out fieldInfos) == false)
            {
                fieldInfos = typeof(TA2).GetFields(BindingFlags.Static | BindingFlags.Public);

                PageCacheUtil.Set(cachekey, fieldInfos);
            }

            return(fieldInfos);
        }
Exemple #5
0
        private BasicThread ProcessLastThread(BasicThread thread, string key)
        {
            if (thread.ThreadStatus == ThreadStatus.Recycled || thread.ThreadStatus == ThreadStatus.UnApproved)
            {
                //PostBOV5.Instance.ClearTopThreadsCache(ForumID);
                ThreadCachePool.ClearAllCache();
                ThreadCollectionV5 threads = PostBOV5.Instance.GetTopThreads(ForumID);
                if (threads != null && threads.Count > 0)
                {
                    thread       = threads[0];
                    LastThreadID = thread.ThreadID;
                }
                else
                {
                    LastThreadID = 0;
                    return(null);
                }
            }
            if (thread.ThreadType == ThreadType.Join || thread.ThreadType == ThreadType.Move)
            {
                int threadID;
                if (int.TryParse(thread.Subject.Substring(0, thread.Subject.IndexOf(',')), out threadID))
                {
                    thread = PostBOV5.Instance.GetThread(threadID);
                    if (thread == null)
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            if (thread != null)
            {
                PageCacheUtil.Set(key, thread);
            }

            return(thread);
        }
        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);
        }