示例#1
0
        protected bool VerifyRedirectToken(string novelId, out int code, out Constants.Novel.ChapterDirection direction, int timeout = 0)
        {
            if (ChapterContext.IsToken)
            {
                code      = 0;
                direction = Constants.Novel.ChapterDirection.none;
                string token     = UrlParameterHelper.GetParams("t");
                string timeStamp = UrlParameterHelper.GetParams("s");
                string random    = UrlParameterHelper.GetParams("r");

                if (string.IsNullOrEmpty(token) ||
                    string.IsNullOrEmpty(timeStamp) ||
                    string.IsNullOrEmpty(random))
                {
                    return(false);
                }

                return(ChapterContext.VerifyRedirectToken(token, novelId, timeStamp, random, out code, out direction, timeout));
            }
            else
            {
                code = StringHelper.ToInt(UrlParameterHelper.GetParams("chapterCode"));
                if (!EnumHelper.TryParsebyName <Constants.Novel.ChapterDirection>(UrlParameterHelper.GetParams("direction"), out direction))
                {
                    direction = Constants.Novel.ChapterDirection.none;
                }
                return(true);
            }
        }
示例#2
0
        private string GetReplyTextUrl(string url, out string replyText)
        {
            replyText = "";

            string rp = UrlParameterHelper.GetParams("rp");

            if (!string.IsNullOrEmpty(rp) && ChapterContext.VerifyReplyText(rp, out replyText))
            {
                url = StringHelper.SpliceUrl(url, "rp", rp);
            }

            return(url);
        }
示例#3
0
        public void Set(int minChapterCode, int maxChapterCode)
        {
            if (NovelId <= 0)
            {
                return;
            }

            _chapterCodeRange = ChapterContext.GetRangeToken(minChapterCode, maxChapterCode);
            if (!string.IsNullOrEmpty(_chapterCodeRange))
            {
                _minChapterCode = minChapterCode;
                _maxChapterCode = maxChapterCode;

                Reset();
            }
        }
示例#4
0
        public ChapterPagerManage(Func <int, ChapterCodeRange> func, bool isCustomRange = false, int chapterCodeRangeTimeout = 0, int chapterRedirectTimeout = 0)
            : base(chapterRedirectTimeout)
        {
            if (NovelId <= 0)
            {
                return;
            }

            string chapterCodeRange = string.Empty;

            if (isCustomRange && !string.IsNullOrEmpty(chapterCodeRange = UrlParameterHelper.GetParams("cc")))
            {
                int      min   = 0;
                int      max   = 0;
                string[] range = chapterCodeRange.Split('_');
                if (!range.IsNullOrEmpty() && range.Length == 2 &&
                    int.TryParse(range[0], out min) && min >= 0 &&
                    int.TryParse(range[1], out max) && max >= 0)
                {
                    Set(min, max);
                }
            }
            else
            {
                _chapterCodeRange = UrlParameterHelper.GetParams("c");
                if (!string.IsNullOrEmpty(_chapterCodeRange) &&
                    ChapterContext.VerifyRangeToken(_chapterCodeRange, out _minChapterCode, out _maxChapterCode, chapterCodeRangeTimeout))
                {
                    Reset();
                }
                else
                {
                    if (func != null)
                    {
                        ChapterCodeRange range = func(NovelId);
                        if (!range.IsNullOrEmpty <ChapterCodeRange>())
                        {
                            Set(range.MinChapterCode, range.MaxChapterCode);
                        }
                    }
                }
            }
        }